# Delete department Delete a department from an organization. Permanently deletes a department. The department must have no child departments and no members before it can be deleted. Remove all members and child departments first, or reparent children to a different department. #### Path Parameters **`organization_id`** string required The unique identifier of the organization (format: `org_*`). **`department_id`** string required The unique identifier of the department to delete (format: `dept_*`). ## Returns No content. Returns a `204 No Content` status code on success. Request ```bash cURL curl -X DELETE https://api.aitronos.com/v1/organizations/org_xyz789/departments/dept_abc123 \ -H "Authorization: Bearer $ACCESS_TOKEN" ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") # Department endpoints coming to SDK soon # client.departments.delete( # organization_id="org_xyz789", # department_id="dept_abc123", # ) ``` ```python Python import requests org_id = "org_xyz789" dept_id = "dept_abc123" url = f"https://api.aitronos.com/v1/organizations/{org_id}/departments/{dept_id}" headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"} response = requests.delete(url, headers=headers) print(response.status_code) # 204 ``` ```javascript JavaScript const orgId = "org_xyz789"; const deptId = "dept_abc123"; const response = await fetch( `https://api.aitronos.com/v1/organizations/${orgId}/departments/${deptId}`, { method: "DELETE", headers: { "Authorization": `Bearer ${accessToken}` }, } ); console.log(response.status); // 204 ``` Response ```json 204 No Content // No response body ``` ```json 422 Error — Has Children { "success": false, "error": { "code": "DEPARTMENT_HAS_CHILDREN", "message": "This department cannot be deleted because it has child departments. Reparent or remove them first.", "system_message": "Department has children", "type": "client_error", "status": 422, "details": { "department_id": "dept_abc123" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ```json 422 Error — Has Members { "success": false, "error": { "code": "DEPARTMENT_HAS_MEMBERS", "message": "This department cannot be deleted because it still has members. Remove all members first.", "system_message": "Department has members", "type": "client_error", "status": 422, "details": { "department_id": "dept_abc123" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ## Related Resources - [Get Department Tree](/docs/api-reference/departments/tree) - [List Departments](/docs/api-reference/departments/list) - [Retrieve Department](/docs/api-reference/departments/retrieve) - [Create Department](/docs/api-reference/departments/create) - [Update Department](/docs/api-reference/departments/update) - [Reparent Department](/docs/api-reference/departments/reparent) - [List Department Members](/docs/api-reference/departments/list-members) - [Add Department Member](/docs/api-reference/departments/add-member) - [Remove Department Member](/docs/api-reference/departments/remove-member) - [Department Object](/docs/api-reference/objects/department-object)