## Unpin a chat

`DELETE /v1/chats/:dialogId/pin`

Unpins a chat in the current user's dialog list: the chat returns to its position according to its last activity time. The chat's messages and members do not change.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `dialogId` (path) | string | yes | Dialog ID: a numeric user ID for a direct dialog, `chatXXX` for a group chat, `me` for the current user's own dialog. Pinned chats are the rows with `pinned: true` in [recent dialogs](/docs/chats/discovery/recent) |

No request body is sent. Any query parameter or body field is rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

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

### curl — OAuth application

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

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat456/pin', {
  method: 'DELETE',
  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.result` | boolean | `true` — the chat is not pinned. A call for a chat that was not pinned also returns `true` |

## Response example

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

## Error response example

400 — a request body was passed:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Body field `folderId` is not accepted by DELETE /v1/chats/:dialogId/pin. It takes no body fields."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | A query parameter or a body field was passed. Checked before the Bitrix24 call |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the Bitrix24 code is in `error.b24Code` |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered "not found"; the Bitrix24 code is in `error.b24Code` |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | The user could not be resolved for the `me` alias |
| 403 | `BITRIX_ACCESS_DENIED` | The user has no access to the chat |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | Read-only key: unpinning is a write, 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 |

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

## Known specifics

**It removes a chat's pin, not a message's.** A message pinned inside a chat is unpinned through a separate path, `DELETE /v1/chats/messages/:messageId/pin`, with the message ID in the path.

**The call may make you a member.** When the chat allows auto-join — for example, a comment chat, a collab or a task chat — the call adds the current user as a member, just as opening the chat in the Bitrix24 interface does.

## See also

- [Pin a chat](/docs/chats/management/pin)
- [Pinned chat order](/docs/chats/management/pin-sort)
- [Recent dialogs](/docs/chats/discovery/recent)
- [Chat management](/docs/chats/management)
