Sign in

Organizations API — User Service

API reference for organizations, organization membership and roles, permissions, and role-permission management

user
apiuserorganizationsrolespermissionsrbacmembersmfa

Updated 2026-11-03

Verified 2026-11-03

User Service endpoints for organizations, organization membership, roles, and permissions. For architecture and configuration, see User Service. Project-level membership and roles are covered in Projects API.

All endpoints require Authorization: Bearer YOUR_TOKEN. Non-superusers must also send X-Org-Id, and their requests are scoped to that organization. Lists use page-number pagination (page, page_size; default 10, max 100) unless noted. See API Conventions.

Endpoint Summary

MethodPathPermissionPurpose
GET/api/v1/organizations/org_viewList organizations
POST/api/v1/organizations/org_createCreate an organization
GET/api/v1/organizations/{id}/org_viewOrganization detail with user mappings
PATCH, PUT/api/v1/organizations/{id}/org_updateUpdate an organization
DELETE/api/v1/organizations/{id}/org_deleteDelete an organization
POST/api/v1/organizations/{id}/activate/, .../deactivate/org_updateChange active state
GET/api/v1/organizations/metrics/org_viewMember, role, and project counts
GET/api/v1/organizations/{id}/users/org_viewMembers and their roles
GET/api/v1/organizations/{id}/roles/org_viewRole IDs in use in the organization
GET, POST, PUT, PATCH/api/v1/organizations/user-organization-roles/org_manage_usersRead or set a user's organization roles
GET/api/v1/organizations/user-organization-roles/by_user/?user_id=org_viewOrganizations and roles for one user
GET/api/v1/organizations/user-organization-roles/by_organization/?organization_id=org_viewUsers and roles for one organization
GET, POST, PUT, PATCH, DELETE/api/v1/access/roles/role_*Organization roles
PUT/api/v1/access/roles/{id}/permissions/role_updateReplace a role's permissions
GET/api/v1/access/permissions/AuthenticatedPermission catalog

Organizations

Organization object

FieldTypeNotes
idUUID
namestring
descriptionstring
is_activeboolean
mfa_requiredbooleanMembers must complete email-code MFA at sign-in. Changing it needs org_manage_security (or superuser).
logo_urlstringTemporary signed URL; read-only
logo_filefileWrite-only; send as multipart. null removes the logo.
created_at, updated_atdatetime
created_by, updated_byUUID

Detail responses also include user_mappings.

List organizations

GET /api/v1/organizations/?search=acme&is_active=true

Filters: name, is_active. Search (search) matches name and description. Superusers see all organizations; other users see only the organization in X-Org-Id.

Create organization

POST /api/v1/organizations/
json
{"name": "Acme", "description": "Acme Corp tenant", "mfa_required": false}

Returns 201 with the organization object. The creator is added with the Guest organization role. No project is created automatically; create projects through the Projects API.

Update organization

PATCH /api/v1/organizations/{id}/

Send JSON for field changes, or multipart/form-data to upload logo_file. Setting mfa_required without org_manage_security returns 403.

Activate or deactivate

POST /api/v1/organizations/{id}/activate/
POST /api/v1/organizations/{id}/deactivate/

Response 200: {"message": "Organization activated successfully"} (or deactivated).

Organization metrics

GET /api/v1/organizations/metrics/
X-Org-Id: YOUR_ORG_ID
json
{"total_members": 42, "total_roles": 6, "total_projects": 5}

X-Org-Id is required. The counts are always organization-wide; X-Project-Id has no effect.

Membership

List members

GET /api/v1/organizations/{id}/users/?search=jane&role=3
ParameterDescription
roleFilter by role ID
userFilter by user ID
searchMatches email, first name, last name, and role name

Returns a paginated list of user-organization-role mappings (one row per role assignment).

Set a user's roles

POST, PUT, and PATCH on user-organization-roles/ all take the same body and set the complete role list for one user in one organization:

PUT /api/v1/organizations/user-organization-roles/
json
{"user": "USER_UUID", "organization": "YOUR_ORG_ID", "roles": [3, 5]}

POST returns 201; PUT and PATCH return 200. GET on the same path returns a paginated list grouped by user. DELETE /api/v1/organizations/user-organization-roles/{mapping_id}/ removes a single role assignment; removing the last one removes the user from the organization.

Default organization roles

Each organization has four default roles: Admin, Contributor, Reader, and Guest. Default roles cannot be edited. Organizations can add custom roles through the roles API.

Roles

Roles live under the Access API.

GET /api/v1/access/roles/?organization=YOUR_ORG_ID&expand=permissions
ParameterDescription
nameFilter by role name
organizationFilter by organization ID
expand=permissionsEmbed each role's permissions
mode=allReturn every matching role without pagination (requires organization)

Create a custom role with POST /api/v1/access/roles/ and {"name", "description", "organization", "permissions": [ids]}. Role objects include is_default.

Replace role permissions

PUT /api/v1/access/roles/{id}/permissions/
json
{"permissions": [12, 15, 31]}

The list replaces the role's permissions. The response is the role (add ?expand=permissions to embed them) plus a change_summary with added, removed, and final. Default roles return 400.

Permissions

GET /api/v1/access/permissions/?search=org_&mode=all

Returns the permission catalog (id, name, code, description). Filter with name or code; search matches name, code, and description; mode=all returns the full list without pagination. Only superusers can create or change permissions.

Permissions are defined in permissions_config.yaml (188 codes). Organization-level codes include:

AreaCodes
Usersuser_create, user_view, user_update, user_delete, user_list
Organizationsorg_create, org_view, org_update, org_delete, org_manage_users, org_manage_roles, org_manage_security
Rolesrole_create, role_view, role_update, role_delete

Other codes cover platform resources such as agents, tools, apps, knowledge bases, observability, and projects. Use the catalog endpoint for the current list.

Errors

StatusExampleCause
400{"name": ["This field is required."]}Validation error
400{"error": "user_id is required"}Missing query parameter on by_user or by_organization
403{"detail": "You do not have permission to perform this action."}Missing permission, or X-Org-Id does not match the caller's membership
404{"detail": "Not found."}Organization outside the caller's scope