> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiveth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# User sync (SCIM)

> Let your directory, such as Okta or Microsoft Entra ID, add, update and remove people in Aiveth on its own with SCIM 2.0.

User sync connects your organization's directory to Aiveth with SCIM 2.0 (RFC 7643 and RFC 7644). When IT adds someone in Okta, Microsoft Entra ID, JumpCloud or OneLogin, they appear in Aiveth. When IT removes or deactivates them, their access ends at once.

> [!NOTE]
>
> User sync is available on the Business plan and above.

## Connect your directory

**1. Open User sync**

In the console, go to **Security** → **User sync**. Seeing this needs the **Manage sign-in security** power.

**2. Make a token**

Only an Owner can make the token. Copy it right away: it won't be shown again.

**3. Configure your directory**

Paste the **Address** and the token into your directory's SCIM app. The address is your Aiveth address followed by `/scim/v2`, for example `https://accounts.aiveth.com/scim/v2`. The directory sends the token as `Authorization: Bearer <token>`.

> [!WARNING]
>
> The token can add and remove people. Treat it as an admin secret. Making a new token stops the old one at once. **Turn off** stops the sync.

Aiveth keeps only a hash of the token. Every change the directory makes appears in the activity log as done by "Your organization's directory".

## What each push does

| Directory action | Result in Aiveth |
| - | - |
| Create a user | A new account with your [default role](https://docs.aiveth.com/access/roles-and-permissions.md#the-default-role) and no password. People sign in with your [single sign-on](https://docs.aiveth.com/sign-in/single-sign-on.md), or set a password with "Forgot password". |
| Set `active: false` | The person is suspended and every session ends at once. |
| Set `active: true` | The person is restored, if the directory suspended them. |
| Change the email | The address changes. The new address counts as unproven, and the person's reset links and sessions end. The old address is emailed. |
| Delete a user | The person is removed. Their records are kept for the activity log. |

A person's SCIM `id` is their Aiveth user id. Aiveth reads `userName`, `name.givenName`, `name.familyName`, the primary email in `emails`, `externalId` and `active`.

If the directory creates someone whose email is already in your organization, Aiveth answers `409` with `uniqueness`. Okta and Entra then look the person up by `userName` and link them. If the directory itself removed that person earlier, they come back instead.

## Endpoints

| Method and path | Use |
| - | - |
| `GET /scim/v2/ServiceProviderConfig`, `/ResourceTypes`, `/Schemas` | Discovery |
| `GET /scim/v2/Users?filter=userName eq "a@example.com"&startIndex=1&count=100` | Find users |
| `POST /scim/v2/Users` | Create |
| `GET /scim/v2/Users/{id}` | Read |
| `PUT /scim/v2/Users/{id}` | Replace (Okta) |
| `PATCH /scim/v2/Users/{id}` | Update (Entra, and Okta's deactivate) |
| `DELETE /scim/v2/Users/{id}` | Remove |
| `GET`, `POST /scim/v2/Groups` and `GET`, `PUT`, `PATCH`, `DELETE /scim/v2/Groups/{id}` | Groups |

Filters support `attribute eq "value"` on `userName`, `externalId`, `emails.value` and `id`. Every answer is `application/scim+json`, and every refusal uses the SCIM error shape. Aiveth reads Okta's and Entra's different PATCH styles the same way.

Each organization can make up to 3,000 SCIM requests a minute.

## Groups and roles

Groups your directory pushes become groups in Aiveth. They show under **Groups** marked **From your directory**. Only the directory changes their name and members. A name already used by a group made in Aiveth is refused with `409`.

Your apps receive these group names in the `groups` claim (see [Roles and permissions](https://docs.aiveth.com/access/roles-and-permissions.md#what-your-apps-receive)).

### Roles from groups

Under **Roles from groups**, an Owner can set "this group gives this role". Once at least one rule exists:

* Every person the directory manages gets the strongest role among their groups' rules, or the default role when none applies.
* Joining or leaving a group in the directory changes the role.
* The strongest role is one with an admin power first, then the one with more powers.
* People added in Aiveth itself, and Owners, are never changed by these rules.

## What the directory is never allowed to do

* **Give the Owner role.** A group can give any role except Owner, and a new person always starts with the default role, never an admin role.
* **Suspend the last Owner.** An organization always keeps one active Owner.
* **Change the email of an Owner or an admin.** A new address plus "Forgot password" would hand over the account. Change it in Aiveth instead.
* **Bring back someone an admin removed or suspended in Aiveth.** Only the directory undoes what the directory did. A person an admin suspended stays suspended, whatever `active: true` the directory sends.
* **Restore someone's old admin role.** A person the directory brings back gets the default role again, not the role they held before.

## Errors

| Status | SCIM type | Example |
| - | - | - |
| 400 | `invalidFilter` | Only 'attribute eq "value"' filters are supported |
| 400 | `invalidValue` | userName or a primary email must be an email address |
| 403 | `mutability` | Your directory can't change the email of an Owner or an admin. Change it in Aiveth. |
| 409 | `uniqueness` | A user with this userName already exists |
| 409 | `uniqueness` | This person was removed in Aiveth by an admin. Ask an admin to restore them first. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.