# Assign role member Assign a user to a role within an organization. The user must be an existing member of the organization. #### Path Parameters **`organization_id`** string required Organization ID (org_ prefixed string). **`role_id`** string required Role ID (role_ prefixed string). #### Request Body **`user_id`** string required The ID of the user to assign to this role (usr_ prefixed string). The user must be a member of the organization. ## Returns A role assignment object with the assignment details including `id`, `user_id`, `role_id`, `organization_id`, and `assigned_at`. Request ```bash cURL curl -X POST "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789/members" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"user_id": "usr_target456"}' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") assignment = client.organizations.roles.assign_member( organization_id="org_abc123", role_id="role_xyz789", user_id="usr_target456", ) print(assignment) ``` ```python Python import requests response = requests.post( "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789/members", headers={ "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", }, json={"user_id": "usr_target456"}, ) print(response.json()) ``` ```javascript JavaScript const response = await fetch( "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789/members", { method: "POST", headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", }, body: JSON.stringify({ user_id: "usr_target456" }), } ); const assignment = await response.json(); console.log(assignment); ``` Response ```json 201 Created { "id": "urol_abc123def456", "user_id": "usr_target456", "role_id": "role_xyz789", "organization_id": "org_abc123", "assigned_at": "2026-01-15T10:30:00+00:00" } ``` ```json 409 Conflict { "success": false, "error": { "code": "ROLE_ASSIGNMENT_DUPLICATE", "message": "This user is already assigned to this role.", "system_message": "this user is already assigned to this role.", "type": "client_error", "status": 409, "details": { "user_id": "usr_target456", "role_id": "role_xyz789", "organization_id": "org_abc123" }, "trace_id": "abc-123-def", "timestamp": "2026-01-15T10:30:00Z" } } ``` ```json 404 Not Found { "success": false, "error": { "code": "MEMBER_NOT_FOUND", "message": "The specified user is not a member of this organization.", "system_message": "the specified user is not a member of this organization.", "type": "client_error", "status": 404, "details": { "user_id": "usr_nonexistent" }, "trace_id": "abc-123-def", "timestamp": "2026-01-15T10:30:00Z" } } ``` ## Related Resources - [Retrieve role](/docs/api-reference/organizations/roles/retrieve) - [Create custom role](/docs/api-reference/organizations/roles/create-role) - [List role members](/docs/api-reference/organizations/roles/list-members) - [Remove role member](/docs/api-reference/organizations/roles/remove-member) - [Effective permissions](/docs/api-reference/organizations/roles/effective-permissions)