## Update a delivery service

`PATCH /v1/delivery-services/:id`

Partially updates a delivery service by ID, preserving the values of fields omitted from the request.

Pass fields at the JSON root without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` (path) | integer | yes | Positive safe integer ID from the [delivery service list](/docs/entities/delivery-services/list) |

## Request fields (body)

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string | no | Service name. Empty strings and `"0"` are not accepted |
| `currency` | string | no | Currency code, for example `USD`. [List currencies](/docs/entities/currencies/list) |
| `description` | string | no | Service description |
| `sort` | integer | no | Sort index |
| `active` | string | no | Service activity, for example `Y` or `N` |
| `logo` | string[] | no | Two nonempty elements: the file name and its base64 content. The decoded file must be at most 2 MiB |

The body must contain at least one field. The JSON body must be at most 3 MiB.

Set `restCode` and `config` only when [creating a service](/docs/entities/delivery-services/create).

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/delivery-services/85" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Courier delivery to an address"
}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/delivery-services/85" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Courier delivery to an address"
}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/delivery-services/85', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Courier delivery to an address',
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/delivery-services/85', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Courier delivery to an address',
  }),
})

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

## Response fields

HTTP status: `200 OK`. Returns the updated record.

`RO` marks read-only fields.

| Field | Type | Description |
|---|---|---|
| `success` | boolean | `true` on success |
| `data` | object | Updated delivery service |
| `data.id` | integer | Service ID. RO |
| `data.parentId` | integer \| null | Parent service ID or `null`. RO |
| `data.name` | string \| null | Service name |
| `data.active` | string \| null | Service activity |
| `data.description` | string \| null | Service description |
| `data.currency` | string \| null | Currency code |
| `data.sort` | integer \| null | Sort index |
| `data.logotype` | integer \| null | Logo file ID, not a URL, or `null`. RO. Use `logo` to write the file |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 85,
    "parentId": null,
    "name": "Courier delivery to an address",
    "active": "N",
    "description": "",
    "currency": "USD",
    "sort": 100,
    "logotype": null
  }
}
```

## Error response example

400 — the body contains `logotype` instead of `logo`:

```json
{
  "success": false,
  "error": {
    "code": "READONLY_FIELD",
    "message": "Field 'logotype' is not writable for this operation"
  }
}
```

## Errors

| HTTP | `error.code` | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | `id` is not a positive safe integer, a field has an invalid type, or `logo` contains an invalid file |
| 400 | `MISSING_REQUIRED_FIELDS` | The body is not a nonempty JSON object, or `name` is an empty string or `"0"` |
| 400 | `READONLY_FIELD` | The body contains a field absent from the request field table, including `logotype`, `restCode`, or `config` |
| 404 | `ENTITY_NOT_FOUND` | The service with the specified `id` was not found during the update |
| 404 | `ENTITY_NOT_FOUND` | After a successful write, the updated service was not found when reading the result |
| 413 | `PAYLOAD_TOO_LARGE` | The logo file exceeds 2 MiB, or the JSON body exceeds 3 MiB |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected or did not confirm the update. See `error.message` for the reason |
| 502 | `BITRIX_RESPONSE_INVALID` | The Bitrix24 update response has an invalid structure |
| 502 | `BITRIX_RESPONSE_INVALID` | A valid record could not be read after the update |
| 403 | `BITRIX_ACCESS_DENIED` | The user lacks permission to modify the service, the service was created without a REST handler, or it belongs to another OAuth application |
| 401 | `TOKEN_MISSING` | The API key has no configured Bitrix24 credentials |
| 403 | `SCOPE_DENIED` | The API key lacks the `delivery` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The API key is in read-only mode |

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

## Known specifics

An error while reading the result does not mean the change was not saved. Before retrying, check the service with [get by ID](/docs/entities/delivery-services/get).

## See also

- [Delivery services](/docs/entities/delivery-services)
- [List delivery services](/docs/entities/delivery-services/list)
- [Get a delivery service](/docs/entities/delivery-services/get)
- [Create a delivery service](/docs/entities/delivery-services/create)
- [Delete a delivery service](/docs/entities/delivery-services/delete)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
