## Payer type fields

`GET /v1/person-types/fields`

Describes payer type fields for creation, updates, selection, and filtering, and lists the available grouping fields.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/person-types/fields" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/person-types/fields" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/person-types/fields', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { data } = await res.json()
console.log('Payer type fields:', Object.keys(data.fields))
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/person-types/fields', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.fields` | object | Field definitions. Each key is a field name, and its value contains the field properties |
| `data.fields.<field>.type` | string | Value type: `number`, `string`, or `boolean` |
| `data.fields.<field>.readonly` | boolean | `true` means the field is read-only |
| `data.fields.<field>.required` | boolean | Included as `true` for `name`, which is required for creation |
| `data.fields.<field>.nullable` | boolean | Included as `true` for `code` and `xmlId`, which allow `null` |
| `data.fields.<field>.notReturned` | boolean | Included as `true` for `lid`: the field is in the schema but omitted from response objects |
| `data.fields.<field>.label` | string | Field label |
| `data.fields.<field>.description` | string | Field description |
| `data.aggregatable` | array | Fields for `groupBy` in [Aggregate payer types](./aggregate.md): `active`, `code` |
| `data.batch` | array | Batch write operations: `create`, `update`, `delete` |

### Payer type fields

All fields from the schema. The RO column marks read-only fields.

| Field | Type | RO | Description |
|------|-----|:--:|---------|
| `id` | number | yes | Payer type ID. List: [`GET /v1/person-types`](./list.md) |
| `name` | string | no | Name. Required for creation and [updates](./update.md) |
| `code` | string \| null | no | Unique code. `null` if not set |
| `sort` | number | no | Sort order |
| `active` | boolean | no | Whether the type is active |
| `xmlId` | string \| null | no | External ID. `null` if not set |
| `lid` | string | yes | Site assigned by Bitrix24. Marked `notReturned` and omitted from response objects |

## Response example

```json
{
  "success": true,
  "data": {
    "fields": {
      "id": {
        "type": "number",
        "readonly": true,
        "label": "ID",
        "description": "ID."
      },
      "name": {
        "type": "string",
        "readonly": false,
        "required": true,
        "label": "Name",
        "description": "Name."
      },
      "code": {
        "type": "string",
        "readonly": false,
        "nullable": true,
        "label": "Unique code",
        "description": "Unique code."
      },
      "sort": {
        "type": "number",
        "readonly": false,
        "label": "Sort order",
        "description": "Sort order."
      },
      "active": {
        "type": "boolean",
        "readonly": false,
        "label": "Active",
        "description": "Active."
      },
      "xmlId": {
        "type": "string",
        "readonly": false,
        "nullable": true,
        "label": "External ID",
        "description": "External ID."
      },
      "lid": {
        "type": "string",
        "readonly": true,
        "notReturned": true,
        "label": "Site assigned by Bitrix24",
        "description": "Site assigned by Bitrix24."
      }
    },
    "aggregatable": [
      "active",
      "code"
    ],
    "batch": [
      "create",
      "update",
      "delete"
    ]
  }
}
```

## Error response example

401 — the API key is missing:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_API_KEY",
    "message": "API key required. Pass via X-Api-Key header."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 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 |
| 429 | `RATE_LIMITED` | Request limit exceeded: 300 per minute per portal, shared by all API keys for the portal. The exact value is in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |

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

## See also

- [List payer types](./list.md)
- [Get a payer type](./get.md)
- [Create a payer type](./create.md)
- [Update a payer type](./update.md)
- [Aggregate payer types](./aggregate.md)
- [Payer types](/docs/entities/person-types)
- [Batch](/docs/batch)
- [Entity API](/docs/entity-api)
