# Add and remove a pack

Add another user's pack to your sticker list or remove it. The pack itself does not change. Built-in packs are always in the list and cannot be removed.

## Add a pack

`POST /v1/chats/stickers/packs/:packId/link`

Adds a user pack by another author to the current user's list — the messenger v2 method `im.v2.Sticker.Pack.link`. This is usually how you add the pack of a sticker that arrived in a message. No request body is needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `packId` (path) | number | yes | Pack ID |
| `packType` | string | yes | Pack type. Only `custom` can be added |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom" \
  -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/stickers/packs/3/link?packType=custom', {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Added pack', data.pack.name)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Added pack', data.pack.name)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.pack` | object | The added pack: `id`, `name`, `type`, `authorId`, `isAdded` |
| `data.stickers` | array | Stickers of the pack — the same fields as in the [list of packs](/docs/chats/stickers/packs) |

## Response example

```json
{
  "success": true,
  "data": {
    "stickers": [
      { "id": 1, "uri": "/upload/im/stickers/3/1.png", "type": "image", "width": 512, "height": 512, "packId": 3, "packType": "custom", "sort": 1 }
    ],
    "pack": { "id": 3, "name": "Work stickers", "type": "custom", "authorId": 7, "isAdded": true }
  }
}
```

## Error response example

422 — the pack is already in the list (for example, it is your own pack):

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `packId` is not a positive integer, `packType` is missing or invalid, another parameter or body field was passed |
| 401 | `TOKEN_MISSING` | The key has no configured Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key lacks the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 403 | `BITRIX_ACCESS_DENIED` | The pack is built-in |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 did not find the object; the portal code is in `error.b24Code` if supplied |
| 422 | `BITRIX_ERROR` | `error.b24Code`: `LINK_EXISTS` — the pack is already in the list, `PACK_NOT_FOUND` — the pack does not exist, `MAX_PACKS_ERROR` — the list already has 50 user packs |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |

## Remove a pack

`DELETE /v1/chats/stickers/packs/:packId/link`

Removes an added user pack from the current user's list — the method `im.v2.Sticker.Pack.unlink`. The pack stays with its author and with other users, and it can be added again. The author cannot remove their own pack — only [delete](/docs/chats/stickers/pack) it.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `packId` (path) | number | yes | Pack ID |
| `packType` | string | yes | Pack type. Only `custom` can be removed |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom" \
  -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/stickers/packs/3/link?packType=custom', {
  method: 'DELETE',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { success } = await res.json()
console.log('Removed:', success)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/stickers/packs/3/link?packType=custom', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success } = await res.json()
console.log('Removed:', success)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.result` | boolean | `true` — the pack was removed from the list |

## Response example

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

## Error response example

403 — the pack is built-in or it is the author's own pack:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ACCESS_DENIED",
    "message": "ACCESS_DENIED"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `packId` is not a positive integer, `packType` is missing or invalid, another parameter or body field was passed |
| 401 | `TOKEN_MISSING` | The key has no configured Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key lacks the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode |
| 403 | `BITRIX_ACCESS_DENIED` | The pack is built-in or it is the user's own pack |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 did not find the object; the portal code is in `error.b24Code` if supplied |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the Bitrix24 code is in `error.b24Code` |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |

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

## Known specifics

- An author's own pack is in their list from the moment it is created: it cannot be added again (`LINK_EXISTS`) or removed (`BITRIX_ACCESS_DENIED`).
- Removing a pack that is not in the list succeeds without an error.
- Sticker error codes come without a message text: `message` equals the code.

## See also

- [Sticker pack](/docs/chats/stickers/pack)
- [List of packs](/docs/chats/stickers/packs)
- [Stickers](/docs/chats/stickers)
