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

# Use a custom connector as an upstream directory

> Connect an HR system or identity provider that Opal doesn't integrate with, by serving a small read-only API.

If Opal doesn't have a built-in integration for your HR system or identity provider, you can connect it as an [upstream directory](https://docs.opal.dev/docs/add-your-first-idphr-provider.md) through a custom connector. Opal then reads your users from it and uses their status, manager and attributes to drive user lifecycle, manager approvals and attribute-based tags, the same way it uses Okta or Workday.

You build a small, read-only API in front of your system. Opal calls it; your system never needs to call Opal. You can serve it in one of two formats:

* **Opal's custom connector API.** Three read-only endpoints, described below.
* **SCIM 2.0.** If your system already serves SCIM 2.0 users, Opal can read it directly, as described at the end of this page.

## What to build

| Endpoint | Required | When Opal calls it |
| - | - | - |
| [`GET /status`](https://docs.opal.dev/docs/api-spec#get-%2Fstatus) | Yes | When you add the app, to check the connection. Return 200; no body is needed. |
| [`GET /users`](https://docs.opal.dev/docs/api-spec#get-%2Fusers) | Yes | Every hour, page by page, to read every user. |
| [`GET /users/{user_id}`](https://docs.opal.dev/docs/api-spec#get-%2Fusers%2F%7Buser-id%7D) | Recommended | To refresh one user as soon as Opal learns they changed. Needed for [faster updates](#faster-updates). |

Every request carries an `X-Opal-Signature` header. Verify it with the signing secret you set when you add the app. See [Signature](https://docs.opal.dev/docs/api-spec.md#signature).

You don't need any other endpoint in the spec. An app added as an upstream directory has no groups, resources or event ingestion, and Opal never writes to your system, so it doesn't call the `/groups`, `/resources` or `/events` endpoints or any `POST`, `PUT` or `DELETE` endpoint.

## What `GET /users` must return

* **Every user, on every sync.** Include suspended and terminated users with their current `status`. Opal treats a user who is missing from the response as removed from your system and offboards them.
* **A stable `id`.** Use an ID that stays the same for the user's lifetime, and use the same ID in `GET /users/{user_id}`.
* **An `email`.** Opal matches users by email. A user without one can't be linked to an Opal user.
* **A `status`** of `ACTIVE`, `SUSPENDED`, `DEPROVISIONED` or `DELETED`. Any other value fails the sync. Omit it to give no opinion on status.
* **A `manager_email`**, not a manager ID. If your system stores a manager's ID, look up the manager's email before you return the user.
* **Pages** linked by `next_cursor`. An empty `next_cursor` ends the sync.

Put standard profile fields in `attributes`: `first_name`, `last_name`, `title`, `team`, `profile_url` and `secondary_emails`. Put anything else, such as location, employee type or hire date, in `custom_attributes` as a map from name to an array of strings. Opal admins can map those keys to tags, team or email.

```json theme={null}
{
  "next_cursor": "",
  "users": [
    {
      "id": "6bac7de4-08d7-4437-8397-75f44b6f76ae",
      "email": "jordan.hayes@example.com",
      "status": "ACTIVE",
      "manager_email": "sam.rivera@example.com",
      "attributes": {
        "first_name": "Jordan",
        "last_name": "Hayes",
        "title": "Software Engineer",
        "team": "Platform"
      },
      "custom_attributes": {
        "work_location": ["Remote"],
        "employee_type": ["Full-time"]
      }
    }
  ]
}
```

## Safeguard against mass offboarding

Opal holds back a sync that would offboard an unusually large share of the users your connector supplies, and shows a sync error on the connection instead. A failed or empty response never offboards anyone. Opal checks again at the next hourly sync.

## Faster updates

The hourly sync is enough on its own. To get new and changed users into Opal within minutes, add one or both of these. Both need `GET /users/{user_id}`, and neither offboards anyone: terminations always apply at the next hourly sync.

* **Support `updated_since` on `GET /users`.** Opal polls for users changed since its last check every few minutes. Opal detects whether your connector supports the filter, so you don't need to configure anything.
* **Push changes to Opal over SCIM.** Your system calls Opal's SCIM endpoint when a user changes, and Opal re-reads that user.

Both are described in [Near-real-time updates](https://docs.opal.dev/docs/api-spec.md#near-real-time-updates).

## If your system already serves SCIM 2.0

When you add the app, set **Directory Protocol** to **SCIM 2.0** and set **Base URL** to your SCIM base URL. Opal then sends the signing secret as a bearer token instead of signing requests, and reads:

* `GET /Users`, paged with `startIndex` and `count`, for the hourly sync.
* `GET /Users/{id}` to refresh one user.
* `GET /Users?filter=meta.lastModified ge "<timestamp>"` for faster updates, if your server supports the filter.

Opal maps `active` to `ACTIVE` or `DEPROVISIONED`, reads name, title and emails from the core schema, reads department and manager from the enterprise extension, and keeps `employeeNumber`, `costCenter`, `organization`, `division`, `department` and `userType` as custom attributes.

## Add the app in Opal

1. Go to the **Inventory** page and select **+ App**.
2. Select the **Custom HRIS / IdP** tile.
3. Fill in **Identifier**, **Base URL** and **Signing Secret**. See [Create a custom app](https://docs.opal.dev/docs/how-to-create-your-own-connector.md#4-create-a-custom-app) for what each field means.
4. Select the **Directory Protocol**: **Opal custom connector API** or **SCIM 2.0**.
5. Create the app. Opal checks the connection, then connects the app as an upstream directory.

The new directory appears under **Configuration** > **Identities**, where you can set its attribute priority against your other directories. See [Add additional IDP/HR providers](https://docs.opal.dev/docs/add-additional-idphr-providers.md).


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