# SCIM

SCIM (System for Cross-domain Identity Management) is a standard protocol that identity providers use to create, update, and remove user accounts in other applications. Skribble has a SCIM 2.0 interface. With it, your identity provider keeps the users and groups of your Skribble business in sync with your directory.

SCIM and the [User Management API](/user-management-api-quick-start) change the same users and groups. SCIM is for identity providers that call Skribble on their own. The User Management API is for your own code.

:::info

Skribble supports and tests SCIM with Microsoft Entra ID. For the step-by-step setup in Entra ID, see [SCIM setup](https://product.docs.skribble.com/en/business-admin/sso/scim-setup) in the product documentation. This page describes the interface itself.

:::

## Availability

SCIM is available on the Scale plan. The Skribble team sets it up with you. To request it, contact [support@skribble.com](mailto:support@skribble.com).

When Skribble enables SCIM for your business, you get a client ID and a client secret. The client ID identifies the SCIM client of your business. Keep the client secret in a secret store.

The tenant URL (the SCIM base URL) and the token endpoint depend on the data hosting region of your business:

| Region | Tenant URL | Token endpoint |
|--------|------------|----------------|
| Switzerland | `https://api.skribble.com/scim/v2` | `https://kc.skribble.com/auth/realms/skribble/protocol/openid-connect/token` |
| Germany | `https://api.skribble.de/scim/v2` | `https://kc.skribble.de/auth/realms/skribble/protocol/openid-connect/token` |

Use the URLs of the region in which your business is hosted. A token from one region does not work in the other region.

## Authentication

SCIM uses the OAuth 2.0 client credentials grant. It does not use the API username and API key from [Authentication](/authentication). Your identity provider gets a token from the token endpoint and sends it as a bearer token with every SCIM request. The examples on this page use the Swiss region.

```bash
TOKEN=$(curl -fsS -X POST "https://kc.skribble.com/auth/realms/skribble/protocol/openid-connect/token" \
  --data-urlencode grant_type=client_credentials \
  --data-urlencode "client_id=$CLIENT_ID" \
  --data-urlencode "client_secret=$CLIENT_SECRET" | jq -er .access_token)

curl -fsS "https://api.skribble.com/scim/v2/Users?filter=userName%20eq%20%22jane.doe%40example.com%22" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/scim+json"
```

Skribble accepts only tokens that were issued to a SCIM client. A token from the API login, or from a user's login, gets `401`.

## Protocol

The interface follows SCIM 2.0. The protocol, the endpoints, and the request and response formats are defined in two standards:

- [RFC 7643](https://datatracker.ietf.org/doc/html/rfc7643): SCIM core schema, the resources and their attributes
- [RFC 7644](https://datatracker.ietf.org/doc/html/rfc7644): SCIM protocol, the endpoints, filters, `PATCH` operations, and errors

All paths start with the tenant URL, for example `https://api.skribble.com/scim/v2/Users`. Skribble supports the resource types `User` (`/Users`) and `Group` (`/Groups`).

## Discovery

The discovery endpoints from [RFC 7644, section 4](https://datatracker.ietf.org/doc/html/rfc7644#section-4) describe what the interface supports. Read them to see the current state, because they always match the running service.

| Endpoint | Content |
|----------|---------|
| `GET /scim/v2/ServiceProviderConfig` | The supported protocol features and limits |
| `GET /scim/v2/ResourceTypes` | The resource types `User` and `Group`, with their schemas |
| `GET /scim/v2/Schemas` | Only the attributes that Skribble reads |

```bash
curl -fsS "https://api.skribble.com/scim/v2/ServiceProviderConfig" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/scim+json"
```

## Differences from the full standard

Skribble does not support every optional part of SCIM 2.0:

| Feature | Supported | Details |
|---------|-----------|---------|
| `PATCH` | Yes | Users return `200` with the user. Groups return `204` with no body. |
| `PUT` | No | Returns `501 Not Implemented`. Send changes with `PATCH`. |
| Filter | Only `eq` | One equality filter per request. Users: `userName` or `externalId`. Groups: `displayName` or `externalId`. |
| Pagination | Yes | `startIndex` and `count`. `count` is at most `200`. |
| Bulk | No | |
| Sort | No | |
| ETag | No | |
| Change password | No | Users sign in through SSO, or set a password on the Skribble login page. |
| Group members in lists | No | `GET /Groups` returns groups without members. Read a group by `id` to get them. |

## User attributes

Skribble reads the attributes in the tables below. It accepts other attributes of the SCIM core User schema and of the enterprise extension, but ignores them. An attribute outside the User schema, or an invalid value, returns `400`.

The attributes come from three schemas. In a request, the attributes of an extension go in an object named after the schema URN, as in the [example below](#example-create-a-user).

### Core schema

Schema URN: `urn:ietf:params:scim:schemas:core:2.0:User`

| Attribute | Skribble field | Notes |
|-----------|----------------|-------|
| `id` | User ID | Set by Skribble |
| `externalId` | `external_id` | The stable link to the user in your directory. Unique in your business. |
| `userName` | `email` | The matching key and the user's Skribble email. Skribble changes it to lowercase. |
| `active` | `status` | `false` suspends the user, `true` reactivates the user. |
| `name.givenName` | `first_name` | |
| `name.familyName` | `last_name` | |
| `phoneNumbers[type eq "mobile"].value` | `mobile` | Country code plus number, digits only, for example `41781122304`. Other phone types are ignored. |
| `preferredLanguage` | `lang` | `en`, `de`, `fr`, or `it`. A region is removed, for example `de-CH` becomes `de`. Other languages are ignored. |
| `roles[].value` | `roles` | `admin`, `creator`, or `signer`. See [Roles](#roles). |

### Enterprise extension

Schema URN: `urn:ietf:params:scim:schemas:extension:enterprise:2.0:User`

| Attribute | Skribble field | Notes |
|-----------|----------------|-------|
| `costCenter` | `cost_center` | The only attribute of this extension that Skribble reads |

### Skribble extension

Schema URN: `urn:ietf:params:scim:schemas:extension:skribble:2.0:User`

| Attribute | Skribble field | Notes |
|-----------|----------------|-------|
| `defaultLegislation` | `default_legislation` | `zertes` or `eidas`, in any case |
| `defaultQuality` | `default_quality` | `ses`, `aes`, or `qes`, in any case |
| `lastLoginAt` | `last_login_at` | Read-only |
| `lastInvitationAt` | `last_invitation_at` | Read-only |

In attribute mappings, for example in Microsoft Entra ID, write an extension attribute as the schema URN, a colon, and the attribute name: `urn:ietf:params:scim:schemas:extension:skribble:2.0:User:defaultQuality`.

### Values

Skribble takes the email only from `userName`. It ignores `emails`.

A Skribble user always has a first name, a last name, a language, and signature defaults. If you send an empty value for one of these, Skribble keeps the current value and applies the rest of the change. An empty mobile number or cost center clears the field.

### Example: create a user

```bash
curl -X POST "https://api.skribble.com/scim/v2/Users" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/scim+json" \
  -d '{
    "schemas": [
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:extension:skribble:2.0:User"
    ],
    "externalId": "8f1e4c2a-5b6d-4e7f-9a0b-1c2d3e4f5a6b",
    "userName": "jane.doe@example.com",
    "name": { "givenName": "Jane", "familyName": "Doe" },
    "preferredLanguage": "en",
    "active": true,
    "roles": [{ "value": "creator", "primary": true }],
    "urn:ietf:params:scim:schemas:extension:skribble:2.0:User": {
      "defaultQuality": "qes"
    }
  }'
```

## Roles

The `roles` attribute sets the Skribble role. The values are `admin`, `creator`, and `signer`. They mean the same as in the [User Management API](/user-management-api-quick-start#roles).

- If a user has more than one role value, Skribble gives the user the highest role: `admin`, then `creator`, then `signer`.
- A role without a value, for example the Entra ID role "Default Access", counts as `signer`.
- Skribble ignores other role values.
- To change a role, send the full list of roles with an `add` or `replace` operation. Skribble rejects a `remove` operation on `roles`.

Skribble does not store `display`, `type`, or `primary` of a role.

## Group attributes

| SCIM attribute | Skribble field | Notes |
|----------------|----------------|-------|
| `id` | Group ID | Set by Skribble |
| `externalId` | `external_id` | The stable link to the group in your directory. Unique in your business. |
| `displayName` | `name` | Unique in your business. The comparison ignores case. A duplicate returns `409` with `scimType` `uniqueness`. |
| `members[].value` | Member | The SCIM `id` of a user in your business |

A Skribble group has no role. Roles always come from the user's `roles` attribute.

A member must already be a user of your business. A user outside your business, or an invited user who did not accept the invitation yet, returns `400` with `scimType` `invalidValue`. Adding a user who is already a member succeeds.

Group changes need the groups feature in your plan. Without it, Skribble returns `400`. The limits of your plan on the number of groups and members also apply.

## Effect of each request

| SCIM request | Effect in Skribble |
|--------------|--------------------|
| `POST /Users` | Same as [creating a user](/user-management-api-quick-start#step-1-create-a-user) with the User Management API. On your managed domains, the user is added at once and gets no email. On other domains, the user gets an invitation email. |
| `POST /Users` with `active: false` | Skribble creates the user and then suspends them. |
| `PATCH /Users/{id}` with attributes | Skribble updates the user. |
| `PATCH /Users/{id}` with `active: false` | Skribble suspends the user. The login is blocked. Open signature requests stay. |
| `PATCH /Users/{id}` with `active: true` | Skribble reactivates the user. |
| `DELETE /Users/{id}` | Same as [deleting a user](/user-management-api-quick-start#suspend-reactivate-and-delete) with the User Management API. On your managed domains, Skribble deletes the account and its data. |
| `DELETE /Groups/{id}` | Skribble deletes the group. Its members stay in your business. |

:::warning

Before you send `DELETE /Users/{id}` for a user on one of your managed domains, make sure that you want to delete the account. Skribble deletes the account and its data, and you cannot undo this. To only block access, set `active` to `false`.

:::

For an invited user who did not accept the invitation yet, `active: false` withdraws the invitation, the same as suspending the user with the User Management API. The invitation link stops working, and Skribble returns `200` with the status `suspended`. `DELETE /Users/{id}` also withdraws the invitation.

## Errors

Errors use the SCIM error format from RFC 7644 with the `urn:ietf:params:scim:api:messages:2.0:Error` schema.

| Status | `scimType` | Cause |
|--------|------------|-------|
| `400` | `invalidFilter` | The filter is not one equality filter on a supported attribute. |
| `400` | `invalidValue` | A value has the wrong format, or a group member is not a user of your business. |
| `401` | | The token is missing, expired, or not from a SCIM client. |
| `403` | | The SCIM client has no access, for example because SCIM is not enabled for your business. |
| `404` | | The user or group does not exist in your business. |
| `409` | `uniqueness` | When you create a user, or create or rename a group: the email, `externalId`, or group name is already in use. |
| `409` | | Another conflict, for example `cannot delete or remove the business's last admin`. The `detail` field contains the message. |
| `501` | | `PUT` is not supported. |
| `502` | | Skribble is temporarily not available, or the rate limit was reached. Your identity provider retries in the next cycle. |

## Next steps

- [SCIM setup](https://product.docs.skribble.com/en/business-admin/sso/scim-setup): configure Microsoft Entra ID step by step.
- [User Management API quick start](/user-management-api-quick-start): manage users from your own code.
- [User Management API v3 reference](/api/user-management-v3): all REST endpoints.
