# SCIM provisioning

> Create, update and remove people and groups from your identity provider.

Source: https://docs.ligament.ai/guides/identity/scim/

SCIM lets your identity provider (IdP) manage who is in your workspace. When you assign someone to the Ligament app in Entra ID or Okta, the IdP adds them to the workspace; when you unassign them or they leave, it removes them. The IdP can also push groups, which you map to roles in Ligament. Use it with [single sign-on](https://docs.ligament.ai/guides/identity/sso/index.md) so that joining, role changes and offboarding all happen in the IdP.

Ligament implements SCIM 2.0 at `https://app.ligament.ai/api/scim/v2`, with `Users` and `Groups` resources.

## Before you start

-   Verify your email domain in **Settings › Domains** (see [Verified domains](https://docs.ligament.ai/guides/identity/domains/index.md)). SCIM only adds people whose email address is at a domain your workspace has verified.
-   You need to be a workspace admin to create SCIM tokens.

## Connect your identity provider

1.  In Ligament, open **Settings › Single sign-on** and scroll to **SCIM provisioning**. Copy the **Endpoint** (`https://app.ligament.ai/api/scim/v2`).
2.  Select **Generate token**, give it a name you’ll recognise later (for example “Entra ID provisioning”) and select **Generate**. Copy the token now: it’s shown once. Tokens start with `scim_`.
3.  In your IdP, open the provisioning settings of the Ligament app. In Entra ID that’s **Provisioning › Automatic**: paste the endpoint as **Tenant URL** and the token as **Secret Token**, then **Test Connection** and **Save**.
4.  Turn provisioning on in the IdP.

The token list shows each token’s name, when it was created and when the IdP last used it. To cut off an IdP, select its token and choose **Revoke**: provisioning with it stops at once and calls answer `401`.

The token belongs to the workspace you created it in. Every call made with it reads and writes that workspace only.

## What the IdP can do

| Resource | Operations | Notes |
| --- | --- | --- |
| `/Users` | `GET` (list, paged with `startIndex` and `count`, up to 200 a page), `POST`, `GET /Users/<id>`, `PUT`, `PATCH`, `DELETE` | Filter by `userName eq "<email>"`. Other filters return an empty list, so the IdP creates the user. |
| `/Groups` | `GET`, `POST`, `GET /Groups/<id>`, `PUT`, `PATCH`, `DELETE` | Filter by `displayName eq`, `externalId eq`, `id eq` or `members[value eq "<user id>"]`, joined with `and`. `excludedAttributes=members` leaves members out. |
| `/ServiceProviderConfig`, `/Schemas`, `/ResourceTypes` | `GET` | What the IdP reads when it connects. |

Bulk operations, sorting, ETags and password changes aren’t supported. The service provider config says so, and IdPs read it when you test the connection:

```json
{
  "patch": { "supported": true },
  "bulk": { "supported": false, "maxOperations": 0, "maxPayloadSize": 0 },
  "filter": { "supported": true, "maxResults": 200 },
  "changePassword": { "supported": false },
  "sort": { "supported": false },
  "etag": { "supported": false }
}
```

## Users

The IdP identifies a user by `userName`, which must be their email address. A user resource looks like this:

```bash
curl -s -G "https://app.ligament.ai/api/scim/v2/Users" \
  -H "authorization: Bearer $SCIM_TOKEN" \
  --data-urlencode 'filter=userName eq "agent@northwind-example.com"'
```

```json
{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
  "totalResults": 1,
  "startIndex": 1,
  "itemsPerPage": 1,
  "Resources": [
    {
      "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
      "id": "7y39vvpJhpSa1bmBIgKAzmhUMHYjyACg",
      "userName": "agent@northwind-example.com",
      "displayName": "Alex Agent",
      "active": true,
      "meta": {
        "resourceType": "User",
        "location": "https://app.ligament.ai/api/scim/v2/Users/7y39vvpJhpSa1bmBIgKAzmhUMHYjyACg"
      },
      "name": { "formatted": "Alex Agent", "givenName": "Alex", "familyName": "Agent" },
      "emails": [{ "value": "agent@northwind-example.com", "primary": true, "type": "work" }]
    }
  ]
}
```

What each call does:

| The IdP sends | Ligament does |
| --- | --- |
| `POST /Users` | Adds the person to the workspace with the role Member. If they already have a Ligament account (from another workspace, or an earlier sign-up), that account joins; otherwise a new one is created. If the People app is installed, they also get a person record. If they are already a member, the existing resource comes back unchanged. |
| `PATCH` or `PUT` with a new name | Sets the person’s display name in this workspace. Their name in other workspaces they belong to doesn’t change. |
| `active: false`, or `DELETE /Users/<id>` | Removes the person from the workspace (deprovisioning) and from every group in it. Their Ligament account itself isn’t deleted. |
| `active: true` again | Adds them back, with no groups until the IdP pushes them again. |

The workspace owner is never removed by SCIM. A `GET` for someone who isn’t a member of this workspace returns `404`.

Role changes don’t come through `/Users`. Give people roles with groups (below) or in **Admin › Members**.

### Only people at your verified domains

SCIM can only add someone, new or existing, if their email domain is verified by this workspace. For any other address the call fails and nothing is written:

```json
{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
  "status": "403",
  "detail": "Can't provision or link a user at northwind-example.com: it isn't a domain this workspace has verified. Verify it under Settings → Domains first."
}
```

If you see this in the IdP’s provisioning log, verify the domain in **Settings › Domains**, or remove people at other domains (contractors with personal addresses, for example) from the app’s assignment.

## Groups and roles

A group pushed by the IdP appears in **Settings › Access › Groups** with the source **SCIM** and its external ID. Its members are the people the IdP lists, and you change membership in the IdP, not in Ligament.

A group gives nothing until you map it to roles. Open the group and select **Edit role mapping**. From then on, everyone the IdP puts in the group holds those roles, and loses them as soon as the IdP takes them out. See [Groups](https://docs.ligament.ai/guides/access/groups/index.md) for mapping roles to groups.

\[Screenshot: A SCIM group named IT Field Engineers in Settings › Access › Groups: its badge shows the external ID, it is not mapped to a role yet, and Alex Agent is listed as a member added by SCIM\]

Rules the group endpoints follow:

-   A member’s `value` is the Ligament user `id` that `/Users` returns. Every member must already be in the workspace. If one isn’t, the whole request fails with `400` (`scimType: invalidValue`) and names the user: `Not a user of this workspace: "usr_doesnotexist"`.
-   `PATCH` supports `add`, `remove` and `replace` on `members`, `displayName` and `externalId`, including the `members[value eq "<id>"]` path that Entra ID and Okta send to remove one member.
-   The IdP only sees groups it created. Groups you made by hand in Ligament aren’t visible or editable over SCIM.
-   Every group change is recorded in **Settings › Access › Audit**, with the token as the source.

Adding a member to a group:

```bash
curl -s -X PATCH "https://app.ligament.ai/api/scim/v2/Groups/grp_9c640a1a82f9169609ea8c69" \
  -H "authorization: Bearer $SCIM_TOKEN" \
  -H 'content-type: application/scim+json' \
  -d '{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
    "Operations": [{ "op": "add", "path": "members", "value": [{ "value": "ixO3gz5g8e3XQY4PvpXkT6dQD32DlB5P" }] }]
  }'
```

The response is the full group, now with both members.

## Errors

SCIM errors use the standard error envelope (`urn:ietf:params:scim:api:messages:2.0:Error`) with `status` and `detail`:

| Status | Detail | Meaning |
| --- | --- | --- |
| 401 | Invalid or missing SCIM bearer token | The token is wrong or was revoked. |
| 401 | This workspace has been suspended | Provisioning is paused while the workspace is suspended. |
| 403 | Can’t provision or link a user at … | The email domain isn’t verified by this workspace. |
| 400 | userName is required | `POST /Users` without `userName`. |
| 400 | Not a user of this workspace: ”…” | A group member isn’t in the workspace. |
| 404 | User not found / Group not found | Not in this workspace. |

The SCIM endpoints are listed with the rest of the API in the [REST API reference](https://docs.ligament.ai/reference/rest-api/index.md#scim).
