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. Deletion is not blocked by child departments or assigned employees: Bitrix24 deletes the department and automatically re-parents its direct child departments onto the deleted department's parent, reassigning their sort (their own subtrees move up together with them). To control the resulting structure, move the child departments and employees manually before deleting.

Parameters

Parameter Type Required Description
id (path) number yes Department ID

Examples

curl — personal key

Terminal
curl -X DELETE "https://vibecode.bitrix24.com/v1/departments/189" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
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

javascript
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

javascript
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:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Department not found"
  }
}

Errors

HTTP Code Description
404 ENTITY_NOT_FOUND Department not found
403 SCOPE_DENIED The API key does not have the department scope
401 TOKEN_MISSING The API key has no configured tokens

Full list of common API errors — Errors.

Known specifics

Deleting a department with children is not forbidden and silently rebuilds the tree. When you DELETE a department that has child departments, Bitrix24 deletes it (204) and re-parents the direct child departments onto the deleted department's parent, reassigning their sort; their own subtrees move up together with them. Assigned employees also do not prevent deletion. To control the resulting structure, before deleting move the child departments via PATCH /v1/departments/:id (a new parentId) and reassign employees via PATCH /v1/users/:id with a new departmentId (array of department IDs).

See also