## List knowledge base menu bindings

`GET /v1/sites/menu-bindings`

Returns knowledge base bindings to Bitrix24 account menu items, either all at once or for a single menu code.

Site type restrictions and how a binding changes the employees' menu are covered in [Knowledge base menu bindings](/docs/entities/sites/menu-bindings).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `menuCode` (query) | string | no | Menu code, for example `crm_switcher:lead`. Encode the colon in the URL as `%3A`. An empty value returns `400 INVALID_PARAMS`. Without the parameter, bindings to all menus are returned |
| `scope` (query) | string | no | Site scope: `KNOWLEDGE`, `GROUP` or `MAINPAGE`. Any other value returns `400 INVALID_SCOPE` |

There is no pagination: the response contains all bindings matching the filter in a single array. The `limit` and `offset` parameters are not processed.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/sites/menu-bindings?menuCode=crm_switcher%3Alead" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/sites/menu-bindings?menuCode=crm_switcher%3Alead" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const params = new URLSearchParams({ menuCode: 'crm_switcher:lead' })
const res = await fetch(`https://vibecode.bitrix24.com/v1/sites/menu-bindings?${params}`, {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log(`Bindings: ${data.length}`)
```

### JavaScript — OAuth application

```javascript
const params = new URLSearchParams({ menuCode: 'crm_switcher:lead' })
const res = await fetch(`https://vibecode.bitrix24.com/v1/sites/menu-bindings?${params}`, {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of bindings. Empty array if no bindings match the filter |
| `data[].siteId` | number | Knowledge base site ID. Get the site: `GET /v1/sites/:id?scope=KNOWLEDGE` |
| `data[].menuCode` | string | Code of the menu the site is bound to |
| `data[].title` | string | Site title. Empty string if the title was not returned |
| `data[].publicUrl` | string | Public URL of the knowledge base site. Empty string if the URL was not returned |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "siteId": 61,
      "menuCode": "crm_switcher:lead",
      "title": "Knowledge base",
      "publicUrl": "https://example.bitrix24.com/knowledge/knowledge_base/"
    },
    {
      "siteId": 131,
      "menuCode": "crm_switcher:lead",
      "title": "Support knowledge base",
      "publicUrl": "https://example.bitrix24.com/knowledge/support_knowledge_base/"
    }
  ]
}
```

## Error response example

400 — empty `menuCode` value:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "menuCode must be a non-empty string"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `menuCode` is empty or whitespace only |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned the bindings list in an unexpected format |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access to the key owner |
| 403 | `B24_TARIFF_RESTRICTION` | The portal plan does not allow the call |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 429 | `RATE_LIMITED` | Bitrix24 throttled requests to the portal. Retry after the period from the `Retry-After` header |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 returned a server error or the connection dropped before the full response. The request only reads data, so a retry is safe |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time. The request only reads data, so a retry is safe |

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

## Known specifics

**One menu code, several sites.** Several knowledge bases can be bound to one menu, and each binding comes as a separate array element with the same `menuCode`. One site can also be bound to several menus.

**The list contains only site bindings.** Bindings of individual knowledge base pages to a menu are not included in the response, so `siteId` always points to a site, not a page.

## See also

- [Knowledge base menu bindings](/docs/entities/sites/menu-bindings)
- [Bind a knowledge base to a menu](/docs/entities/sites/menu-bindings/bind)
- [Unbind a knowledge base from a menu](/docs/entities/sites/menu-bindings/unbind)
- [Knowledge base workgroup bindings](/docs/entities/sites/group-binding)
- [List sites](/docs/entities/sites/list)
- [Errors](/docs/errors)
