## Delete a subscription

`DELETE /v1/infra/servers/:id/event-subscriptions/:subId`

Deletes the subscription and unregisters the event in Bitrix24 — deliveries of this event to the application stop. The response is `{ "success": true }` with HTTP status `200`.

## Parameters

| Parameter | In | Type | Req. | Description |
|----------|---|-----|:-----:|----------|
| `id` | path | string (UUID) | yes | Server ID. List: [`GET /v1/infra/servers`](/docs/infra/servers) |
| `subId` | path | string (UUID) | yes | Subscription ID. From the response of [`POST`](./create.md) or [`GET .../event-subscriptions`](./list.md) |

## Examples

### curl — personal key

```bash
curl -X DELETE -H "X-Api-Key: YOUR_API_KEY" \
  https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/event-subscriptions/SUBSCRIPTION_ID
```

### curl — OAuth application

```bash
curl -X DELETE \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/event-subscriptions/SUBSCRIPTION_ID
```

### JavaScript — personal key

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/event-subscriptions/${subId}`,
  { method: 'DELETE', headers: { 'X-Api-Key': 'YOUR_API_KEY' } }
)
const { success } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/event-subscriptions/${subId}`,
  {
    method: 'DELETE',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
    },
  }
)
const { success } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on successful deletion |

## Response example

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

## Error response example

404 — subscription not found:

```json
{
  "success": false,
  "error": {
    "code": "SUBSCRIPTION_NOT_FOUND",
    "message": "Subscription not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `NOT_FOUND` | Server not found or belongs to another API key |
| 404 | `SUBSCRIPTION_NOT_FOUND` | Subscription with the given `subId` was not found for this server |

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

## Known specifics

- **Deleting the same subscription again returns `404 SUBSCRIPTION_NOT_FOUND`.** After a successful deletion there is no longer a record with this `subId`, so the second call does not find the subscription.
- **You can also detach an event with a repeat `POST`.** If you need to redirect the event to a different path rather than delete the subscription, call [`POST`](./create.md) with the same `event` — it updates the `appPath` of the existing subscription.

## See also

- [Portal event subscriptions](/docs/infra/event-subscriptions)
- [Create a subscription](/docs/infra/event-subscriptions/create)
- [List subscriptions](/docs/infra/event-subscriptions/list)
- [Errors](/docs/errors)
