
## Create field

`POST /v1/userfields/:entity`

Creates a new user field for a CRM entity. Returns HTTP `201 Created` with the numeric `id` of the new field. Fields are passed flat at the JSON root — without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `:entity` (path) | string | yes | Entity: `deals`, `leads`, `contacts`, `companies`, `quotes`, `requisites` |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `userTypeId` | string | yes | Field type. For the list of allowed values, see [`GET /v1/userfields/:entity/types`](/docs/userfields/crm/types). Examples: `string`, `enumeration`, `integer`, `double`, `datetime` |
| `fieldName` | string | no | Suffix of the system name. The final name is formed as `UF_CRM_<FIELD_NAME>`. If you do not pass it, Bitrix24 generates the name automatically — leave the key out entirely; an empty string or `null` is not accepted. The name used to pass the field in entity record requests is different — [User fields (UF)](/docs/entity-api#user-fields-uf) |
| `label` | string | no | Display label of the field. The value is automatically propagated to all Bitrix24 account languages in `editFormLabel`, `listColumnLabel`, `listFilterLabel`, `errorMessage`, `helpMessage`. To set different labels per language, use the `editFormLabel` object |
| `editFormLabel` | object | no | Label in the edit form per language. Example: `{ "en": "Project", "de": "Projekt" }`. Values are set for the specified languages; the remaining locales are filled in according to Bitrix24 rules |
| `sort` | number \| string | no | Sort order in the Bitrix24 interface. Accepted as a number or a string, read back as a string. Defaults to `"100"` |
| `multiple` | boolean | no | Allow multiple values: `true` / `false` or `"Y"` / `"N"`. Off by default |
| `mandatory` | boolean | no | Required when filling in a record: `true` / `false` or `"Y"` / `"N"`. Off by default |
| `showFilter` | boolean | no | Show in the filter: `true` or `"Y"` — yes, `false` or `"N"` — no. On write, the letters `"I"` and `"S"` switch the filter off. An enabled filter reads back as `"E"`; sending that `"E"` back is safe — the platform reads it as "on" |
| `showInList` | boolean | no | Show in the record list: `true` / `false` or `"Y"` / `"N"` |
| `editInList` | boolean | no | Allow editing directly from the list: `true` / `false` or `"Y"` / `"N"` |
| `isSearchable` | boolean | no | Included in the Bitrix24 account's full-text search: `true` / `false` or `"Y"` / `"N"` |
| `xmlId` | string | no | External identifier for integrations |
| `settings` | object | no | Field settings specific to `userTypeId`. For `string`, `double`, and `crm`, the keys in the rows below are saved |
| `settings.ROWS` | number | no | For the `string` type: height of the input field in lines |
| `settings.DEFAULT_VALUE` | string | no | For the `string` type: default value |
| `settings.PRECISION` | number | no | For the `double` type: number of decimal places. Defaults to `0` |
| `settings.LEAD` | string | no | For the `crm` type: the field links to leads when the value is `"Y"` |
| `settings.CONTACT` | string | no | For the `crm` type: the field links to contacts when the value is `"Y"` |
| `settings.COMPANY` | string | no | For the `crm` type: the field links to companies when the value is `"Y"` |
| `settings.DEAL` | string | no | For the `crm` type: the field links to deals when the value is `"Y"` |
| `list` | array | no | Options for an `enumeration` field. Each item: `{ "VALUE": "Name", "SORT": 10 }`. Ignored for other types |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/userfields/deals" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "userTypeId": "enumeration",
    "fieldName": "PROJECT_STATUS",
    "label": "Project status",
    "sort": "200",
    "showFilter": true,
    "showInList": "Y",
    "list": [
      { "VALUE": "New", "SORT": 10 },
      { "VALUE": "In progress", "SORT": 20 },
      { "VALUE": "Completed", "SORT": 30 }
    ]
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/userfields/deals" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userTypeId": "enumeration",
    "fieldName": "PROJECT_STATUS",
    "label": "Project status",
    "sort": "200",
    "showFilter": true,
    "showInList": "Y",
    "list": [
      { "VALUE": "New", "SORT": 10 },
      { "VALUE": "In progress", "SORT": 20 },
      { "VALUE": "Completed", "SORT": 30 }
    ]
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/userfields/deals', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    userTypeId: 'enumeration',
    fieldName: 'PROJECT_STATUS',
    label: 'Project status',
    sort: '200',
    showFilter: true,
    showInList: 'Y',
    list: [
      { VALUE: 'New', SORT: 10 },
      { VALUE: 'In progress', SORT: 20 },
      { VALUE: 'Completed', SORT: 30 },
    ],
  }),
})

const { success, data } = await res.json()
console.log('Created field with id:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/userfields/deals', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    userTypeId: 'enumeration',
    fieldName: 'PROJECT_STATUS',
    label: 'Project status',
    sort: '200',
    showFilter: true,
    showInList: 'Y',
    list: [
      { VALUE: 'New', SORT: 10 },
      { VALUE: 'In progress', SORT: 20 },
      { VALUE: 'Completed', SORT: 30 },
    ],
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | Creation result |
| `data.id` | number | Numeric identifier of the created field |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 7115
  }
}
```

## Error response example

400 — the required parameter `userTypeId` is missing:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_FIELD",
    "message": "userTypeId is required (e.g. \"string\", \"enumeration\", \"integer\", \"double\", \"datetime\")"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_FIELD` | The required parameter `userTypeId` is missing |
| 400 | `INVALID_FIELD_NAME` | The `fieldName` key was passed, but its value is not a string or consists of whitespace only |
| 400 | `INVALID_REQUEST` | The request body is not an object |
| 400 | `UNKNOWN_ENTITY` | `:entity` is not in the list of supported entities |
| 422 | `BITRIX_ERROR` | An unknown `userTypeId` was passed — not from the [`/types`](/docs/userfields/crm/types) catalog |
| 422 | `BITRIX_ERROR` | Other Bitrix24 errors: duplicate field name, invalid `settings` |
| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**Auto-propagation of `label`.** When a `label` string is passed, the value automatically appears in all language fields: `editFormLabel`, `listColumnLabel`, `listFilterLabel`, `errorMessage`, `helpMessage`. To set different labels for different languages, pass the `editFormLabel` object: `{ "en": "Project", "de": "Projekt" }`.

**Linking a `crm` field.** The field links to records of the entities whose key in `settings` equals the string `"Y"`. A boolean `true` and lowercase keys are not saved. If no key equals `"Y"`, or `settings` is omitted, the field links to leads. Example body for a field that links to contacts and companies: `{ "userTypeId": "crm", "settings": { "CONTACT": "Y", "COMPANY": "Y" } }`.

**A link to a smart process is not saved.** This method does not save the `DYNAMIC_<entityTypeId>` key in the `settings` of a `crm` field: the response comes back with `201`, but the key is missing when you read the field. If the request has no other key set to `"Y"`, the field links to leads.

## See also

- [Field type catalog](/docs/userfields/crm/types)
- [Get field](/docs/userfields/crm/get)
- [Update field](/docs/userfields/crm/update)
- [Delete field](/docs/userfields/crm/delete)
- [CRM entity fields](/docs/userfields/crm)
- [User fields](/docs/userfields)
