## Update a payer type

`PATCH /v1/person-types/:id`

Updates an existing online store payer type used in orders and order properties.

Pass fields at the root of the JSON object, without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Payer type ID, a non-negative integer. List: [`GET /v1/person-types`](./list.md) |

## Request body fields

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `name` | string | yes | Name. To keep the existing name, read it with [`GET /v1/person-types/:id`](./get.md) |
| `code` | string \| null | no | Unique code. `null` keeps the existing code |
| `sort` | number | no | Sort order |
| `active` | boolean | no | Whether the type is active |
| `xmlId` | string \| null | no | External ID. `null` keeps the existing ID |

For the full field list, see [`GET /v1/person-types/fields`](./fields.md).

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/person-types/21" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Updated documentation payer",
  "sort": 910,
  "active": true
}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/person-types/21" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Updated documentation payer",
  "sort": 910,
  "active": true
}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/person-types/21', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Updated documentation payer',
    sort: 910,
    active: true,
  }),
})

const { success, data } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/person-types/21', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Updated documentation payer',
    sort: 910,
    active: true,
  }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success. The HTTP status is `200` |
| `data` | object | Updated payer type |
| `data.id` | number | RO. Payer type ID |
| `data.name` | string | Name |
| `data.code` | string \| null | Unique code |
| `data.sort` | number | Sort order |
| `data.active` | boolean | Whether the type is active |
| `data.xmlId` | string \| null | External ID |

## Response example

```json
{
  "success": true,
  "data": {
    "active": true,
    "code": "DOCS_PERSON_397F55D8FB1D",
    "id": 21,
    "name": "Updated documentation payer",
    "sort": 910,
    "xmlId": "DOCS_PERSON_397F55D8FB1D"
  }
}
```

## Error response example

422 — `active` was provided, but `name` is missing:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Required fields: name",
    "b24Code": "0"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `EMPTY_UPDATE_BODY` | The request body is empty |
| 400 | `NO_RECOGNIZED_UPDATE_FIELDS` | The body contains no writable payer type fields |
| 400 | `READONLY_FIELD` | A read-only field was provided: `id` or `lid` |
| 400 | `INVALID_PARAMS` | A scalar field received an object or array, such as an object in `active` |
| 400 | `INVALID_PARAMS` | The path `id` is not a non-negative integer |
| 404 | `ENTITY_NOT_FOUND` | No payer type exists with this `id`. Message: `person type is not exists` |
| 422 | `BITRIX_ERROR` | The `name` field is missing. Message: `Required fields: name`, `b24Code`: `0` |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the update for another reason, including a `code` already in use. The reason is in `message` |
| 403 | `BITRIX_ACCESS_DENIED` | The key owner lacks permission to modify payer types in Bitrix24 |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 403 | `SCOPE_DENIED` | The API key lacks the `sale` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

For the full list of common API errors, see [Error codes](/docs/errors).

## See also

- [Payer types](/docs/entities/person-types)
- [Get a payer type](./get.md)
- [Create a payer type](./create.md)
- [Payer type fields](./fields.md)
- [Delete a payer type](./delete.md)
