Skip to content

Directory sync (SCIM) and customer setup links ​

Directory sync keeps one customer's user list in step with their identity provider. When someone leaves the customer's company and is deactivated in Okta or Microsoft Entra ID, they are suspended in your app and signed out. Nothing is deleted.

Mint a one-time link for one customer (tenant) from your backend. The API key needs the setup-links.write scope, which is not part of any broad scope.

http
POST /api/v1/runtime/applications/{applicationId}/tenants/{tenantId}/setup-links
X-TenancyEngine-Api-Key: te_...

The response contains url. Send it to the customer's IT admin.

  • The link can be opened once, within 5 minutes of being created.
  • After it is opened, the setup page stays available for 7 days.
  • Creating a new link for the same customer stops the previous one at once. DELETE on the same path revokes it immediately.
  • The page uses your application's white-label name, logo and color.
  • The link is never logged: it travels in the URL fragment.

What the IT admin does ​

On the setup page they copy the SCIM base URL, create a bearer token (shown once, valid for 180 days) and paste both into a SCIM 2.0 application in their identity provider. Creating a new token stops the previous one from working.

Using SCIM directly ​

Base URL: /api/v1/runtime/applications/{applicationId}/tenants/{tenantId}/scim/v2

Authentication: Authorization: Bearer te_... with an application-level API key that carries the scim.provision scope.

OperationNotes
GET /Usersfilter supports userName eq, emails.value eq, externalId eq and id eq. startIndex and count (up to 100).
GET /Users/{id}
POST /UsersuserName must be the user's email address. New users get the member role and no password; they sign in through your app's sign-in. SCIM cannot grant an admin role.
PUT /Users/{id}
PATCH /Users/{id}add, replace and remove on active, userName, externalId, displayName and name. Entra's string booleans are accepted.
DELETE /Users/{id}Suspends and signs the user out, and removes them from this tenant.
GET /ServiceProviderConfig, GET /ResourceTypes
GET /Groupsfilter supports displayName eq (not case sensitive), externalId eq and id eq. Members are left out of the list; read one group to get them.
GET /Groups/{id}Includes members.
POST /GroupsdisplayName is required and unique per tenant, not case sensitive. Every member must already be a user of this tenant.
PUT /Groups/{id}Replaces the name, external id and the whole member list.
PATCH /Groups/{id}add, replace and remove on members (also members[value eq "id"] for remove), displayName and externalId. Operation names are not case sensitive, so Entra's "Add" works.
DELETE /Groups/{id}Deletes the group. The people in it keep their accounts.

active: false suspends the account and revokes refresh tokens and cookie sessions. A person who also belongs to another customer's tenant keeps that access; the account is only locked once no active tenant is left. Reactivating lifts only a suspension that SCIM itself applied.

Groups and roles ​

A group your customer's identity provider pushes does nothing to roles on its own. Only your organization's administrators decide what a group means, so your customer's IT team cannot create a group and give themselves a role.

In the console, open the tenant, then Members, then Directory groups. Pick a role for each group:

  • Members get the role as soon as they are in the group, and new members get it when they are added.
  • If someone is in several mapped groups, the group you mapped first decides, so adding a second group never changes a role silently.
  • When someone leaves the group, or the group is deleted or unmapped, they return to member, but only if their current role came from that group. A role you set by hand is never taken away by a directory change.
  • The last tenant administrator is never demoted by a directory change.
  • A role the tenant's plan does not include is skipped and recorded in the audit log.
  • Mapping a group to tenant_admin asks you to confirm with your password or a verification code.

Every mapping and every role it applies is recorded in the audit log (scim.group.mapped, scim.group.role_applied, scim.group.role_skipped).

Webhooks ​

Subscribe your application webhook endpoint to directory.user.created, directory.user.updated and directory.user.deactivated. Each payload carries organizationId, applicationId, tenantId, userId and email, and is signed like every other application webhook.

Groups send directory.group.created, directory.group.updated (name, members or mapped role changed) and directory.group.deleted. Their payloads carry organizationId, applicationId, tenantId, groupId, displayName and mappedRole, but not the member list: read the group over SCIM or listen for directory.user.* when you need members.

Not yet available ​

The single sign-on and domain steps of the setup page are planned. Groups are not shown to your customer's IT admin on the setup page yet.

TenancyEngine platform documentation