## Delete expenses from an end-to-end analytics source

`DELETE /v1/crm-tracking/expenses/:id`

Deletes a manually added expense pack. Expense packs from advertising integrations cannot be deleted. Deleted packs cannot be restored through the API; create a new one if needed.

> **The method ships in the `crm 26.2100.0` update and is not yet available on all Bitrix24 accounts.** Until the feature is enabled for your Bitrix24 account, the API returns `422 METHOD_NOT_YET_AVAILABLE`.

Requires the `crm` scope and a key with `READWRITE` access.

## Parameters

| Parameter | Type | Required | Default | Description |
|----------|-----|:-----:|-----------|----------|
| `id` (path) | integer | yes | — | Positive expense pack ID. [Expense list](/docs/entities/crm-tracking/expenses-list) |

Query parameters and request body fields are not accepted.

## Examples

### curl — personal key

```bash
curl -i -X DELETE "https://vibecode.bitrix24.com/v1/crm-tracking/expenses/7" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -i -X DELETE "https://vibecode.bitrix24.com/v1/crm-tracking/expenses/7" \
  -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/crm-tracking/expenses/7', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY'
  }
})
if (res.status === 204) {
  console.log('Deleted')
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-tracking/expenses/7', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN'
  }
})
if (res.status === 204) {
  console.log('Deleted')
}
```

## Response

Successful deletion returns HTTP `204 No Content` with an empty body. Check the status code to confirm success.

## Response example

Response shape example.

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

## Error response example

400 — invalid ID.

```json
{"success":false,"error":{"code":"INVALID_PARAMS","message":"id must be a positive safe integer"}}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | Invalid ID or request body fields were supplied |
| 400 | `UNKNOWN_FILTER_FIELD` | A query parameter was supplied |
| 403 | `SCOPE_DENIED` | The `crm` scope is missing |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key permits reads only |
| 404 | `ENTITY_NOT_FOUND` | Expense pack not found |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The feature is disabled for the Bitrix24 account or its version does not support the method |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 returned an invalid response |

Other Bitrix24 refusals retain their codes and messages. Secrets are removed from messages. General errors — [Errors](/docs/errors).

## See also

- [Expense list](/docs/entities/crm-tracking/expenses-list)
- [Add expenses](/docs/entities/crm-tracking/expenses-create)
- [Source list](/docs/entities/crm-tracking/sources-list)
