# SCIM API

> The SCIM 2.0 requests Oktul eID SSO answers, its bearer token, the identifier attribute and every status code, for an identity admin or a SCIM client.
>
> Documentation for Oktul eID SSO for Jira, for Jira Cloud, by Oktul: https://oktul.com/docs/plugins/eid-sso/scim-api/

The app has a SCIM 2.0 server that receives users. Microsoft Entra ID is the client it is built
and tested for. [Provision users from Entra ID](../entra-provisioning/) is the setup guide; this
page lists what the server answers.

## Address and token

- **The address** is the **Tenant URL** on the app's **SCIM** tab. It belongs to the
  installation.
- **Every request** carries `Authorization: Bearer` and the SCIM token. Any other request gets
  `401`.
- **The token** is generated on the **SCIM** tab and shown once. The app stores only a SHA-256
  hash of it. **Replace SCIM token** makes a new one, and the old one stops working at once.

## Requests

| Request | What it does |
|---|---|
| `GET /Users?filter=…` | Finds a user by `userName` (in any letter case), `externalId` or `id`, with `eq` |
| `POST /Users` | Creates a user. `201` |
| `GET /Users/<id>` | Reads a user |
| `PUT /Users/<id>` | Replaces a user |
| `PATCH /Users/<id>` | Changes a user, including the forms Entra ID sends |
| `DELETE /Users/<id>` | Deletes a user. `204` |
| `GET /ServiceProviderConfig`, `/Schemas`, `/ResourceTypes` | Discovery |

- **`GET /Users` without a filter** answers `400 tooMany`. The server lists no users.
- **`/Groups`** answers `404`. Turn group provisioning off in the client.
- **Bulk requests, sorting, ETags and password changes** are not supported, and
  `/ServiceProviderConfig` says so.

## The user resource

| Attribute | Stored | Notes |
|---|---|---|
| `id` | Yes | Made by the server |
| `userName` | Yes | Required. Unique, in any letter case |
| `emails[type eq "work"].value` | Yes, one address | The email Atlassian knows the user by. Unique, in any letter case. Without a work email, an email-shaped `userName` is used |
| `externalId` | Yes | The permanent ID the app sends to Atlassian. Unique. A user without it cannot log in |
| `active` | Yes | An inactive user cannot log in |
| `urn:ietf:params:scim:schemas:extension:oktul:2.0:User:nationalIdentifier` | Yes | The country and personal code, as `PNOEE-38001085718`. Unique. **Never returned** |
| Every other attribute | No | Accepted and ignored |

### The national identifier

- **The form** is `PNO`, the country (`EE`, `LV` or `LT`), a hyphen and the eleven-digit code.
  Anything else is refused with `400 invalidValue`. The message names the rule and never the
  value.
- **A bare code** is refused the same way. The server never assigns a country to digits.
- **It is write-only.** The schema marks it `returned: "never"`, and no answer carries it.
- **A `PUT` that leaves it out** keeps the stored one. Only an explicit `null` or an empty
  string clears it.

## Status codes

| Status | When |
|---|---|
| `200`, `201`, `204` | The request was done |
| `400 invalidValue` | A value is missing or malformed, the identifier among them |
| `400 tooMany` | `GET /Users` without a filter |
| `401` | No valid bearer token |
| `404` | No such user, or an unknown resource such as `/Groups` |
| `405` | The method is not supported on that path |
| `409 uniqueness` | Another user holds that `userName`, email, `externalId` or identifier. The message names which |
| `409`, without a `scimType` | Other requests changed the same user at the same moment. Send the request again |
| `413` | The request body is too large |
| `500` | Storage failed. Send the request again |

A `PUT` or `PATCH` that changes no stored value writes nothing and answers with the user as
stored, so its version and `lastModified` stay as they were.

<Aside type="note" title="A SCIM client other than Entra ID">
Any SCIM 2.0 client that can send the identifier attribute can use the server. We have tried
only Entra ID.
</Aside>

## What the server records

- **In the audit log**, when you record them: each user created, changed or deleted, and a
  request with a wrong token, at most once every 10 minutes. Reads are not recorded. See
  [audit log](../audit-log/).
- **In its technical log**: the method, the kind of path, the status and a fixed reason. Never a
  user name, an email address, an identifier or the token.

## Related

- [Provision users from Entra ID](../entra-provisioning/)
- [Audit log](../audit-log/)
- [Security](../security/)

---

A problem or a question? Write to [support@oktul.com](mailto:support@oktul.com) or open a request in the [Help Center](https://support.oktul.com).
