## Revoke a link by code

`DELETE /v1/chats/sharing-links/:code`

Revokes your individual link by its code — a chat link or a guest link. After revocation, the code can no longer be used to join the chat. The chat is resolved from the code, so you do not specify it in the path.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `code` (path) | string | yes | The link code — the `code` field of the link object or the `IM_CODE` parameter of its address. From 1 to 64 printable characters without spaces |

The request takes no body: body fields and query parameters are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/sharing-links/Xk9pQ2mZ7rT4vB1c" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

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

const { data } = await res.json()
console.log('Revoked:', data.result)
```

### JavaScript — OAuth application

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

const { data } = await res.json()
console.log('Revoked:', data.result)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the link is revoked |

## Response example

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

## Error response example

422 — the link is already revoked:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "SHARING_LINK_ALREADY_REVOKED",
    "b24Code": "SHARING_LINK_ALREADY_REVOKED"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | The request failed validation for one of these reasons. `code` does not match the link code format: 1 to 64 printable characters without spaces. A query parameter or body field was passed — the method accepts none. The request body is not a JSON object |
| 403 | `BITRIX_ACCESS_DENIED` | You cannot revoke another member's individual link or a personal guest invitation — Bitrix24 refused with the `ACCESS_DENIED` code |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered with an unspecified "not found" code. The portal code is in `error.b24Code` if supplied |
| 422 | `BITRIX_ERROR` | Bitrix24 refused; the portal code is in `error.b24Code`. `SHARING_LINK_ALREADY_REVOKED`: the link is already revoked. `SHARING_LINK_WRONG_PARAMS`: the link is not an individual link that can be revoked this way, for example a primary chat link. `SHARING_LINK_NOT_FOUND`: no link with this code exists |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |

The full list of general API errors — [Errors](/docs/errors).

## Known specifics

**A guest link can be revoked without a code.** Your guest link can also be revoked with [guest link revocation](/docs/chats/sharing/guest-link-revoke) — it needs no code, only `dialogId`.

**A revoked link can still be read.** [Reading by code](/docs/chats/sharing/link-get) returns it exactly as before, with no revocation flag, and joining with it is rejected with `SHARING_LINK_REVOKED`.

## See also

- [Get a link by code](/docs/chats/sharing/link-get)
- [Regenerate an individual link](/docs/chats/sharing/individual-link-regenerate)
- [Revoke a guest link](/docs/chats/sharing/guest-link-revoke)
- [Links and guests](/docs/chats/sharing)
