## Create an enumeration field value

`POST /v1/userfields/:entity/enum-values`

Adds one option to an existing CRM enumeration field. Send the body without a `fields` wrapper.

> **This feature is rolling out.** It requires a CRM update after `26.2200.0` and activation by an administrator. The release version has not been published. Until available, requests return `422 METHOD_NOT_YET_AVAILABLE` with `error.release`.

For Smart Process Automation (SPA) fields, use the same contract at `POST /v1/items/:entityTypeId/userfields/enum-values`. Invoices are also available through `entityTypeId=31`.

## Parameters

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `entity` (path) | string | yes | — | `deals` — deals, `leads` — leads, `contacts` — contacts, `companies` — companies, `quotes` — estimates, `invoices` — invoices |
| `entityTypeId` (path) | integer | for the alternate path | — | [SPA type](/docs/entities/smart-processes/list) ID, or `31` for invoices |

## Request body fields

| Field | Type | Required | Description |
|---|---|---|---|
| `fieldId` | integer / string | yes | ID or `UF_*` code of an enumeration field. Sources: [CRM fields](/docs/userfields/crm/list), [SPA fields](/docs/userfields/smart-processes/list) |
| `value` | string | yes | Option label |
| `isDefault` | boolean | no | Use as a default option |
| `sort` | integer | no | Sort order |
| `xmlId` | string / null | no | External integration ID |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/userfields/deals/enum-values" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fieldId": 6008145, "value": "VIBE-PROBE option", "isDefault": false, "sort": 500, "xmlId": "VIBE-PROBE-X"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/userfields/deals/enum-values" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fieldId": 6008145, "value": "VIBE-PROBE option", "isDefault": false, "sort": 500, "xmlId": "VIBE-PROBE-X"}'
```

### JavaScript — personal key

```javascript
const response = await fetch(
  'https://vibecode.bitrix24.com/v1/userfields/deals/enum-values',
  {
    "method": "POST",
    "headers": {
      "X-Api-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "fieldId": 6008145,
      "value": "VIBE-PROBE option",
      "isDefault": false,
      "sort": 500,
      "xmlId": "VIBE-PROBE-X"
    })
  }
)
const { success, data } = await response.json()
```

### JavaScript — OAuth application

```javascript
const response = await fetch(
  'https://vibecode.bitrix24.com/v1/userfields/deals/enum-values',
  {
    "method": "POST",
    "headers": {
      "X-Api-Key": "YOUR_APP_KEY",
      "Authorization": "Bearer USER_SESSION_TOKEN",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "fieldId": 6008145,
      "value": "VIBE-PROBE option",
      "isDefault": false,
      "sort": 500,
      "xmlId": "VIBE-PROBE-X"
    })
  }
)
const { success, data } = await response.json()
```

## Response fields

HTTP `201 Created`.

| Field | Type | Description |
|---|---|---|
| `success` | boolean | `true` on success |
| `data` | object | Field option |
| `data.id` | integer | Option ID for [retrieval](/docs/entities/crm-field-enum/get) |
| `data.fieldId` | integer | Field ID. See [CRM fields](/docs/userfields/crm/list) and [SPA fields](/docs/userfields/smart-processes/list) |
| `data.value` | string | Option label |
| `data.isDefault` | boolean | Used as a default option |
| `data.sort` | integer | Sort order |
| `data.xmlId` | string / null | External integration ID |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 4119,
    "fieldId": 6008145,
    "value": "VIBE-PROBE option",
    "isDefault": false,
    "sort": 500,
    "xmlId": "VIBE-PROBE-X"
  }
}
```

## Error response example

400 — invalid request:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Use enum fields fieldId (add only), value, isDefault, sort and xmlId with their documented types"
  }
}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | Invalid request shape or parameter type |
| 400 | `UNKNOWN_FILTER_FIELD` | Unknown or repeated query parameter |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The feature is not yet available. Update information is provided in `error.release` |
| 502 | `BITRIX_UNAVAILABLE` | Invalid response from Bitrix24 |
| 401 | `MISSING_API_KEY` | Missing `X-Api-Key` |
| 401 | `TOKEN_MISSING` | No Bitrix24 tokens are configured |
| 403 | `SCOPE_DENIED` | The key requires the `crm` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | Creation is blocked for a `READONLY` key |

For shared API errors, see [Errors](/docs/errors).

## Known specifics

After an ambiguous failure, check the [option list](/docs/entities/crm-field-enum/list) before retrying. A blind retry can create another option.

## See also

- [List enumeration field values](/docs/entities/crm-field-enum/list)
- [Get an enumeration field value](/docs/entities/crm-field-enum/get)
- [Update an enumeration field value](/docs/entities/crm-field-enum/update)
- [Delete an enumeration field value](/docs/entities/crm-field-enum/delete)
- [CRM enumeration field values](/docs/entities/crm-field-enum)
