# List departments Retrieve a flat list of all departments within an organization. Returns all departments belonging to the specified organization as a flat array. Each department includes its hierarchical metadata (`parent_id`, `path`, `depth`) so you can reconstruct the tree client-side if needed. #### Path Parameters **`organization_id`** string required The unique identifier of the organization (format: `org_*`). ## Returns An array of department objects. Request ```bash cURL curl https://api.aitronos.com/v1/organizations/org_xyz789/departments \ -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 # result = client.departments.list(organization_id="org_xyz789") ``` ```python Python import requests org_id = "org_xyz789" url = f"https://api.aitronos.com/v1/organizations/{org_id}/departments" headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"} response = requests.get(url, headers=headers) departments = response.json() print(departments) ``` ```javascript JavaScript const orgId = "org_xyz789"; const response = await fetch( `https://api.aitronos.com/v1/organizations/${orgId}/departments`, { headers: { "Authorization": `Bearer ${accessToken}` }, } ); const departments = await response.json(); console.log(departments); ``` Response ```json 200 OK [ { "id": "dept_abc123", "name": "Engineering", "description": "Software development team", "parent_id": null, "path": "/dept_abc123", "depth": 0, "organization_id": "org_xyz789", "member_count": 5, "is_active": true, "is_default": false, "color": null, "created_by": "usr_owner1", "created_at": "2025-01-15T10:00:00Z" }, { "id": "dept_def456", "name": "Backend", "description": "Backend engineering team", "parent_id": "dept_abc123", "path": "/dept_abc123/dept_def456", "depth": 1, "organization_id": "org_xyz789", "member_count": 3, "is_active": true, "is_default": false, "color": null, "created_by": "usr_owner1", "created_at": "2025-01-16T14:30:00Z" } ] ``` ```json 404 Error { "success": false, "error": { "code": "ORGANIZATION_NOT_FOUND", "message": "The requested organization could not be found.", "system_message": "Organization not found", "type": "client_error", "status": 404, "details": { "organization_id": "org_invalid" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ## Related Resources - [Get Department Tree](/docs/api-reference/departments/tree) - [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) - [Delete Department](/docs/api-reference/departments/delete) - [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)