Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Organizations API

The Organizations API manages organizations, their members, and email invitations. All endpoints require an authenticated session (cookie or Authorization: Bearer …) and are scoped to the current Application via X-App-Id / host context.

Organizations

MethodEndpointDescription
POST/api/organizationsCreate a new organization (caller becomes first admin)
GET/api/organizationsList the caller's organizations (paginated)
GET/api/organizations/:idGet organization details (member-only, 404 otherwise)
PUT/api/organizations/:idUpdate name / slug / logo / metadata (admin-only)
DELETE/api/organizations/:idDelete the organization (admin-only)

Slugs are unique per application, 3–63 chars, ^[a-z](?:[a-z0-9-]*[a-z0-9])?$, no consecutive hyphens.

Members

MethodEndpointDescription
GET/api/organizations/:id/membersList members (any member)
PUT/api/organizations/:id/members/:user_idUpdate a member's role (admin-only)
DELETE/api/organizations/:id/members/:user_idRemove a member (admin-only)

Role-change and remove endpoints return 409 if the action would leave the organization without an admin.

Invitations

MethodEndpointDescription
POST/api/organizations/:id/invitationsCreate an invitation and email it (admin-only)
GET/api/organizations/:id/invitationsList invitations, optionally filtered by status (admin-only)
DELETE/api/organizations/:id/invitations/:invitation_idRevoke a pending invitation (admin-only)
POST/api/organizations/accept-invitationAccept an invitation with the emailed token (auth required)

Invitation tokens are 64 hex characters. The accept endpoint requires the caller's email to match the invitation's email (case-insensitive). Email link target: {appPublicBaseUrl}/accept-org-invite?token=....

Audit Events

Event typeEmitted on
org_createdSuccessful create
org_updatedSuccessful update
org_deletedSuccessful delete
member_role_changedRole updated
member_removedMember removed
org_invitation_sentInvitation created + emailed
org_invitation_revokedInvitation revoked
org_invitation_acceptedInvitation accepted

Active Organization

MethodEndpointDescription
POST/api/organizations/:id/activateSwitch the caller's active organization. Membership-only; re-mints the session JWT with an active_org_id claim and revokes the previous session row. Returns { ok: true, active_org_id, role }.

Returns 404 to non-members and for organizations in other applications (deliberate — avoids cross-tenant probing). The active_org_id claim is a hint surfaced through GET /api/users/me; per-request authorization should still check organization_members so a forged or stale claim can't grant access.

Related