
## Chat folder on Drive

`GET /v1/chats/:chatId/folder`

Returns the identifier of the chat folder in Bitrix24 Drive. Files uploaded to the chat via `POST /v1/chats/:chatId/files` are stored in this folder.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `chatId` (path) | number | yes | Chat ID. Get it: `POST /v1/chats` or `GET /v1/chats/recent` |

## Examples

### curl — personal key

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

### curl — OAuth application

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

const { success, data } = await res.json()
console.log('Folder ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/1001/folder', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
console.log('Folder ID:', data.id)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | ID of the chat folder on Drive |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 9263
  }
}
```

## Error response example

404 — folder not found:

```json
{
  "success": false,
  "error": {
    "code": "FOLDER_NOT_FOUND",
    "message": "Chat disk folder not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `FOLDER_NOT_FOUND` | The chat folder on Drive was not found |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned a NOT_FOUND error — the chat does not exist or is not accessible |
| 422 | `BITRIX_ERROR` | Bitrix24 error while retrieving the folder |
| 403 | `SCOPE_DENIED` | The key lacks the `im` scope |
| 401 | `TOKEN_MISSING` | The key has no configured Bitrix24 tokens |

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

## See also

- [Chat files](/docs/chats/files)
- [Upload a file to a chat](/docs/chats/files/upload)
- [File metadata](/docs/chats/files/file-get)
