
## Delete an order

`DELETE /v1/orders/:id`

Deletes an order by identifier along with its related basket items and payments. A deleted order cannot be restored via the API — create a new one if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Order identifier |

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/orders/859" \
  -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/orders/859', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

if (res.status === 204) {
  console.log('Order deleted')
}
```

### JavaScript — OAuth application

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

if (res.status === 204) {
  console.log('Order deleted')
}
```

## Response

On successful deletion, an HTTP status `204 No Content` is returned with an empty body — success is checked by the status.

## Response example

```http
HTTP/1.1 204 No Content
```

## Error response example

422 — order not found:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "order is not exists"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 422 | `BITRIX_ERROR` | An order with this ID was not found or has already been deleted |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## Known specifics

**Cascading deletion.** Deleting an order automatically deletes the related basket items and payments — there is no need to call `DELETE /v1/basket-items/:id` or `DELETE /v1/payments/:id` separately.

**Alternative — cancel instead of delete.** To preserve history and links, it is better to cancel the order via [`PATCH /v1/orders/:id`](./update.md) with `{"canceled": true, "reasonCanceled": "..."}` — the order remains in query results with `filter[canceled]=true`.

## See also

- [Update an order](./update.md)
- [List orders](./list.md)
- [Get an order](./get.md)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
