## Delete a trace

`DELETE /v1/crm-traces/:id`

Deletes a sales-intelligence trace together with its bindings to CRM records. A deleted trace cannot be restored via the API — create a new one if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Trace identifier — a positive integer. Returned in `data.id` when [creating a trace](/docs/entities/crm-traces/create) |

## Examples

### curl — personal key

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

### curl — OAuth application

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

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

### JavaScript — OAuth application

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

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

## Response

On successful deletion, 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

400 — `id` is not a positive integer:

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

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the deletion. The error text is returned in `error.message` |
| 403 | `SCOPE_DENIED` | The key does not have the `crm` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key works in read-only mode |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## Known specifics

**Deletion is idempotent.** A nonexistent or already deleted trace also returns `204`. The response does not say whether the trace existed. You cannot check in advance whether a trace exists: there is no method for reading traces.

**Partial permissions.** If you have update permission for only some of the bound CRM records, the bindings to the accessible records are removed. The other bindings and the trace itself remain, and the response is still `204`.

## See also

- [Create a trace](/docs/entities/crm-traces/create)
- [Sales-intelligence traces](/docs/entities/crm-traces)
