# Add department member Add a user to a department. Adds an existing organization member to a department. The user must already be a member of the organization. A user cannot be added to the same department twice. #### Path Parameters **`organization_id`** string required The unique identifier of the organization (format: `org_*`). **`department_id`** string required The unique identifier of the department (format: `dept_*`). #### Request Body **`user_id`** string required The ID of the user to add to the department (format: `usr_*`). The user must be a member of the organization. ## Returns The department member object with a `201 Created` status code. Request ```bash cURL curl -X POST https://api.aitronos.com/v1/organizations/org_xyz789/departments/dept_abc123/members \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "user_id": "usr_def456" }' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") # Department endpoints coming to SDK soon # result = client.departments.add_member( # organization_id="org_xyz789", # department_id="dept_abc123", # user_id="usr_def456", # ) ``` ```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}/members" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", } data = {"user_id": "usr_def456"} response = requests.post(url, headers=headers, json=data) member = response.json() print(member) ``` ```javascript JavaScript const orgId = "org_xyz789"; const deptId = "dept_abc123"; const response = await fetch( `https://api.aitronos.com/v1/organizations/${orgId}/departments/${deptId}/members`, { method: "POST", headers: { "Authorization": `Bearer ${accessToken}`, "Content-Type": "application/json", }, body: JSON.stringify({ user_id: "usr_def456" }), } ); const member = await response.json(); console.log(member); ``` Response ```json 201 Created { "user_id": "usr_def456", "full_name": "Jane Smith", "email": "jane@company.com", "added_at": null } ``` ```json 409 Error { "success": false, "error": { "code": "DEPARTMENT_MEMBERSHIP_DUPLICATE", "message": "This user is already a member of the department.", "system_message": "Department membership duplicate", "type": "client_error", "status": 409, "details": { "user_id": "usr_def456", "department_id": "dept_abc123" }, "trace_id": "abc-123-def", "timestamp": "2025-11-02T08:21:45Z" } } ``` ```json 404 Error — Member Not Found { "success": false, "error": { "code": "MEMBER_NOT_FOUND", "message": "The specified user is not a member of this organization.", "system_message": "User is not a member of this organization", "type": "client_error", "status": 404, "details": { "user_id": "usr_invalid" }, "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) - [Delete Department](/docs/api-reference/departments/delete) - [List Department Members](/docs/api-reference/departments/list-members) - [Remove Department Member](/docs/api-reference/departments/remove-member) - [Department Object](/docs/api-reference/objects/department-object)