## Detach from the parent chat

`DELETE /v1/chats/:dialogId/parent`

The chat stops being a child and becomes standalone. Detaching does not remove the members that attaching added to the parent chat. A chat can be detached by whoever has that permission in the chat.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `dialogId` (path) | string | yes | The child chat as `chatN`, for example `chat42` — the `dialogId` field of [recent dialogs](/docs/chats/discovery/recent) |

The endpoint accepts no query parameters and no request body: any parameter or body field is rejected with `400 INVALID_PARAMS` before any call to Bitrix24.

## Examples

### curl — personal key

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

### curl — OAuth application

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

const { success, data } = await res.json()
console.log('Detached:', data.result) // true
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/parent', {
  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 detached |

## Response example

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

## Error response example

422 — the chat has no parent:

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

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | A query parameter or a body field was sent — the endpoint accepts neither — or the body is not a JSON object |
| 403 | `BITRIX_ACCESS_DENIED` | The caller has no permission to detach this chat |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. `CHAT_HAS_NO_PARENT` — the chat has no parent, `CHAT_NOT_FOUND` — the chat does not exist on the portal |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## See also

- [Attach to a parent chat](/docs/chats/management/parent)
- [Chat management](/docs/chats/management)
- [Dialog details](/docs/chats/discovery/get)
