Organizations API — User Service
API reference for organizations, organization membership and roles, permissions, and role-permission management
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
| Method | Path | Permission | Purpose |
|---|---|---|---|
| GET | /api/v1/organizations/ | org_view | List organizations |
| POST | /api/v1/organizations/ | org_create | Create an organization |
| GET | /api/v1/organizations/{id}/ | org_view | Organization detail with user mappings |
| PATCH, PUT | /api/v1/organizations/{id}/ | org_update | Update an organization |
| DELETE | /api/v1/organizations/{id}/ | org_delete | Delete an organization |
| POST | /api/v1/organizations/{id}/activate/, .../deactivate/ | org_update | Change active state |
| GET | /api/v1/organizations/metrics/ | org_view | Member, role, and project counts |
| GET | /api/v1/organizations/{id}/users/ | org_view | Members and their roles |
| GET | /api/v1/organizations/{id}/roles/ | org_view | Role IDs in use in the organization |
| GET, POST, PUT, PATCH | /api/v1/organizations/user-organization-roles/ | org_manage_users | Read or set a user's organization roles |
| GET | /api/v1/organizations/user-organization-roles/by_user/?user_id= | org_view | Organizations and roles for one user |
| GET | /api/v1/organizations/user-organization-roles/by_organization/?organization_id= | org_view | Users 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_update | Replace a role's permissions |
| GET | /api/v1/access/permissions/ | Authenticated | Permission catalog |
Organizations
Organization object
| Field | Type | Notes |
|---|---|---|
id | UUID | |
name | string | |
description | string | |
is_active | boolean | |
mfa_required | boolean | Members must complete email-code MFA at sign-in. Changing it needs org_manage_security (or superuser). |
logo_url | string | Temporary signed URL; read-only |
logo_file | file | Write-only; send as multipart. null removes the logo. |
created_at, updated_at | datetime | |
created_by, updated_by | UUID |
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/
{"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
{"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
| Parameter | Description |
|---|---|
role | Filter by role ID |
user | Filter by user ID |
search | Matches 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/
{"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
| Parameter | Description |
|---|---|
name | Filter by role name |
organization | Filter by organization ID |
expand=permissions | Embed each role's permissions |
mode=all | Return 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/
{"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:
| Area | Codes |
|---|---|
| Users | user_create, user_view, user_update, user_delete, user_list |
| Organizations | org_create, org_view, org_update, org_delete, org_manage_users, org_manage_roles, org_manage_security |
| Roles | role_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
| Status | Example | Cause |
|---|---|---|
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 |