## Delete a delivery service

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

Deletes a delivery service by ID from the service list if the user has permission to delete it. Deleted records cannot be restored through the API.

## Parameters

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

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/delivery-services/85" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/delivery-services/85" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/delivery-services/85', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/delivery-services/85', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

HTTP status: `200 OK`.

| Field | Type | Description |
|---|---|---|
| `success` | boolean | `true` on success |
| `data` | boolean | `true` confirms deletion |

## Response example

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

## Error response example

404 — the service with the specified ID was not found:

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

## Errors

| HTTP | `error.code` | Description |
|---|---|---|
| 400 | `INVALID_PARAMS` | `id` is not a positive safe integer |
| 404 | `ENTITY_NOT_FOUND` | The service with the specified `id` was not found |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected or did not confirm deletion. See `error.message` for the reason |
| 502 | `BITRIX_RESPONSE_INVALID` | The deletion response has an invalid structure |
| 403 | `BITRIX_ACCESS_DENIED` | The user lacks permission to delete 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).

## 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)
- [Update a delivery service](/docs/entities/delivery-services/update)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
