For AI agents: markdown of this page — /docs-content-en/entities/departments/delete.md documentation index — /llms.txt
Delete a department
DELETE /v1/departments/:id
Deletes a department by ID, even when it has child departments or assigned employees. A deleted department cannot be restored through the API — create a new one if needed.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Parameterid (path) |
Typenumber | Requiredyes | DescriptionDepartment ID. List: GET /v1/departments |
Examples
curl — personal key
curl -X DELETE "https://vibecode.bitrix24.com/v1/departments/189" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl -X DELETE "https://vibecode.bitrix24.com/v1/departments/189" \
-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/departments/189', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
})
if (res.status === 204) {
console.log('Department deleted')
}
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/departments/189', {
method: 'DELETE',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
if (res.status === 204) {
console.log('Deleted')
}
Response
On successful deletion, HTTP status 204 No Content is returned with an empty body — success is confirmed by the status.
Response example
HTTP/1.1 204 No Content
Error response example
404 — department not found:
{
"success": false,
"error": {
"code": "ENTITY_NOT_FOUND",
"message": "Department not found"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionDepartment not found |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionThe API key does not have the department scope |
| HTTP403 | CodeWRITE_BLOCKED_READONLY_KEY |
DescriptionThe key is read-only — see access rights |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionThe API key has no configured tokens |
Full list of common API errors — Errors.
Known specifics
Deletion rebuilds the department tree. The direct child departments move under the deleted department's parent with a new sort, and their own subtrees move up together with them. To control the resulting structure, before deleting, move the child departments via PATCH /v1/departments/:id with a new parentId and reassign employees via PATCH /v1/users/:id with a new departmentId, an array of department IDs.