## Unbind a knowledge base from a menu

`DELETE /v1/sites/:id/menu-bindings/:menuCode`

Removes the binding of a knowledge base site to a Bitrix24 menu by menu code, and that menu changes for all employees of the Bitrix24 account.

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

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Knowledge base site ID. List: `GET /v1/sites?scope=KNOWLEDGE` |
| `menuCode` (path) | string | yes | Code of the menu the site is unbound from. Encode the colon as `%3A`: `crm_switcher%3Alead`. Site bindings and their codes: `GET /v1/sites/menu-bindings` |
| `scope` (query) | string | no | Site scope: `KNOWLEDGE`, `GROUP` or `MAINPAGE`. A knowledge base site is found even without the parameter |

No request body is sent.

## Examples

### curl — personal key

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

### curl — OAuth application

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

### JavaScript — personal key

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

const { success, data } = await res.json()
console.log(success && data.length === 0 ? 'Binding removed' : data)
```

### JavaScript — OAuth application

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

const { success, data } = await res.json()
console.log(success && data.length === 0 ? 'Binding removed' : data)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Bindings of this site to the removed menu code, read back after removal. Empty array after a successful removal |
| `data[].siteId` | number | Site ID |
| `data[].menuCode` | string | Menu code |
| `data[].title` | string | Site title |
| `data[].publicUrl` | string | Public URL of the site |

## Response example

```json
{
  "success": true,
  "data": []
}
```

## Error response example

404 — site not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Site not found or not visible"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `menuCode` in the path is whitespace only |
| 400 | `INVALID_PARAMS` | `id` in the path is not a positive integer |
| 400 | `INVALID_PARAMS` | A non-empty body was sent — message `DELETE takes no body` |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 404 | `ENTITY_NOT_FOUND` | No site with this `id` was found among knowledge bases, workgroup sites and sites of the `scope` — message `Site not found or not visible` |
| 409 | `SITE_BINDING_TYPE_MISMATCH` | The site is not a knowledge base: a regular site or a site bound to a workgroup |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on the portal. Ask the portal administrator to enable it — while the module is off, a retry returns the same rejection |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the removal. A repeated removal of an already removed binding gets the same response. `message` lists possible causes: the site is unavailable, not a knowledge base, no write permission, no binding exists |
| 422 | `BITRIX_ERROR` | The binding was removed, but 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 |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode, the request does not reach Bitrix24 |
| 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 operation may have succeeded — read the bindings back before retrying |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time. The operation may have succeeded — read the bindings back before retrying |

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

## Known specifics

**A repeated removal is indistinguishable by the response.** To find out after a `422` rejection whether the binding has been removed, call `GET /v1/sites/menu-bindings?menuCode=crm_switcher%3Alead` and check whether the response contains this site.

## See also

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