# Patron Delete

Provider API v0.6.7 · 3 operations
Source: https://plasapi.com/provider/v0.6.7/patron-delete/

Deleting a patron from the library, either by patron ID and password, by identifier and password, or through an identity provider. The provider decides whether the patron may be deleted, for example while they still have loans or fees outstanding.

## Delete patron.

`POST` `/patron/delete` · `DeletePatron`

### Example request

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/delete?version=0.6.7" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "acknowledgement": {
    "code": "SplxlOBeZQQYbYS6WxSbIA"
  },
  "patron": {
    "identifiedBy": "patron_id",
    "password": "correct-horse-battery",
    "patronId": "40218873"
  }
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/delete?version=0.6.7`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "acknowledgement": {
      "code": "SplxlOBeZQQYbYS6WxSbIA"
    },
    "patron": {
      "identifiedBy": "patron_id",
      "password": "correct-horse-battery",
      "patronId": "40218873"
    }
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/delete",
    params={
        "version": "0.6.7",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "acknowledgement": {
            "code": "SplxlOBeZQQYbYS6WxSbIA",
        },
        "patron": {
            "identifiedBy": "patron_id",
            "password": "correct-horse-battery",
            "patronId": "40218873",
        },
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

### Request body

`application/json` · required

[`DeletePatronRequestBody`](https://plasapi.com/provider/v0.6.7/schemas/#DeletePatronRequestBody)

### Responses

#### `200` Success

`DeletePatronResponseBody`

Example (Generated from the schema):

```json
{
  "message": "I accept the library’s terms of use.",
  "status": "waiting_for_acknowledgement"
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

## This will fetch a SSO URL used for patron deletion, matching the chosen identity provider.

`GET` `/patron/delete/identity-provider` · `GetDeletePatronUrl`

### Example request

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/patron/delete/identity-provider?identity_provider=norway_id_portal&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&state=af0ifjsldkj&version=0.6.7" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/delete/identity-provider?identity_provider=norway_id_portal&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&state=af0ifjsldkj&version=0.6.7`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/patron/delete/identity-provider",
    params={
        "identity_provider": "norway_id_portal",
        "code_challenge": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
        "state": "af0ifjsldkj",
        "version": "0.6.7",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

- `identity_provider` (In `query`, [`ConfigurationPatronIdentityProviderType`](https://plasapi.com/provider/v0.6.7/schemas/#ConfigurationPatronIdentityProviderType), required) — The identity provider type, found in GET /configuration.
- `code_challenge` (In `query`, `string`, required) — A hashed value (of the code_verifier from a PKCE flow) used to secure the authorization code exchange.
- `state` (In `query`, `string`, required) — A random string to protect against CSRF and track the request state. The value should be returned to the Vendor on the callback url after deletion.
- `prompt` (In `query`, `string enum`, optional) — If prompt is set to login, the returned url should force a new login, even if the user is already logged in.
- `app_redirect_url` (In `query`, `string (uri)`, optional) — This value should be returned to the Vendor on the callback url after deletion.

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

### Responses

#### `200` Success

`PatronDeletionIdentityProviderResponseBody`

Example (Generated from the schema):

```json
{
  "url": "https://nordby.bibliotek.example/url"
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

## Delete patron by code and code verifier from SSO deletion.

`POST` `/patron/delete/identity-provider` · `DeletePatronByCodeAndCodeVerifier`

### Example request

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/delete/identity-provider?version=0.6.7" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "code": "SplxlOBeZQQYbYS6WxSbIA",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
  "identity_provider": "norway_id_portal"
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/delete/identity-provider?version=0.6.7`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "code": "SplxlOBeZQQYbYS6WxSbIA",
    "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
    "identity_provider": "norway_id_portal"
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/delete/identity-provider",
    params={
        "version": "0.6.7",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "code": "SplxlOBeZQQYbYS6WxSbIA",
        "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
        "identity_provider": "norway_id_portal",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

### Request body

`application/json` · required

[`DeletePatronByCodeAndCodeVerifierRequestBody`](https://plasapi.com/provider/v0.6.7/schemas/#DeletePatronByCodeAndCodeVerifierRequestBody)

### Responses

#### `200` Success

`DeletePatronResponseBody`

Example (Generated from the schema):

```json
{
  "message": "I accept the library’s terms of use.",
  "status": "waiting_for_acknowledgement"
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.7/)
