## Add a pack

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

Adds another author's user sticker pack to the current user's list of packs. This is 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 — the `packId` of a sticker from a message, the `data.stickers` field of the [first page of messages](/docs/chats/messages/initial) |
| `packType` (query) | 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 — the same fields as in the [get a pack response](/docs/chats/stickers/pack-get) |
| `data.stickers` | array | Stickers of the pack — the same fields as in the [get a pack response](/docs/chats/stickers/pack-get) |

## 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

403 — the pack is built-in:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ACCESS_DENIED",
    "message": "ACCESS_DENIED",
    "hint": "Bitrix24 refused this call; the cause is not determined.",
    "cause": "unknown",
    "fix": { "action": "none" }
  }
}
```

## 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, a parameter was repeated |
| 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 |

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, and the response is `422` with `error.b24Code` `LINK_EXISTS`.
- Sticker error codes come without a message text: `message` equals the code.

## See also

- [Remove a pack](/docs/chats/stickers/link-delete)
- [Get a pack](/docs/chats/stickers/pack-get)
- [List of packs](/docs/chats/stickers/packs)
