# Deactivate user Deactivate a user within an organization, preserving their role and department assignments for potential reactivation. Sets the user's status to inactive. Their roles and department memberships are preserved so they can be reactivated later. A target department must be specified for resource transfer. #### Path Parameters **`organization_id`** string required The unique identifier of the organization (format: `org_*`). **`user_id`** string required The unique identifier of the user to deactivate (format: `usr_*`). #### Request Body **`transfer_resources_to_department_id`** string required The ID of the department to transfer the user's resources to (format: `dept_*`). ## Returns The updated user object with `account_state` set to `"deactivated"`. Request ```bash cURL curl -X POST https://api.aitronos.com/v1/organizations/org_xyz789/users/usr_abc123/deactivate \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "transfer_resources_to_department_id": "dept_eng001" }' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") # Users V2 endpoints coming to SDK soon # result = client.users.deactivate( # organization_id="org_xyz789", # user_id="usr_abc123", # transfer_resources_to_department_id="dept_eng001", # ) ``` ```python Python import requests org_id = "org_xyz789" user_id = "usr_abc123" url = f"https://api.aitronos.com/v1/organizations/{org_id}/users/{user_id}/deactivate" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", } data = { "transfer_resources_to_department_id": "dept_eng001", } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` ```javascript JavaScript const orgId = "org_xyz789"; const userId = "usr_abc123"; const response = await fetch( `https://api.aitronos.com/v1/organizations/${orgId}/users/${userId}/deactivate`, { method: "POST", headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", }, body: JSON.stringify({ transfer_resources_to_department_id: "dept_eng001", }), } ); const data = await response.json(); console.log(data); ``` Response ```json 200 OK { "id": "usr_abc123", "full_name": "Jane Doe", "email": "jane@example.com", "user_name": "janedoe", "account_state": "deactivated", "role_ids": ["role_admin1"], "department_ids": ["dept_eng001"], "organization_id": "org_xyz789", "invitation_link": null, "invited_at": null, "deactivated_at": null } ``` ```json 422 Validation Error { "success": false, "error": { "code": "USER_ALREADY_DEACTIVATED", "message": "This user account has already been deactivated.", "system_message": "this user account has already been deactivated.", "type": "client_error", "status": 422, "details": { "user_id": "usr_abc123" }, "trace_id": "abc-123-def", "timestamp": "2025-12-22T15:30:00Z" } } ``` ## Related Resources - [Invite user (v2)](/docs/api-reference/users/invite-v2) - [Update memberships](/docs/api-reference/users/update-memberships) - [Reactivate user](/docs/api-reference/users/reactivate) - [Remove user](/docs/api-reference/users/remove)