
## Update deal

`PATCH /v1/deals/:id`

Updates the fields of an existing deal. Pass only the fields being changed. For the full list, see the [field reference](/docs/entities/deals/fields).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Deal ID. List: [`GET /v1/deals`](/docs/entities/deals/list) |

## Frequently updated fields

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `stageId` | string | no | Pipeline stage. Each pipeline has its own set of stages. List: `GET /v1/statuses?filter[entityId]=DEAL_STAGE` for the main pipeline, `DEAL_STAGE_{categoryId}` for the others |
| `amount` | number | no | Deal amount. To keep a manually set value, pass `isManualOpportunity: true` together with it |
| `assignedById` | number | no | Assigned person. List: `GET /v1/users` |
| `title` | string | no | Title |
| `closedAt` | datetime | no | Closing date |
| `ufCrm*` | per field schema | no | A user field of the Bitrix24 account, for example `ufCrmProjectCode`. The actual name and type are in the schema [`GET /v1/deals/fields`](/docs/entities/deals/fields), and the value format for each type is in [User fields (UF)](/docs/entity-api#user-fields-uf). An `enumeration` field takes the option `ID` from the field's `items` array in the schema, and a multiple field takes an array of such `ID`s. If you send the option label `VALUE` instead of the `ID`, the value is lost: a single-value field gets `0`. A number that is not among the options is stored as is. Neither the label nor a non-existent `ID` raises an error, and the request returns `200`, so map the label to its `ID` on your side and check the stored value of this field in the response `data` |

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/deals/741" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stageId": "WON",
    "amount": 75000
  }'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/deals/741" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "stageId": "WON",
    "amount": 75000
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/deals/741', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    stageId: 'WON',
    amount: 75000,
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/deals/741', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    stageId: 'WON',
    amount: 75000,
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data` | object | The updated deal object with all fields — see [Fields](/docs/entities/deals/fields) |
| `meta.warnings` | array | Present when the body carries fields that are neither in the deal schema nor in the field list of [`GET /v1/deals/fields`](/docs/entities/deals/fields), for example a misspelled name. The warning code is `UNRECOGNIZED_WRITE_FIELD`: such a field may not have been stored. The response status is `200`. On a route that wraps the field map itself, an object under `fields` is rejected with `400 NESTED_FIELDS_ENVELOPE` when the schema does not declare `fields`; pass fields flat at the JSON root. |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 741,
    "title": "Equipment delivery",
    "amount": 75000,
    "currency": "USD",
    "stageId": "WON",
    "categoryId": 0,
    "assignedById": 1,
    "updatedAt": "2026-04-14T09:15:00.000Z"
  }
}
```

## Error response example

404 — deal not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Item not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `ENTITY_NOT_FOUND` | Deal not found |
| 422 | `STAGE_NOT_APPLIED` | The `stageId`/`categoryId` you sent was not applied: after the `PATCH`, the value is unchanged. A possible cause is that no stage or pipeline with that ID exists. Details are in `error.message` and `error.details`. The re-read deal is in `data`. The record has already been updated, and other fields in the request body may have been applied: correct the value and send only what still needs changing, not the whole body again |
| 403 | `BITRIX_ACCESS_DENIED` | No access to the deal |
| 400 | `INVALID_PARAMS` | A field value has the wrong type or format, or the `id` in the path is not a non-negative integer |
| 400 | `EMPTY_UPDATE_BODY` | The request body is empty: there are no fields to change |
| 400 | `READONLY_FIELD` | The request body contains a read-only field, such as `isWon`. Such fields are marked in the RO column of [Deal fields](/docs/entities/deals/fields) |
| 403 | `SCOPE_DENIED` | API key lacks the `crm` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | API key has no configured tokens |

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

## See also

- [Working with files in CRM fields](/docs/recipes/crm-files)
- [Get deal](/docs/entities/deals/get)
- [Deal fields](/docs/entities/deals/fields)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
