For AI agents: markdown of this page — /docs-content-en/chats/service/department.md documentation index — /llms.txt
User department
GET /v1/chats/users/:userId/department
Returns the lowest department the user belongs to in the company structure, by user ID or for the key owner.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ParameteruserId (path) |
Typestring | Requiredyes | DescriptionUser ID — a positive integer from the user list, or me for the key owner |
There are no query parameters: any parameter is rejected with 400 INVALID_PARAMS.
Examples
curl — personal key
curl "https://vibecode.bitrix24.com/v1/chats/users/me/department" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl "https://vibecode.bitrix24.com/v1/chats/users/4/department" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/users/me/department', {
headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})
const { data } = await res.json()
console.log('My department:', data.name)
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/users/4/department', {
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { data } = await res.json()
console.log('Department:', data.id, data.name)
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata |
Typeobject | DescriptionThe user's department |
Fielddata.id |
Typenumber | null | DescriptionDepartment ID — a node of the company structure, as in org structure nodes. null — the user is not in any department |
Fielddata.name |
Typestring | null | DescriptionDepartment name |
Response example
{
"success": true,
"data": { "id": 1, "name": "Sales" }
}
Error response example
422 — the user was not found:
{
"success": false,
"error": {
"code": "BITRIX_ERROR",
"message": "USER_NOT_FOUND",
"b24Code": "USER_NOT_FOUND"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionuserId is neither a positive integer nor me, or a query parameter was passed |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no Bitrix24 tokens configured |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key does not have the im scope |
| HTTP422 | CodeBITRIX_ERROR |
DescriptionBitrix24 returned an error, and the Bitrix24 code is in error.b24Code. USER_NOT_FOUND — the user does not exist |
| HTTP502 | CodeME_ALIAS_RESOLUTION_FAILED |
DescriptionFailed to resolve the key owner for me |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionBitrix24 is unavailable or returned a server error |
The full list of common API errors — Errors.