SCIM provisioning API
The gateway exposes a SCIM 2.0 inbound endpoint at /scim/v2/ so an identity provider (e.g. Microsoft Entra ID) can automatically provision, update, deactivate and group a tenant's users. It pairs with OIDC SSO: SSO authenticates, SCIM provisions.
SCIM is configured per tenant. A tenant admin generates the bearer token under the tenant settings (see Tenants and gateways → SCIM credential); the IdP is given the base URL and that token. The base URL is the full HTTPS URL shown in the SCIM provisioning panel, served on the admin-API host (for example
https://ai-api-admin.myra.eu/scim/v2) — the split-host admin-API origin, not theai.myra.euapplication host. Use it exactly as displayed rather than hand-constructing it.
Authentication
Every /scim/v2/ request carries Authorization: Bearer <token> — exactly that shape: the scheme Bearer (case-insensitive), one space, then the token (no whitespace or control characters, at most 4096 bytes). A header without the Bearer prefix, with another scheme, with extra or different whitespace, or sent more than once is rejected 401 with WWW-Authenticate: Bearer before any lookup. The token is hashed (SHA-256) and matched to a tenant; the tenant is derived entirely from the token, never from the request payload, so one tenant's credential can only ever touch its own users and groups. A missing or unknown token returns 401. A storage fault while resolving the token is not a bad credential: it returns 503 with Retry-After: 10 (never a 401, which an IdP would treat as a revoked credential and stop retrying). We store only the hash — the plaintext is shown once at generation.
Suspended tenants. With the tenancy switch on, every /scim/v2/ request of a tenant that the partner portal has suspended is answered 403 with the detail tenant_suspended — reads and discovery included, after the token has resolved. If the suspension state cannot be read, the answer is 503 with Retry-After: 10. Resuming the tenant lifts the refusal. See Partner tenancy API. (tests: tests/unit/test_map4135_scim.lua)
Discovery
| Method | Path | Description |
|---|---|---|
GET |
/scim/v2/ServiceProviderConfig |
Capabilities — patch and filter supported; bulk, sort, etag, changePassword not. |
GET |
/scim/v2/ResourceTypes |
User and Group (with the enterprise-user extension). |
GET |
/scim/v2/Schemas |
Core User, Group, and enterprise-user schemas. Each schema resource carries the RFC 7643 §7 schemas envelope and a description on every attribute definition, so an IdP conformance fetch does not abort on the missing fields. |
Users
Every SCIM 503 answer — on any resource — carries Retry-After: 10, so an IdP provisioning service retries it instead of quarantining the job.
Seat limit. When the tenant has a seat limit (an enterprise contract with a fixed number of seats, or a plan with a seat allowance), SCIM provisioning counts against it exactly like an administrator's invitation: creating an active user, or reactivating a deactivated one (active:true via PATCH/PUT, or the leave-and-return re-POST of a deactivated externalId), is refused at the limit with 403 and the detail Seat limit reached for this tenant — nothing is created or reactivated. While a seat reduction is scheduled below an existing seat limit, the scheduled count is the limit and the detail ends with (a seat reduction to N seats is scheduled); while the reduction of a mixed plan change is pending (not scheduled yet, or being applied late), its count is the limit and the detail ends with (a seat reduction to N seats is pending); a schedule never imposes a limit on a tenant without one. Free a seat (deprovision a user with active:false, or delete one — an administrator-disabled user still occupies a seat) or have the limit raised, then retry. Creating a user with active:false takes no seat and is never refused, and an already-active user is never refused. The count and the write run in one transaction under a tenant lock, so a burst of parallel provisioning cannot overshoot the limit. If the seat limit cannot be read (a database fault), the answer is 503 with Retry-After: 10 and nothing is provisioned. Tenants without a seat limit are unaffected.
Refusals are visible to administrators. The IdP still receives the 403. In addition, the tenant's administrators see one in-app Seats alert that lists the refused users (up to 50, newest first; entries expire after 7 days), and receive one email per tenant per day while refusals occur. Raising the limit and letting the IdP push again provisions the users and clears the list. A refused identity is keyed by x:<externalId> when the request carried a non-blank externalId, otherwise by e:<lower-cased email>; a later successful create or reactivation clears both candidate keys of that identity (for a PATCH/PUT reactivation, both the stored and the newly supplied identity). The list holds at most about 1000 identities per tenant (further new identities are not stored; the 403 is unchanged). A new refused identity writes one scim.seat_limit_refused audit entry (actor type system, tenant entity, cap and scheduled count only — no identity data, and repeat refusals of the same identity add no further entries). The email never contains a refused identity, and a failed write of the list, the audit entry or the email never changes the 403 the IdP receives.
| Method | Path | Description |
|---|---|---|
POST |
/scim/v2/Users |
Create. A new user starts with the tenant's default_role (member unless an administrator changed it; see New users); an existing user's role is never changed. If the stored default cannot be read the request answers 503 Retry-After rather than guessing a role. userName is required and non-blank — a present but blank userName is 400 invalidValue regardless of emails[]; only when the key is absent is the primary emails[].value (or failing one the first non-blank emails[].value) accepted in its place; a blank or null externalId is treated as absent, a non-string one is 400 invalidValue. A new user's address (the resolved userName, or the emails[].value that stands in for it) must be a valid e-mail address (local@domain.tld: a single @, a dotted domain, no whitespace, 3–254 bytes, printable ASCII only — a non-ASCII character such as jörg@firma.de, a no-break space or BOM, invalid UTF-8 or a control byte is refused because that account could never sign in) — otherwise 400 invalidValue (userName must be an email address) and nothing is created. A malformed userName is refused with 400 invalidValue before the duplicate check, so it never answers 409 uniqueness. A duplicate externalId of a deactivated user reactivates it (the leave-and-return path); a duplicate of a live user returns 409 uniqueness. Rate-limited per token → 429 + Retry-After (see Global email namespace and provisioning rate limit). |
GET |
/scim/v2/Users?filter=userName eq "…" |
The reconcile/match query (userName or externalId, eq only). An empty match is a 200 ListResponse with Resources: [] — never 404. A blank match value (empty, whitespace or format-only), one that is not valid UTF-8, or a filter parameter that is bare or repeated is refused with 400 invalidFilter — never the unfiltered list. externalId matching is byte-exact (case, accents, width and trailing spaces all distinguish values); userName matching is unchanged. |
GET |
/scim/v2/Users?startIndex=1&count=100 |
Paginated list of the tenant's active users. count defaults to 100 and is capped at 200. startIndex and count must be integers of at most 9 digits; a negative value is clamped per RFC 7644 §3.4.2.4 (startIndex < 1 → 1, count < 0 → 0), while a non-integer, empty (?startIndex=, ?count=) or over-long value is 400 invalidValue — also when a filter is given. A failed read (of the count or of the page) answers 503 with Retry-After: 10 — never an empty or partial 200 an IdP would reconcile as "these users are gone". |
GET |
/scim/v2/Users/{id} |
Read one. |
PATCH |
/scim/v2/Users/{id} |
PatchOp. active:false → deprovision (below); active:true → reactivate; attribute replace. active is accepted as a bool or the string "False"/"True", path-form or pathless, op names case-insensitive; paths may be bare (active) or fully qualified (urn:ietf:params:scim:schemas:core:2.0:User:active). Only active, userName, displayName and the enterprise department, costCenter and manager are honoured — an op addressing any other attribute (e.g. externalId, or name.givenName / name.familyName — see User name) is ignored. The PatchOp shape is validated first: Operations must be a JSON array of objects whose op is add, replace or remove — anything else — including an empty Operations list — is 400 invalidSyntax (on /Groups too), never a silent no-op. Operation keys are exactly op / path / value, matched case-insensitively ("Value": false deprovisions); any other key, or one given twice in different case, is 400 invalidSyntax. Also refused before anything is applied — never a silent 200: a path that is present but not a string (a number, object, boolean or array; null / "" are pathless) → 400 invalidPath; a pathed add / replace of active without a value or with null, a remove of active or of displayName, an add / replace of displayName whose value is not a string (incl. null), a pathless add / replace whose value is missing, null, a scalar, an array or an empty object, or a pathless value naming an attribute twice in different case (active + Active), or a pathless value whose displayName is not a string (incl. null) → 400 invalidValue; a remove without a path (absent, null or "") → 400 invalidPath. An enterprise department change (see Department → group mapping) remaps the user's derived group. It also sets the user's Department (Department assignment); a malformed department is 400 invalidValue. |
PUT |
/scim/v2/Users/{id} |
Full replace of attributes + active. userName is required and non-blank (RFC 7643): the same rule as POST — a present userName that is not a string or has no visible character (empty, whitespace, control or format code points such as NBSP, zero-width space or a BOM) returns 400 invalidValue and changes nothing; only when the key is absent is the primary (else first non-blank) emails[].value accepted in its place, and a body with neither is 400 invalidValue. A PATCH op that addresses userName with a blank or non-string value, with no value, or that removes it, is refused the same way (never a silent no-op). A request carrying both a rename and active:false applies the rename first, then deactivates; if the new address collides (409), the deactivation still lands — a revoke is never blocked by an unrelated attribute conflict — while a transient fault on the rename (503) applies nothing. A request that is refused as invalid (400 — a malformed PatchOp, a blank or over-long identity value) applies nothing either, including its deactivation (the one exception is a malformed enterprise costCenter, which never blocks a deprovisioning — see Cost centre): fix the payload and resend, so the retry re-applies both (a transient fault on the deactivation after a successful rename leaves the rename in place; the retry converges). A request carrying active:true and a userName on a deactivated user reactivates atomically under that address: a collision is a 409 with the user still deactivated (never live under a stale address), and a returning user whose old address has since been taken by someone else comes back under the new one. An absent department clears the derived group membership and any Department the identity provider assigned (Department assignment); a malformed one is 400 invalidValue. externalId is not updated by PUT (and is therefore not validated there). |
DELETE |
/scim/v2/Users/{id} |
Deprovision (same as active:false); the user is kept, so a later GET /Users/{id} answers 200 with active:false, not 404 — see Deleted users. Idempotent — an unknown/already-deprovisioned id returns 204, never 404, so a retried delete is safe. A deadlock with a concurrent write is retried by the server (up to 4 attempts); a storage fault that persists answers 503 (nothing revoked — retry), never a 500, and the driver's error text is never returned. |
User name (name.*)
A gateway user has one display name. The SCIM name complex attribute is not stored as such — this is an intentional deviation, not a defect:
- On
PATCH,displayNameis the only name input. APATCHsets the name only throughdisplayName; an operation onnameor any of its sub-attributes (name.givenName,name.familyName,name.formatted, …) is ignored and the request still answers200with the unchanged user. OnPOST/PUT(a full resource) the name isname.formattedwhen that is a string, otherwisedisplayName. name.givenName/name.familyNameare never stored, on any method. A read returns the stored name asname.formattedonly, andGET /Schemasdoes not advertisename.- Why: Microsoft Entra ID sends
displayNamealongside the name parts in its default attribute mapping, so the visible name stays in sync without a second copy of it. A conformance client that patchesname.givenNameand reads it back (the Entra-flavour check Update persisted) therefore reports a difference; the gateway's own conformance run marks that check aswarn(expected), not as a failure.
Deleted users (DELETE)
DELETE /Users/{id} deprovisions the user — the same as active:false, with the full deprovisioning contract — and keeps the account. This is an intentional deviation from RFC 7644 §3.6, which says a deleted resource then answers 404:
GET /Users/{id}answers200with the user andactive:false(never404).- The
userName/externalIdfilters and the paginated list return live users only, so the deleted user is not matched or listed. - A returning user is reactivated, not duplicated. A later
POSTwith the sameexternalId, oractive:true, brings back the same account (the leave-and-return path above); a hard delete would lose that link. - Why: Microsoft Entra ID first deprovisions with
active:falseand sendsDELETEonly after its recycle-bin period, so deprovisioning onDELETEmatches real Entra sync. A conformance client that expects404afterDELETE(the Entra-flavour check Deleted user is 404) therefore reports a difference; the gateway's own conformance run marks that check aswarn(expected), not as a failure.
Groups
| Method | Path | Description |
|---|---|---|
POST |
/scim/v2/Groups |
Create a group bound to the IdP group id (externalId; blank or null → the group is bound under its displayName, a non-string is 400 invalidValue). displayName is required and non-blank (a PATCH rename to a blank or non-string value, or a remove of it, is refused the same way — and a PATCH is validated as a whole before any of its operations is applied). Works on a tenant with no SSO configuration (a SAML-only tenant needs no OIDC setup); the binding is keyed by tenant and IdP group id. Idempotent on the IdP group id. |
GET |
/scim/v2/Groups / ?filter=displayName eq "…" |
List / match (displayName, eq only, compared exactly and with no limit on the number of groups; the same filter grammar as Users, so \" and \\ escapes work and a blank match value is refused with 400 invalidFilter). startIndex and count follow the same rules as for Users (integers of at most 9 digits, negatives clamped, malformed or empty → 400 invalidValue). |
GET |
/scim/v2/Groups/{id} |
Read one (with members). |
PATCH |
/scim/v2/Groups/{id} |
Add / remove / replace members (both the value-list and the members[value eq "id"] value-path forms), and rename displayName. A pathless add / replace whose value is an attribute object ({"displayName": …, "members": [...]}; id, schemas, externalId, meta are ignored) is applied like the pathed operations; a pathless add whose value is a members array adds them. Paths and filter operators are matched case-insensitively (Members[value EQ "id"], a schema-qualified urn:ietf:params:scim:schemas:core:2.0:Group:members). Refused before anything is applied — never a silent 200: an unsupported path (e.g. externalId, a value-path on add / replace, a value-path that does not parse) or a pathless remove / unsupported attribute → 400 invalidPath; a path that is not a string (null / "" are pathless) → 400 invalidPath; a pathless replace whose value is not an attribute object, or a pathless add / replace without a value → 400 invalidPath; a pathless add / replace whose attribute object is empty or carries only ignored attributes (id, schemas, externalId, meta) → 400 invalidValue; a pathed add / replace without a value, a remove whose value is an explicit null, a value-path remove that also carries a value, a malformed members value (incl. a pathless add with a scalar value) or an attribute repeated in another case — also inside a member element ({"value": …, "VALUE": …}; member attribute names are case-insensitive, so {"Value": "id"} is the member id) → 400 invalidValue; an unsupported op (anything but add / remove / replace) or an operation key other than op / path / value (all three matched case-insensitively, incl. OP / Op; a misspelt values is never read as "no value"), or one of them given twice in different case → 400 invalidSyntax. The same folding applies to /Users PATCH (a deprovision sent as "Value": false or a pathless {"Active": false} deactivates; a replace of active without a value is 400 invalidValue). On POST, attribute names are matched case-insensitively too (DisplayName, Members); an attribute given twice in different case is 400 invalidValue. A remove of members without a value clears the SCIM members (RFC 7644). |
DELETE |
/scim/v2/Groups/{id} |
Unlink — removes the IdP binding and the SCIM-sourced memberships only. The local group, its manually-added members, and its project grants are kept (a cascade-delete would silently strip other users' access). Idempotent — an unknown/already-unlinked id returns 204, never 404. |
Group read faults. If the group list, the group itself or its member list cannot be read, every
/Groups read (list, displayName filter, read-one, and the group returned after a create / PATCH)
answers 503 with Retry-After: 10 and the SCIM error body — never an empty Resources list (on
which an IdP would create a duplicate group) and never a group with members: [] (which an IdP would
reconcile by re-adding every member). Retry the request.
Group → role. A group can be mapped to a role (role_id on PATCH /admin/v1/groups/{id}). A SCIM member add / remove / replace / clear, a DELETE (unlink), a SAML group-claim sync and a deprovision re-derive the role of the affected users in the same transaction: the highest mapped base role (tenant_admin, ki_manager) applies — also lowering a manually set role — and a user who leaves every mapped group becomes member; a custom role adds its permissions on the next request. A platform admin is never changed, only users of the tenant that owns the config are affected, and a change that would remove the tenant's last admin is refused softly (role kept, audited as user.role_group_sync_refused; the SCIM request still succeeds). Deprovisioning a user resets a group-derived role to member, so a reactivated user does not regain it. An OIDC group-claim sync (oidc_claim memberships) re-derives roles the same way as the SAML sync. Whoever controls the IdP group mapped to tenant_admin controls who is tenant administrator.
Project ownership. A PATCH member remove / replace / clear or a DELETE (unlink) that would leave a project owned only through this group without an effective owner hands the project to a live admin of the project's tenant (one project.owner_handed_over audit row per project, actor type system; the request still succeeds). With no live tenant admin the project is kept ownerless, a warning is logged and a project_without_owner alert fires. The same applies to the department sync below. A lock wait or a persisting deadlock answers 503 with Retry-After and writes nothing; any other storage fault answers 500 with nothing written. A fault that strikes while the transaction is committing is the exception: it answers 503 rather than 500 (the outcome of that commit is unknown, and a retry is safe because the /Groups writes are idempotent). The hand-over also covers projects in the trash (a trashed project is handed over too), while the admin-route refusal covers live projects only. An OIDC group-claim sync follows the same hand-over rule.
Group write faults. Every /Groups write is idempotent — create keys on the IdP group id, member
add is a no-op for an existing member, remove / replace / clear converge, a rename sets a value,
and unlink removes nothing the second time — so re-sending a request can never double-apply, whatever
part of it landed. A transient storage fault on any of them (no database connection, a connection
lost mid-statement, a deadlock or lock-wait timeout — while creating the group or its initial members, a
PATCH member add / remove / replace / clear or rename, DELETE) therefore answers 503 with
Retry-After: 10 — never a 200 / 201 the IdP would not retry (a failed member remove answered
as success would leave a departed user with the group's project access). The group returned after a
successful create / PATCH is re-read; if that read fails the answer is the same 503, and the retry
converges. A write the database rejects deterministically (one that would fail the same way on every
retry) answers the SCIM 500 with the request id instead — never a 503 the IdP would retry forever;
the database's own text is only logged. A displayName
another group of the tenant already holds (a group created in the admin UI, or a second IdP group with
the same name, or a group the IdP itself provisioned earlier and then unlinked with DELETE — the
local group survives an unlink under its name) is not a fault: create and rename answer 409 with
scimType: "uniqueness". Resolve it by renaming (or deleting) the existing group in the admin UI, then
let the IdP retry. A concurrent re-send of the same create (same externalId) is not a conflict: it
answers with the group the first request created. A PATCH is applied operation by operation, and each member add / remove operation is one batched transaction however many members it names (a large initial sync is not one statement per member): a rename
refused with 409 leaves the operations listed before it applied (they are idempotent — re-sending the
PATCH without the rename converges) and the ones after it unapplied. An
over-long initial members list is refused (400 tooLarge) before the group is created. A members value
that is present but not an array of { "value": "<user id>" } objects (a string, an object, an element
without a string value) — on create or on a PATCH members operation — is refused 400
invalidValue before anything is applied; it is never read as "no members" (on create, members: null or an absent members is). (This
retry-safe 503 after a possibly-landed write is specific to these idempotent SCIM writes; the admin
API's general rule is in Storage faults.)
Provisioning status and sync log
Two admin-API reads (not SCIM endpoints) feed the tenant's SCIM provisioning card. Both are tenant-fenced: another tenant's id answers 404; a caller in the tenant without the permission answers 403.
GET /admin/v1/tenants/{id}/scim-status (SSO_MANAGE; takes no query parameters, any parameter → 400 bad_param):
{ "tenant": "…", "state": "syncing", "last_activity_at": 1760000000, "last_activity_at_ms": 1760000000123, "users": 1004, "groups": 52 }
last_activity_atis the newest successful provisioning change (user provision, update, deprovision, reactivate, email or department change, group create, rename, membership change or unlink). Refused attempts (seat limit, held or refused deprovision, denied email change) and the IdP's read-only polls do not move it. Unix seconds, ornull.state:never(no such change yet),syncing(last change within 3600 s),idle(older).userscounts active users provisioned through SCIM, with or without anexternalId;groupscounts SCIM-linked groups.- A storage fault answers
503, never zeros ornever.
GET /admin/v1/tenants/{id}/scim-sync-log (SSO_MANAGE and TENANT_AUDIT_VIEW) returns the tenant's scim.* audit rows, newest first, in the same shape as the tenant audit log (items, next_cursor, chain, where chain.sealed_through_ms is tenant-wide, not limited to scim.* rows) including its staff-privacy rules. Accepted parameters: limit, cursor, from_ms, to_ms. Any other parameter (action, entity_type, action_prefix, unknown keys), a repeated or malformed one → 400. Refusal rows do appear here. A storage fault → 503.
The deprovisioning contract
Deactivating a user (PATCH active:false or DELETE) runs one atomic transaction that completely removes the user's access — not just their group membership:
- revokes every access surface: group memberships, direct project memberships, agent shares received and granted, the group-shares of the user's own agents, public conversation share links, third-party MCP connector credentials, and personal API tokens (revoked, so a subsequent
/v1call gets a typedtoken_revoked401, not a generic error, and the auth cache is dropped so none survive even briefly); - removes the user's agents from the org catalog and disables their scheduled runs (those not handed over below);
- reassigns any project the user solely owned to a live tenant-admin successor (one
project.owner_handed_overaudit row each, actor typesystem; with no live admin the project is kept ownerless, a warning is logged and aproject_without_owneralert fires after the commit; a lock wait answers503after one lock-wait timeout and writes nothing; a deadlock is retried, and one that persists answers503) (live means neither deleted nor disabled; a disabled admin is never picked, and the pick is the same one a user erasure uses), so nothing is orphaned. The same rule as a user erasure applies: the successor gets anownermembership row only when no other effective owner (direct owner or owner-group member of the project's tenant) remains; a disabled but not deleted co-owner still counts as an owner, and a project that is already ownerless gets the successor. A project the user owned without having created it is handled the same way; if no successor can be resolved for it, it is kept without an owner row (the deprovision still succeeds). "Solely owned" counts effective owners of the project's own tenant only: a leftover member row of a user from another tenant never counts as a second owner, and a deprovisioned user's leftover owner row on another tenant's project is ignored (no successor is added there). A platform admin's effective ownership of another tenant's project goes to a live tenant admin of the project's tenant, not of the platform admin's own; if that tenant has no live admin, no owner is added (the deprovision still succeeds) and a platform admin can recover the project; - blocks login and ends every session permanently on every device — the deactivation gate is checked live on every admin, API-token and scheduled request, and a per-user revocation floor (
sessions_valid_after) is stamped so an older admin cookie is refused even after reactivation; - hands the user's agents that are shared with the organisation, a group or other users to a successor, paused until the successor confirms them (the oldest live
ki_manager, otherwise the oldest livetenant_admin/admin; a deprovision has no per-agent or default successor, those apply only to an erase; with none, the agent stays with the user and its org sharing is cleared). Shares on handed agents are kept, and the successor is e-mailed after the commit (a failed mail never fails the deprovision). An agent still waiting on a previous hand-over to the deprovisioned user is left exactly as it was, paused, until the earlier owner returns or someone confirms or erases it; - writes a
scim.deprovisionaudit-log entry.
Last administrator is protected. A deprovision (PATCH active:false, PUT with active:false, or DELETE) of the tenant's last active tenant administrator is refused with 403 and the detail Refusing to deactivate the last active tenant administrator; nothing is revoked. A platform admin in the tenant counts as an administrator. Promote or keep another administrator, then retry. The first refusal per tenant and user per hour writes one audit entry and raises one alert; repeats add none. If the check itself fails (a database fault) the deprovision is refused and nothing is revoked.
Mass-deprovision breaker. Each tenant may deprovision at most 25 users per 3600 seconds (scim:deprovision:<tenant>). Beyond that the answer is 429 with Retry-After, nothing is revoked, the metric aig_scim_deprovision_held_total increments, a warning is logged, and the first hold per window writes an audit entry and an alert. Slots are consumed at admission, so a retried 503 or a last-administrator refusal also uses a slot. Tenant administrators can change the limit with scim_deprovision_limit (tenant settings). The counter is kept in the gateway node's shared memory: limits above 64 use the approximate sliding-window counter, which admits a request it could not record (a full shared-memory store), so the breaker bounds a burst rather than guaranteeing an exact count. If writing the audit entry for a refusal or hold fails, a warning is logged and that hour's entry is not retried (the alert still fires).
Serialisation. Every SCIM deprovision takes the tenant lock and therefore runs one at a time per tenant, behind group sync and capped creates. A lock wait that times out (1205) answers 503 and revokes nothing; retry. Known limit: the administrator-UI delete/disable path checks the last-administrator rule without this lock, so an administrator-UI removal of one admin racing a SCIM deprovision of the other could still leave a tenant without an administrator.
Reactivation (a returning employee — active:true, or a fresh POST with the same externalId) restores login but does not silently restore the revoked grants, sessions, or API tokens; the IdP re-provisions the grants and the user signs in afresh (the revocation floor is never cleared). Agents handed over at deprovision and not yet confirmed by the successor return to the reactivated user; confirmed agents stay with the successor. A reactivation also drops a Department an administrator assigned by hand (or one that predates the recorded source): the user returns with source idp and no Department, so the tenant default applies until the IdP sends one (see Departments). Reactivating an already-active user changes nothing.
Audit symmetry. Every access-changing SCIM event is auditable, not just the revoke: provisioning a user writes scim.provision, reactivating writes scim.reactivate, and deprovisioning writes scim.deprovision. A create-inactive therefore reads as scim.provision followed by scim.deprovision.
Credential auditing. Creating or revoking the SCIM credential (and deleting the SSO / SAML config) is audited with the signed-in administrator as the actor.
Change auditing. SCIM mutations also write an audit row in the same transaction as the change (actor_type system, no actor_id, after.source = "scim", actor_ip = the caller): scim.user_updated (after.fields_set lists the attribute names the request sent, never values; a same-values update still writes a row), scim.group_created, scim.group_renamed, scim.group_unlinked, scim.group_member_added and scim.group_member_removed (one row per request listing only the members that actually changed: user_ids, count, and truncated: true beyond 500) and scim.group_members_replaced (before / after member_ids, sorted, capped at 500 each with truncated: true and count when longer). No-ops write no row: re-adding existing members, adding a user outside the tenant, removing a non-member, or replacing a member set with an identical one. If the audit write fails, the whole change is rolled back and the request fails (503 for a retryable database error, 500 otherwise). Group membership changed by department-attribute sync is not audited per member. A change of the user's Department by SCIM writes scim.user_department_changed. See Audit log.
Creates return 201 with a Location header pointing at the new resource. A PatchOp whose path is an empty string ("") is treated as pathless (applied to the resource body), not silently dropped — so an active:false is never lost.
Reconciliation model
The IdP is the single source of truth for SCIM-managed users and groups. The filterable GET endpoints serve the IdP's match and full-sync cycles; do not edit SCIM-managed users or groups directly in the admin UI, as the next sync would overwrite or recreate them.
Cost centre
The enterprise-user extension's costCenter is stored on the user and reported by the chargeback exports (/cogs/per-user column cost_center):
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "department": "Sales", "costCenter": "CC-4711" }
- Applies on
POST,PUTandPATCH(path…:enterprise:2.0:User:costCenter, path = the extension URN with an object value, or a pathless object value). It is returned onGETand in lists. - Absent or
nullonPOST/PUTclears it (full replace). OnPATCHan operation that does not addresscostCenterleaves it untouched; aremoveof it (or of the whole extension) clears it, and areplaceof the whole extension object (path = the extension URN) is authoritative — acostCenterabsent from that object clears it. Anaddof the extension object or a pathless value changes it only when it carriescostCenter. - A blank value clears it; values are stored trimmed.
- Attribute names are case-insensitive — both the extension URN key and
costCenter(CostCenteris accepted). A name given twice in different case (costCenter+CostCenter, or the URN key twice) is ambiguous →400 invalidValue. - The extension must be a JSON object: an extension that is present but a string, number, boolean or array (on
POST/PUT, as a pathlessPATCHvalue, or as the value of aPATCHadd/replaceon the extension URN — wherenullor a missing value is malformed too) is400 invalidValue, never read as absent. Only the nested form is read: a flattened key"urn:…:enterprise:2.0:User:costCenter"inside a pathless value is ignored (use the path form for a single attribute). - Malformed is not absent: a non-string value (number, boolean, object, array) or one over 128 characters is
400 invalidValuewith nothing written (aPOSTcreates no user) when the user ends active — the same rule as a malformeddepartment. A request that leaves the user inactive (aPATCH/PUTwithactive:false, one on an already deprovisioned user, or aPOSTwithactive:false) is never blocked by it: the malformedcostCenteris ignored (the stored value is left unchanged, aPOSTstores none), the rest of the request applies, and the answer is200/201. APATCHreplace/addof the whole extension withnullleavescostCenterunchanged. - The cost centre is the user's current value: changing it re-labels past spend in the per-user report. Deleting a user (including GDPR erasure, a row delete) removes it with the row.
Manager
The enterprise extension's manager (urn:ietf:params:scim:schemas:extension:enterprise:2.0:User) names the user's manager; it routes the user's limit requests to that manager when the manager is in the same department. The value is the manager's SCIM id (the user id this server returns).
- Accepted:
manager: {"value": "<id>"}or a bare string id (Entra sendspath: "urn:…:User:manager", value: "<id>"andmanager.valuepaths); keys are case-insensitive; an upper-case id is normalised. Returned onGET/ list as{"value": "<id>"}when set. - Cleared: on
PUT/POST, an absentmanager(full replace),nullor""; onPATCH,null,"", aremoveop, or replacing the enterprise extension with an object withoutmanager. APATCHthat does not addressmanagerleaves it unchanged. - Rejected (
400 invalidValue, nothing applied): a value that is neither a string nor an object with a stringvalue(a number, a boolean, an array), the user's own id, an object namingvaluetwice in different case, or an addressed op without a value. As withcostCenter, a malformedmanagernever blocks a deprovisioning: when the user ends inactive it is ignored (and logged). - A string that is not uuid-shaped (an employee number, an e-mail address, a non-uuid identity-provider id) can never resolve: it is stored as no manager (logged), and the rest of the request applies. A uuid-shaped id that names no user of this workspace (not yet provisioned, a uuid-shaped identity-provider id, a user of another workspace) is stored and returned on
GET, but routes to nobody until that user exists in the same workspace. When the manager is erased (right to erasure) or the manager's organisation is purged, the id is cleared on every user that names it; a one-time cleanup during an update also cleared every manager id that named no existing user at that time. A later push that carriesmanagersets it again. Replacing the whole enterprise extension with an object that has nomanagerclears it (the same rule ascostCenter).
Department to group mapping
A SCIM user's enterprise department attribute can automatically place the user in an internal group — the same automatic grouping the SAML department claim performs, driven by one shared configuration (no separate SCIM mapping to keep in sync).
Accepted shape. The department is read from the enterprise-user extension in the request body:
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"],
"userName": "alice@corp.example",
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "department": "Sales" }
}
Configuration. Set group_attribute to department and group_mapping to the JSON allow-list { "<department value>": "<internal group id>" } on the tenant's identity configuration. This is settable on either the OIDC SSO config (PUT /admin/v1/tenants/{id}/sso-config) or the SAML config (PUT …/saml-config) — the two fields are one shared, tenant-scoped setting, so a pure OIDC/SCIM tenant configures department grouping without any SAML setup (no IdP metadata required). group_mapping must be a JSON object string and group_attribute is required whenever group_mapping is sent; the two are saved together, and a request that omits group_mapping leaves the existing mapping unchanged (the admin UI's IdP value mapping rows on User Management → Sign-in & provisioning write exactly this JSON and refuse to send a row with a blank IdP value, a missing group or a duplicate IdP value; the server validation above is unchanged) (an ordinary SSO/SAML config save never disturbs it). When group_attribute is department, the SCIM department value is looked up in the allow-list and the user is reconciled into the mapped group. If group_attribute is anything else (or unset), the SCIM department path does nothing — it never reuses a mapping whose keys are not department values.
Role targets. A group_mapping value may be a role target, { "kind": "role", "id": "<role id>" } (a system tenant role or a custom role of the tenant; see Groups API). On SCIM create / update the user's IdP-granted roles are set from the department value; a user without a department value (or a value that maps to nothing) loses the roles this lane granted. Saving or deleting a mapping with role targets, and generating or revoking the SCIM credential while role targets exist, need the tenant admin role.
Department targets. A group_mapping value may also be a department target, { "kind": "department", "id": "<department-id>" }. As soon as the mapping holds any department target, the mapping owns the user's department and the name match below is not used: when group_attribute is department and the SCIM department value maps to a department target, that department is assigned by id; any other value (unmapped, mapped to a group, absent or removed) leaves the department unchanged. A malformed department (including a value with nothing visible) is still 400 invalidValue. A manually assigned department wins unless the tenant's department_source_precedence is idp. The department sync runs independently of the group membership write. Rules, precedence and audit: Departments.
Behaviour.
- Create / update (
POST,PUT, andPATCHthat carriesdepartment) reconciles the user's derived membership to exactly the mapped group. A padded value maps like the trimmed one the Department assignment uses (" Sales "maps like"Sales": the exact key is tried first, then the trimmed value; an empty value clears), so the group and the Department never read one input two ways. The SAML/OIDC claim group mapping uses the same lookup. A department that is empty after trimming (""or ASCII whitespace only) is unassigned, so it never matches a stored mapping key made only of whitespace. - Value shape.
departmentmust be a string;null,""or ASCII whitespace only means unassigned (RFC 7643 §2.5) and clears the derived membership. A value with nothing visible (zero-width space, no-break space, ...) is malformed, not empty: a department value decides access, so garbage must not clear it (this is deliberate, unlikecostCenter, where an invisible-only value clears). Any other type, a present enterprise extension that is not a JSON object (a scalar or an array) onPOST,PUTandPATCH(whole-extension and pathless forms), and the other malformed values listed under Department assignment are400 invalidValue(department must be a valid department name string) with nothing applied — never read as "department removed". APATCHthat replaces the whole enterprise extension withnullleavesdepartmentuntouched. APATCHis atomic (RFC 7644 §3.5.2): a malformeddepartmentor extension in any operation makes the whole request400 invalidValue, even when a later operation in the same request sets a valid value or removes the attribute. A request that ends the user inactive is never blocked by a malformed department (it deprovisions, and deprovisioning removes derived memberships anyway). - Removal — a
PUTwhose body omitsdepartment, or aPATCHthat removes it — clears the derived membership. APATCHthat does not mentiondepartmentleaves membership untouched (partial-update semantics), so an unrelatedactive/displayNamechange never disturbs it. - The derived membership is written with its own provenance (
scim_attr) and is reconciled, never accumulated: it is completely independent of memberships added manually, via SCIM/Groups, or via a SAML claim, and it never clobbers them. - A change that removes the user's last owner path to a project hands the project to a live tenant admin (see Project ownership above); if that cannot complete because of a lock wait, the
PATCH/PUTanswers503and nothing is written, while aPOSTcreate or reactivation logs a warning and continues. On aPATCH/PUTthis503comes after the user-attribute change was committed: the attribute change is already applied and only the department-group sync is pending, so retrying the samePATCH/PUTis safe and converges. - A department value not present in
group_mappingresults in no membership (not an error). A deactivating request does not create derived memberships. - Tenant isolation is structural: a group id in the allow-list that does not belong to the tenant is silently ignored (0 rows) — a SCIM request can never place a user in another tenant's group. The
departmentvalue itself is only ever an allow-list key; it is never interpolated into SQL.
Independent of SAML. The mapping is stored per tenant and driven purely by group_attribute/group_mapping; it is independent of whether SAML SSO login is configured or enabled. A pure OIDC/SCIM tenant (no SAML IdP) can define it via the OIDC SSO-config endpoint, and a tenant that has migrated to another sign-in method but still provisions via SCIM keeps its department grouping. Setting only the group mapping never turns on SAML login.
To remove the mapping, set group_mapping to an empty allow-list ({}), or delete the SSO/SAML config.
Gateway grants. A group can carry gateway grants. Membership written here (scim_attr) and by the SCIM Groups API is applied by the identity provider and is not subject to the admin delegate rules, so editing a mapped department value or a SCIM group in the IdP can widen a user's gateways.
Limitation. Editing group_mapping does not retroactively re-group already-provisioned users until the IdP next sends a department update for them.
Department assignment
The same enterprise department attribute also sets the user's Department (the organisational unit that carries budgets and defaults), independent of the group mapping above and without any configuration. The value is the Department's name. This name match applies only while the tenant's group_mapping holds no department target; once it holds one, the mapping alone sets the department and the table below does not apply (see Department targets above).
Sent department |
Outcome |
|---|---|
| A name of a Department of this tenant | The user is assigned to it, marked as set by the identity provider (department_source = idp). |
| A name no Department of this tenant has | The user's own Department is cleared (marked idp), so the tenant default Department applies. A warning is logged; the request still succeeds. |
Absent: key missing on PUT / POST, null, an empty string or one of ASCII whitespace only, or a PATCH remove |
Clears an assignment the identity provider made earlier. An assignment or "no department" choice made by an admin is never touched. A PATCH that does not mention department changes nothing. |
Malformed: not a string (number, boolean including false, object, array), a department key under an enterprise extension that is itself not an object (a string, number, boolean or array, including an empty array []; null is absent — also when a PATCH addresses the whole extension, by path or inside a pathless value), a PATCH add / replace of department with no value at all (only remove, or an explicit null, clears), invalid UTF-8, longer than 255 characters after trimming, or a value with nothing visible (zero-width space, no-break space, ...; formerly read as an unknown name, which fell to the tenant default Department) |
400 invalidValue; nothing is applied. This used to be silently treated as "no department". A request that ends the user inactive (active:false) is never blocked by a malformed department: it deprovisions, and the value is only logged. |
Matching. The name is trimmed and matched against this tenant's Departments with the same case-, accent- and trailing-space-insensitive comparison the admin API uses (legal, LÉGAL and Legal all match Legal). A Department of another tenant never matches.
Precedence. The tenant setting department_source_precedence decides who wins when an admin assigned the user by hand. The default manual keeps the admin's assignment (and an admin's deliberate "no department"); an assignment made before the source was recorded (a Department set, no source) counts as an admin's assignment and is protected the same way; idp lets the identity provider overwrite it. Any other value behaves as manual. One exception: reactivating a soft-deleted user drops a manual or legacy Department regardless of this setting (source idp, Department empty).
SAML. A tenant can also drive the Department from a SAML assertion attribute (department_attribute in the SAML configuration). SCIM and SAML are last-writer-wins on the same field, except that a group mapping with department targets takes over as the only identity-provider source of the Department (then department_attribute is not applied). Absent differs: a SAML login without the attribute changes nothing, while SCIM absent clears an assignment the identity provider made earlier.
Audit. The reactivation demotion is recorded in the scim.reactivate row (before / after carry department_id and department_source). A change of the user's stored Department writes one scim.user_department_changed audit row in the same transaction (before / after carry department_id, department_source, the effective department and, for an unknown name, unknown_department: true). A request that changes nothing writes no row; if the assignment cannot be written (audit write failure or any other database error) it is rolled back and a PATCH or PUT answers 503 (retryable fault; retry is safe) or 500 (a failure a retry will not cure). On PATCH / PUT the user-attribute change may already be committed when the 503 / 500 is answered: only the Department write is rolled back, and a retry is idempotent. On POST (create) and on reactivation the user change is already committed, so the failure is logged as a warning and the request still succeeds without the Department.
Changing a user's email address
The email address is the user's sign-in identity: whoever controls it can request a one-time code or magic link for the account. A SCIM credential therefore may change an address only under these rules. They apply to PATCH (userName), PUT and a POST that reactivates a deprovisioned user with a new userName.
- Only accounts SCIM provisioned. The account must carry a non-blank
externalId. Any other account (for example the tenant owner or an administrator created in the console) answers403with the SCIM erroruserName change not permitted for this accountand nothing is written, even when the new address is in an allowed domain. An account that was provisioned by SCIM and later signed in through single sign-on still counts as SCIM-provisioned. - Only to a valid email address. The new
userNameof a SCIM-provisioned account must be a valid email address by the same rule as a new user's (local@domain.tld: a single@, a dotted domain, printable ASCII only). A bare login name such asalice(what some IdPs send asuserNameby default, for example authentik's managed SCIM mapping), a domain without a dot such asalice@corp, or a value with a space or a second@answers400withscimType: "invalidValue"and the SCIM erroruserName must be an email address. Nothing is written, so the account keeps the address its single sign-on matches. Map the IdP's email attribute touserName. An account whose stored address is not a valid email (an older row) keeps working when the request resends that address unchanged; only a change to another invalid value is refused. - Only into an allowed domain. The new address must end in a domain from the allowed email domains of an enabled OIDC or SAML configuration of the tenant (comparison is case-insensitive; the domain is the part after the last
@). Otherwise403withuserName domain is not allowed for this tenant. A tenant with no enabled single sign-on configuration has no allowed domains, so every email change is refused there. - Creating a new user is unaffected in a tenant without single sign-on. If the tenant has allowed domains, a new user's address must be inside them as well.
- Not a change: resending the stored address, including with different capitalisation, is not a change and is accepted for every account.
- A refused request applies nothing. A request that carries a refused
userName(403or400above) together with other attributes (for exampledisplayName) writes none of them, andactive:truedoes not reactivate the user.active:falsein the same request still deprovisions, then the refusal is answered: a revoke is never blocked. A policy lookup fault answers503withRetry-After: 10. - An allowed change signs the user out everywhere. It revokes the user's sessions, personal access tokens and device sign-ins, removes the user's push-notification device registrations, and deletes the pending sign-in one-time codes, magic links and password reset links of both the old and the new address, and writes a
scim.user_email_changedaudit entry holding the email domain before and after (never the full address). Each refusal writes ascim.user_email_change_deniedaudit entry that records the reason only. Denial entries (this one and the seat-limit refusal) and the notes for a refused or held deprovision (scim.deprovision_refused/scim.deprovision_held) are best-effort: a failure to write one is logged and never changes the answer the IdP receives. Thescim.deprovisionentry itself commits together with the deprovision.
Global email namespace and provisioning rate limit
One address, one account (by design). An email address (the SCIM userName) identifies exactly one user account across the whole platform — the gateway is a business product in which one person belongs to one tenant, so the address namespace is global rather than per-tenant.
- Accepted:
POST /Userswith auserName/email that is not already registered →201 Created. - Storage faults on
POST /Users: a deadlock with a concurrent write (or another immediate serialization abort the database asks the client to restart — typical during a bulk initial sync, when the IdP creates many users in parallel) is retried by the server: the whole provision, including its audit record, re-runs from scratch, up to 4 attempts, never creating a second account. A conflict that persists through every attempt, and any other storage/infrastructure fault on the create step (database unavailable, a lock wait that outlasts the request's database timeout), answers503— retryable, never500— and the driver's error text is logged, not returned. Nothing was created, with one exception inherent to any database client: if the connection drops while the final commit is in flight, the commit may have been applied — the IdP's retry then answers409uniquenessfor thatexternalId/userName, and the user exists. Two concurrent creates racing for the sameuserNameorexternalIdend as one201and one409withscimType: "uniqueness". A create that asks foractive: falseprovisions and deactivates the user in the same transaction (both audit records —scim.provisionandscim.deprovision— included): either the user exists deactivated or nothing was created; a failure of the deactivation step rolls the whole create back and answers503, never an active user the IdP asked to create inactive. Reactivations and attribute updates are retried by the server the same way (the whole step re-runs from scratch, up to 4 attempts; onescim.reactivaterecord per reactivation). The same503applies when a reactivation or an attribute update cannot read the rows it must lock, or still conflicts after the retries: it applies nothing rather than continuing without the check. - Rejected: a
userName/email that is already registered →409withscimType: "uniqueness". This refusal is intentional: because an address maps to a single account, a second registration of the same address is declined rather than creating a duplicate identity. The409does not disclose which tenant owns the address.
Conflict vs. transient fault (the returning-user path). Reactivating a deactivated user (a POST with a returning externalId, or active:true on PATCH/PUT) and updating its attributes are each classified so the IdP reacts correctly: a genuine email collision — the address the request carries (or, without one, the returning user's old address) is now held by a different live account — returns 409 with scimType: "uniqueness" and leaves the user deactivated (a permanent conflict the IdP resolves by sending a free userName, which then reactivates the account under it), while a transient/infrastructure fault (database unavailable, lock timeout, a row disappearing under a concurrent change) returns 503 (a retryable status) with Retry-After: 10 — every SCIM 503 (on /Users, /Groups, the unreadable-body and the credential-lookup answers) carries that header. A retryable fault is never reported as a 409 (which the IdP would not retry) or a 500 (which reads as permanent). The address collision check is scoped to live accounts; a deactivated account's tombstoned address does not block a reactivation. The returning user's address and display name are applied in the reactivating transaction itself, so a reactivation never leaves a live user waiting on a second, separately failing update.
Rate limit. POST /Users is rate-limited per SCIM bearer token (default 60 requests per 60 seconds per tenant; there is exactly one bearer per tenant). Exceeding it returns 429 with a Retry-After header. IdP provisioning services (Microsoft Entra, Okta) honour Retry-After and retry with backoff, so a burst during a large initial sync is throttled, never dropped. The limit bounds automated bulk probing of the address namespace at scale; it is not intended to (and cannot) prevent a single lookup, which is inherent to a global-account model. The limit is operator-tunable for a large initial sync (thousands of users in one sitting): contact operations to raise it for the duration of the sync. /Groups writes are not subject to it.
Request body contract
Every body-bearing SCIM method (POST, PUT, PATCH) reads its body through one reader (the same one the admin API uses, in the stricter SCIM mode), so these rules hold uniformly:
- Accepted shape: a JSON object — inline or large. Bodies above the gateway's in-memory buffer (~320 KB) are spooled by nginx and read back in full, so a Group
PATCHcarrying thousands of members or a bulk full-resourcePUTis applied exactly like a small one. The body may be at most 2 MB (client_max_body_sizeon the SCIM location); anything larger is refused by nginx with a plain413before the request reaches the SCIM handler — no SCIM Error document, nothing read, nothing changed. - Rejected —
400withscimType: "invalidSyntax": an absent or empty body (RFC 7644 requires one on these methods), a body that is not a JSON object (null, a number, a string, a boolean, or a JSON array), malformed JSON (a truncated payload, a trailing token, a byte-order mark), a number that is not finite anywhere in it (NaN,Infinity, an out-of-range1e999), an object that repeats a key anywhere in it ({"active":false,"active":true}— a JSON parser would keep only the last value, so the IdP's intent would be ambiguous), and a body that is not valid UTF-8 anywhere (RFC 8259 §8.1 — checked once for the whole body, so no string field can carry an invalid byte into the database). Nothing is read from it and nothing is written. Malformed body content is never logged (a SCIM body carries personal data); only the parser's error position is. - Rejected —
400withscimType: "invalidValue": a brand-new user whoseuserName(or theemails[].valueused in its place) is not a valid e-mail address — it is the user's sign-in identity (POSTonly; a returningexternalIdreactivation is not re-validated); identity keys beyond their storage width —userName(andemails[].value) over 254 bytes,externalId(and a Group'sdisplayName, its key) over 255 characters — on every method that carries them (an over-long value is never a500or a retried503). A User's display name (name.formatted/displayName) is not an identity: it is stored truncated to 255 characters rather than refused, so a long name never blocks a request — in particular never a deactivation carried in the same request. - Rejected —
413Error document (noscimType): a body with more than 262,144 JSON values (structural elements), refused before it is parsed; checked ahead of the400syntax rules, so an over-complex body that is also malformed answers413. Split the payload. - Rejected —
503withRetry-After: 10: a body that was sent but could not be read (a spooled body whose temp file failed to read). Not a client error; the IdP should retry after the header, not in a tight loop. It is distinct from an absent body, which is a400. - Body syntax is validated before the resource lookup, so an absent, non-object, malformed or unreadable body on an unknown id answers
400/503, not404. A well-formed object on an unknown or other-tenant id still answers404(the field-level checks sit after the lookup). - A genuine server fault while handling a request returns a SCIM Error document with status
500whosedetailcarries the request id for correlation with the gateway's logs — never the database's error text. A transient storage failure on a Group write answers the retry503withRetry-After, a write the database rejects deterministically the500with the request id (see Group write faults above); a GroupdisplayNamethat another group of the tenant already holds — on create or rename — answers409withscimType: "uniqueness"(a permanent conflict, never retried). - The
detailtext of a SCIM Error document is human-readable and is not a contract; match on thestatusandscimType(for example400withinvalidFilterfor a filter the gateway cannot accept, including one that is not valid UTF-8).
Input validation
The filter grammar is restricted to userName/externalId eq "value" (groups: displayName eq); the attribute maps to a fixed field and is never interpolated as a SQL column, and an unparseable filter returns 400 — never "return all". Bodies are validated; a duplicate externalId/userName returns 409 uniqueness (see Global email namespace for the global-vs-tenant scope of the address check), retries are idempotent. A sustained burst of POST /Users on one token is rate-limited to 429 with Retry-After.
Numbers in SCIM responses are written exactly as stored or sent (for example a startIndex of 999999999 is echoed unchanged). If a response cannot be encoded, the endpoint answers 500 with an RFC 7644 error document; see Error codes.