## Change a CRM setting

`PATCH /v1/crm-settings/:id`

Change a CRM setting for the entire Bitrix24 account. Use a key with write access and check the value schema first.

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` (path) | string | yes | Identifier from the [settings list](./list.md). |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `value` | any JSON | yes | Complete value matching `meta.schema` from [get](./get.md). Required even for `null`, `false` or `0`. |

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-settings/crm.layout.file_previewer.enabled" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": true}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-settings/crm.layout.file_previewer.enabled" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"value": true}'
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/crm-settings/crm.layout.file_previewer.enabled', {
  method: 'PATCH',
  headers: {"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
  body: JSON.stringify({"value": true}),
})
const result = await response.json()
```

### JavaScript — OAuth application

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/crm-settings/crm.layout.file_previewer.enabled', {
  method: 'PATCH',
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json"},
  body: JSON.stringify({"value": true}),
})
const result = await response.json()
```

## Response fields

| Field | Description |
|---|---|
| `data.id` | Identifier. |
| `data.value` | JSON value with its original type. |
| `data.meta.title` | Setting title. |
| `data.meta.description` | Setting description. |
| `data.meta.schema` | Accepted value schema, validated by Bitrix24. |

## Response example

Response structure with neutral sample data.

```json
{
  "success": true,
  "data": {
    "id": "crm.layout.file_previewer.enabled",
    "value": true,
    "meta": {
      "title": "File preview",
      "description": "Preview files",
      "schema": {
        "type": "boolean"
      }
    }
  }
}
```

## Error response example

400 — unknown query parameter or a missing required field:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_REQUIRED_FIELDS",
    "message": "value is required"
  }
}
```

## Errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | Invalid type or identifier. |
| 400 | `UNKNOWN_FILTER_FIELD` | Unknown query parameter. |
| 400 | `MISSING_REQUIRED_FIELDS` | Missing required body field. |
| 400 | `UNKNOWN_FIELD` | Unknown body field. |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 credentials. |
| 403 | `SCOPE_DENIED` | The `crm` scope is required. |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key access mode forbids writes. |
| 404 | `ENTITY_NOT_FOUND` | The record is absent or inaccessible. |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The method is absent on the account. `error.release` names the required release. |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned an invalid response shape. |

Other Bitrix24 refusals retain their original code and message. Common [API errors](/docs/errors).

## Known behavior

An object in `value` replaces the complete setting value. A successful write is not rolled back if its readback fails. Never blindly retry an ambiguous write failure: read the setting first.

## See also

- [CRM settings](/docs/entities/crm-settings)
- [CRM e-mails](/docs/entities/crm-emails)
