> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# SCIM

## Overview

Edupass will use the [System for Cross-domain Identity Management (SCIM) 2.0 protocol](https://datatracker.ietf.org/doc/html/rfc7644) to provide live user information updates to RPs that require it. Edupass will be the SCIM client, and **RPs will be the SCIM Service Provider** (or Server). **RPs will need to implement the SCIM endpoints listed below, and expose them for access by Edupass**.

Edupass identities which should have access to the RP application will be sent as SCIM User resources.

Application roles managed by Edupass will be encoded as SCIM Group resources.

### Required SCIM Endpoints for All RPs

RPs will need to implement **all** the following endpoints:

- [User Operations](#user-operations)
  - Create User: For RPs to be informed of new Edupass identities that should have access to the RP
  - Update User: To update details for an existing identity. RPs should support both `PUT` and `PATCH` updates.
  - Delete User: To remove access for a specific identity. RPs may remove the User resource entirely or do a soft delete.
  - Read Users
    - Get all Users: Return a paginated list of all User resources within the RP. In addition, it should be possible to retrieve a User with a given `userName`.
    - Get by ID: Return a specific user resource with the RP provided user identifier: `id`
- SCIM discovery Endpoints
  - [Service Provider Configuration Endpoint](#service-provider-configuration-endpoint)
  - [Get All Schemas Endpoint](#get-all-schemas-endpoint)
  - [Get All Resource Types Endpoint](#get-all-resource-types-endpoint)

### Required SCIM Endpoints for RPs with Roles Managed by Edupass

Additionally, RPs with roles managed by Edupass should implement **all** the Group operation endpoints below. This includes RPs who manage roles internally but have location-specific application access roles.

- [Group Operations](#group-operations)
  - Create Group: To create a new Group, which is used to encode application roles.
  - Update Group: To update Group details or membership. Will be used to update a user’s application permissions by adding the user to a Group representing a role. Only `PATCH` updates need to be supported.
  - Delete Group: To remove a specific Group
  - Read Groups
    - Get all Groups: Return a paginated list of all groups created within the RP. In addition, it should be possible to retrieve a Group with a given `displayName`
    - Get by ID: Return a specific Group with the RP provided identifier: `id`

## Overview of SCIM Endpoint Invocation Workflow by Edupass

![SCIM interactions between Edupass and RPs](/static/svg/scim-rp-interactions.drawio.5707c94ba9.svg)

#### Provisioning Group for Application Role

Groups are created in Edupass based on application roles defined by the RP. For each location-scoped role, a Group will be created for the role in each applicable location. For example a Group will be created to encode the application role `1730_APP_admin`, which is the application’s admin role at the school with location code 1730.

When MOE registers a new school or branch, Edupass automatically creates Groups for all application roles that are applicable to the school or branch.

RPs will be informed of new Groups created in Edupass for the RP via the following workflow:

1. Create Group (POST /Groups)

#### Provisioning Access for New Identities

RPs will be informed of new Edupass identities and their application role assignments for the RP via the following workflow:

1. Create User (POST /Users)
2. Update Group Membership (PATCH /Groups/\<RP group id> for each RP application role that the user is assigned)

![Provisioning access for new identities](/static/svg/scim-provision-new-identity.drawio.a1d649ef27.svg)

#### Updating Profile for Existing Identities

RPs will be notified of changes to the attributes of Edupass identities which have access to the RP via the following workflow:

1. Update User (PATCH /Users/\<RP user id> or PUT /Users/\<RP user id>)

#### Updating Access for Existing Identities

RPs will be notified of changes to application role assignments of Edupass identities known to the RP via the following workflow:

1. Update Group Membership (PATCH /Groups/\<RP group id>)

If an application role has been removed for a user, an `Update Group Membership` request will be sent to **remove** the user from the Group encoding the role.

If an application role has been assigned to a user, an `Update Group Membership` request will be sent to **add** the user to the Group encoding the role.

#### Removing Access for Existing Identities

RPs will be notified of Edupass identities whose access to the RP should be removed via the following workflow:

1. Delete User (DELETE /Users/\<RP user id>)

This happens when the person’s access to the RP has been completely removed through the Edupass access management portal.

#### Removing Group for Deprecated Application Role

Application roles will only be deprecated under 2 circumstances:

1. The RP raises a request to remove the role
2. MOE closes a school. The location-scoped roles for the closed school will eventually be removed.

Groups associated with deprecated application roles will be deleted. RPs will be informed of Groups to be removed via the following workflow:

1. Delete Group (DELETE /Groups/\<RP group id>)

## SCIM Security Requirements

### TLS Support Requirements

RPs must support [TLS 1.2](https://datatracker.ietf.org/doc/html/rfc5246).

### Securing SCIM Endpoints

Edupass will identify itself via a short-lived signed bearer token signed by Edupass, which is a [JSON Web Token (JWT)](https://datatracker.ietf.org/doc/html/rfc7519), in the request `Authorization` header. RPs will need to validate the token by doing the following:

1. Verify that the signature is valid.
2. Check that the following fields are valid
   1. `iss`: Identifies the token issuer, this should match the value that Edupass uses to identify itself. This will be Edupass' API domain name
      1. In the Edupass preprod environment: [https://api.preprod.edupass.moe.gov.sg](https://api.preprod.edupass.moe.gov.sg/)
      2. In the Edupass production environment: [https://api.edupass.moe.gov.sg](https://api.edupass.moe.gov.sg/)
   2. `aud`: The RP’s application code in Edupass
   3. `exp`: Unix time for when the token expires. Check that the token is not expired yet

RPs hosted on AWS API Gateway or APEX, or RPs that require API keys, should refer to [Authentication for Specific RP Hosting Setups](#authentication-for-specific-rp-hosting-setups).

#### Verifying Edupass JWT Signature

Edupass' signing public key will be published at the JSON Web Key Set (JWKS) endpoint listed below, which returns one or more public keys in JSON Web Key (JWK) format.

| **Environment** | **URL**                                                                                                            |
| --------------- | ------------------------------------------------------------------------------------------------------------------ |
| Preprod         | [https://api.preprod.edupass.moe.gov.sg/.well-known/keys](https://api.preprod.edupass.moe.gov.sg/.well-known/keys) |
| Production      | [https://api.edupass.moe.gov.sg/.well-known/keys](https://api.edupass.moe.gov.sg/.well-known/keys)                 |

The key to be used for signature validation will have `use: "sig"` and a `kid` that matches the Edupass JWT being validated.

Edupass rotates its signing keys. When a rotation occurs, a new key with a different `kid` is added to the JWKS endpoint, and newly issued JWTs will reference this `kid` in their headers. RPs should refresh cached keys by re-fetching the JWKS endpoint whenever they encounter an unknown `kid`.

#### Sample Signed JWT

:::details Encoded JWT

Format: \<base64 url encoded JWT header>.\<base64 url encoded JWT payload>.\<base64 url encoded signature>

```
eyJhbGciOiJFUzI1NiIsImtpZCI6ImVkdXBhc3Mtc2lnLXByZXByb2QtZDk3ZTljMmYtYWZmYi00NWNmLWIwNTAtZjUzZTUwYjcyZWE2In0.eyJpc3MiOiJodHRwczovL2FwaS5wcmVwcm9kLmVkdXBhc3MubW9lLmdvdi5zZyIsImF1ZCI6InRlc3RBcHAiLCJpYXQiOjE3ODcwNTUwOTcsImV4cCI6MTc4NzA1NTY5N30.Gcn3io5_tVIHbPksm4QB61RbtXiOntfyf9XL9x9QniA-Qe-blOCekXIGYh4IcIlcwGPNQc0OlSeRR5Cqhs5zlQ
```

:::

:::details Decoded JWT Header and Payload

**JWT Header**

```
{
  "alg": "ES256",
  "kid": "edupass-sig-preprod-d97e9c2f-affb-45cf-b050-f53e50b72ea6"
}
```

| **Field** | **Type** | **Description**                                             |
| --------- | -------- | ----------------------------------------------------------- |
| alg       | String   | The algorithm used to sign the JWT                          |
| kid       | String   | Key ID from the JWKS endpoint that was used to sign the JWT |

**JWT Payload**

```
{
  "iss": "https://api.preprod.edupass.moe.gov.sg",
  "aud": "testApp",
  "iat": 1787055097,
  "exp": 1787055697
}
```

| **Field** | **Type** | **Description**                                            |
| --------- | -------- | ---------------------------------------------------------- |
| iss       | String   | Issuer of the JWT. See [`iss` values](#iss-values).        |
| aud       | String   | The RP’s Edupass application code                          |
| iat       | Number   | Unix timestamp in seconds at which the token was generated |
| exp       | Number   | Unix timestamp in seconds at which the token expires       |

###### `iss` values

| **Environment** | **Value**                                                                         |
| --------------- | --------------------------------------------------------------------------------- |
| Preprod         | [https://api.preprod.edupass.moe.gov.sg](https://api.preprod.edupass.moe.gov.sg/) |
| Production      | [https://api.edupass.moe.gov.sg](https://api.edupass.moe.gov.sg/)                 |

:::

:::details Sample return from the JWKS endpoint

```
{
  "keys": [
    {
      "kty": "EC",
      "x": "GhTXpP7iU8oc_GSdhPWyMuL1qql7ldcUqscsTc0JbpE",
      "y": "sywI9QA6Mgb4CJiXUEDofwY9hAsLgrsM0-4n3M5jwLA",
      "crv": "P-256",
      "kid": "edupass-sig-preprod-d97e9c2f-affb-45cf-b050-f53e50b72ea6",
      "alg": "ES256",
      "use": "sig"
    }
  ]
}
```

:::

## Understanding SCIM

### SCIM Resources

Edupass represents identities as SCIM `User` resources, and application roles as SCIM `Group` resources.

In SCIM, `User` and `Group` are SCIM resources that can be created, modified, deleted and retrieved through REST API endpoints.

Each SCIM resource has the following common attributes:

| **Attribute** | **Description**                                                                                                                                                                                                                             |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id            | Unique identifier for the SCIM resource defined by the RP. It must be a stable, non-reassignable identifier that does not change when the same resource is returned in subsequent requests.<br>This can be the same as Edupass' identifier. |
| externalId    | Edupass' identifier for the resource.                                                                                                                                                                                                       |
| meta          | The resource metadata. This is an object with the following sub-attributes<br>See [`meta` sub-attributes](#meta-sub-attributes).                                                                                                            |

###### `meta` sub-attributes

| **Attribute** | **Required?** | **Description**                                                                                                                                                                               |
| ------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| resourceType  | Required      | Resource type of the SCIM resource. Either `User` or `Group`                                                                                                                                  |
| created       | Required      | Timestamp the SCIM resource was created by the RP                                                                                                                                             |
| lastModified  | Required      | Timestamp the SCIM resource was modified by the RP                                                                                                                                            |
| location      | Required      | Location of the SCIM resource.<br>For a `User` resource: `https://{RP base URL for SCIM}/Users/{RP User id}`<br>For a `Group` resource: `https://{RP base URL for SCIM}/Groups/{RP Group id}` |
| version       | Optional      | Must be the same as the ETag in the HTTP response header for the resource if the RP supports it                                                                                               |

### SCIM Endpoint Responses

If a request body is present, SCIM endpoints must return responses with media type `application/scim+json`, which are JSON objects with a `schemas` attribute – a list of [IETF URN](https://www.rfc-editor.org/rfc/rfc7643.html)s under the namespace `urn:ietf:params:scim`.

Each URN identifies a schema that defines the structure of the attributes present in the JSON response.

#### Resource Endpoint Responses

##### Single Resource Response

The response will contain common attributes - `id`, `externalId` and `meta`, and attributes as defined by the schemas in the `schemas` attribute. By default, this should include all attributes with `returned` property set as `always` or `default` in the respective schemas returned by the [Get All Schemas](#get-all-schemas-endpoint) endpoint.

See the table below for the list of possible values for `schemas`.

| **Resource Type** | **Schemas**                                                                                                   | **Description**                                                                     |
| ----------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| User              | \["urn:ietf:params:scim:schemas:core:2.0:User"]                                                               | Response contains attributes in the core User schema                                |
| User              | \["urn:ietf:params:scim:schemas:core:2.0:User",<br>"urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"] | Response contains attributes in the core User schema and the Edupass User extension |
| Group             | \["urn:ietf:params:scim:schemas:core:2.0:Group"]                                                              | Response contains attributes in the Group schema                                    |

##### List Response

All list responses will have the following attributes:

| **Attribute**  | **Required?**                                                | **Description**                                                                                                                                                                                            |
| -------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schemas`      | Required                                                     | The value must be `["urn:ietf:params:scim:api:messages:2.0:ListResponse"]`                                                                                                                                 |
| `totalResults` | Required                                                     | Integer, total number of resources                                                                                                                                                                         |
| `startIndex`   | Required when partial results are returned due to pagination | Integer, 1-based index of first result in the current set of results.<br>If there are 50 resources, and `itemsPerPage` is 25, `startIndex: 26` means the second page (the next 25) of results is returned. |
| `itemsPerPage` | Required when partial results are returned due to pagination | Integer, number of SCIM resources returned in a list                                                                                                                                                       |
| `Resources`    | Required                                                     | Array of SCIM User or Group resource objects, with attributes as defined by the schemas in the `schemas` attribute, like in the case of a single resource response.                                        |

#### Error Responses

##### HTTP Error Status Codes

RPs should conform to the following HTTP status code convention for error returns.

| Status Code | Applicability                 | Description                                                                                                            |
| ----------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| 400         | GET, POST, PUT, PATCH, DELETE | **Bad Request**. The request is unparsable, syntactically incorrect, or violates the schema.                           |
| 401         | GET, POST, PUT, PATCH, DELETE | **Unauthorized**. The authorization header is missing or invalid.                                                      |
| 403         | GET, POST, PUT, PATCH, DELETE | **Forbidden**. The operation is not permitted based on the authorization provided.                                     |
| 404         | GET, POST, PUT, PATCH, DELETE | **Not Found**. The specified resource or endpoint does not exist. For example if a PUT is made to a non-existent User. |
| 409         | POST, PUT, PATCH, DELETE      | **Conflict**. The version number is mismatched, or the server refused to create a duplicate resource.                  |
| 429         | All Methods                   | **Too Many Requests**. API rate limits reached.                                                                        |
| 500         | All Methods                   | **Internal Server Error**. An unexpected internal error occurred.                                                      |
| 501         | All Methods                   | **Not Implemented**. The provider does not support the requested operation.                                            |

##### HTTP Error Response Body

If present, the response body should have the following attributes:

| **Attribute** | **Required?**                          | **Description**                                                    |
| ------------- | -------------------------------------- | ------------------------------------------------------------------ |
| status        | Required                               | The HTTP status code expressed as a JSON string                    |
| schemas       | Required                               | MUST contain the URI `urn:ietf:params:scim:api:messages:2.0:Error` |
| scimType      | Required for HTTP status 400 responses | See [`scimType` values](#scimtype-values).                         |
| detail        | Optional                               | A detailed, human-readable message explaining the error.           |

###### `scimType` values

| **Value**     | **Description**                                                                                                                 | **Applicability**              |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| tooMany       | The specified filter yields many more results than the server is willing to calculate or process.                               | Get All Users, Get All Groups  |
| uniqueness    | The resource being created already exists                                                                                       | Create User, Create Group      |
| invalidSyntax | The request body message structure was invalid or did not conform to the request schema.                                        | POST, PUT requests             |
| invalidFilter | The specified filter attribute and comparison combination is not supported.                                                     | GET `/Users`, GET `/Groups`    |
| invalidPath   | The "path" attribute was invalid or malformed.                                                                                  | PATCH requests                 |
| invalidValue  | A required value was missing, or the value specified was not compatible with the operation, attribute type, or resource schema. | GET, POST, PUT, PATCH requests |
| noTarget      | The specified "path" did not yield an attribute or value that could be operated on (e.g., a path filter yielded no match).      | PATCH requests                 |

## SCIM Resource Endpoints

### User Operations

#### User Schema

| **Attribute**                                             | **Required?** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `externalId`                                              | Required      | Edupass Identifier                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `userName`                                                | Required      | This will be the Edupass identifier.<br>(This is a compulsory field according to the SCIM RFC that uniquely identifies the User resource within the RP.)                                                                                                                                                                                                                                                                             |
| `id`                                                      | Required      | RP’s identifier for the User resource that will be used to retrieve the resource stored by the RP. This can be the Edupass identifier.<br>Edupass should be able to send HTTP GET/PUT/PATCH/DELETE requests for the resource at `https://{RP base URL for SCIM}/Users/{id}`.                                                                                                                                                         |
| `name`                                                    | Optional      | While SCIM’s `name` object defines other name components like `familyName`, `givenName` and `honorificPrefix`, Edupass will not be including these fields.<br>See [`name` sub-attributes](#name-sub-attributes).                                                                                                                                                                                                                     |
| `emails`                                                  | Optional      | Array of email objects.<br>**Email object:**<br>See [`emails` sub-attributes](#emails-sub-attributes).                                                                                                                                                                                                                                                                                                                               |
| `title`                                                   | Optional      | The job title of the user associated with the Edupass identity                                                                                                                                                                                                                                                                                                                                                                       |
| `urn:ietf:params:scim:schemas:extension:Edupass:2.0:User` | Optional      | Edupass user schema extension for additional user attributes in the [Edupass User Schema](/specs/index.md#user-schema)<br>For RPs who do not store `uinFin`, the `uinFin` can be omitted if indicated at onboarding and in the [Get Schemas](#get-all-schemas-endpoint) endpoint.<br>See [`urn:ietf:params:scim:schemas:extension:Edupass:2.0:User` sub-attributes](#urnietfparamsscimschemasextensionedupass20user-sub-attributes). |

###### `name` sub-attributes

| **Attribute** | **Description**                                       |
| ------------- | ----------------------------------------------------- |
| formatted     | Name of the user associated with the Edupass identity |

###### `emails` sub-attributes

| **Attribute** | **Description**                                  |
| ------------- | ------------------------------------------------ |
| type          | One of `WOG`, `CES`, `ICON`, `OTHER`             |
| value         | Email address                                    |
| primary       | `true` for notification email, `false` otherwise |

###### `urn:ietf:params:scim:schemas:extension:Edupass:2.0:User` sub-attributes

| **Attribute**  | **Required?** | **Description**                                                                                                                                               |
| -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| identityType   | Optional      | IdentityType associated with the Edupass identity                                                                                                             |
| uinFin         | Optional      | The Unique Identification Number (UIN) / Foreign Identification Number (FIN) associated with the Edupass identity<br>uinFin is null for Non-human identities. |
| schoolOrHq     | Optional      | Either School or HQ. Null for Non-human identities                                                                                                            |
| identitySource | Optional      | The source of this identity’s core information (e.g. Name, UIN/FIN, Job Title)                                                                                |

RPs can indicate which fields in the core user schema and Edupass User extension they require through their [Get All Schemas](#get-all-schemas-endpoint) endpoint.

##### Groups Attribute

For RPs with roles managed by Edupass, the `groups` attribute should be part of the SCIM Core User Schema with `returned` property set as `default`. Hence User operations (_Create User_, _Update User - PUT_, _Get All Users_, _Get User By ID_) should include the `groups` attribute for each User resource in the response.

#### Create User

RPs will be informed of new Edupass identities that should have access to the RP via this endpoint.

RPs should check that the given identity does not already exist within the RP’s **active** User resources. If there are conflicts, the RP should respond with HTTP status 409 with `scimType` error code `uniqueness`. Conflicts should not happen with deleted User resources.

##### Request

_POST /Users_

:::details Request Body - All fields in the User Schema table supported by the RP, excluding id

```json
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "externalId": "000012345678",
  "userName": "000012345678",
  "emails": [
    {
      "primary": true,
      "type": "WOG",
      "value": "john_tan@moe.gov.sg"
    },
    {
      "primary": false,
      "type": "ICON",
      "value": "john_tan_xiao_ming@moe.edu.sg"
    }
  ],
  "name": {
    "formatted": "John Tan Xiao Ming"
  },
  "title": "Director",
  "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User": {
    "uinFin": "S1234567A",
    "schoolOrHq": "HQ",
    "identityType": "Staff",
    "identitySource": "HRPS"
  }
}
```

:::

##### Response

:::details Status 201: User resource for Edupass identity is created

In addition to the attributes in the Request SCIM User object, RPs should return the `id` attribute with their identifier for the created user record.

For RPs with roles returned by Edupass, the `groups` attribute should be included.

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "id": "RPUser1", # RP's user identifier
  "externalId": "000012345678",
  "userName": "000012345678",
  "meta": {
    "resourceType": "User",
    "created": "2025-12-01T22:00:25Z",
    "lastModified": "2025-12-01T22:00:25Z",
    "location": "https://example.com/scim/Users/RPUser1"
  },
  "emails": [
    {
      "primary": true,
      "type": "WOG",
      "value": "john_tan@moe.gov.sg"
    },
    {
      "primary": false,
      "type": "ICON",
      "value": "john_tan_xiao_ming@moe.edu.sg"
    }
  ],
  "groups": [],
  "name": {
    "formatted": "John Tan Xiao Ming"
  },
  "title": "Director",
  "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User": {
    "uinFin": "S1234567A",
    "schoolOrHq": "HQ",
    "identityType": "Staff",
    "identitySource": "HRPS"
  }
}
```

:::

:::details Status 409: User resource for Edupass identity already exists

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:Error"
  ],
  "status": "409",
  "scimType": "uniqueness",
  "detail": "User with the specified userName already exists."
}
```

:::

#### Update User - PUT

This should overwrite all attributes for the associated user resource with the values provided.

##### Request

_PUT /Users/RPUser1_

:::details Request Body - All fields in the User Schema table supported by the RP, excluding id

```json
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "externalId": "000012345678",
  "userName": "000012345678",
  "emails": [
    {
      "primary": true,
      "type": "WOG",
      "value": "john_tan@moe.gov.sg"
    },
    {
      "primary": false,
      "type": "ICON",
      "value": "john_tan_xiao_ming@moe.edu.sg"
    }
  ],
  "name": {
    "formatted": "John Tan Xiao Ming"
  },
  "title": "Principal",
  "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User": {
    "uinFin": "S1234567A",
    "schoolOrHq": "School",
    "identityType": "Staff",
    "identitySource": "HRPS"
  }
}
```

:::

##### Response

:::details Status 200: User resource for Edupass identity updated

For RPs with roles returned by Edupass, the `groups` attribute should be included.

```json
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "id": "RPUser1", # RP's user identifier
  "externalId": "000012345678",
  "userName": "000012345678",
  "emails": [
    {
      "primary": true,
      "type": "WOG",
      "value": "john_tan@moe.gov.sg"
    },
    {
      "primary": false,
      "type": "ICON",
      "value": "john_tan_xiao_ming@moe.edu.sg"
    }
  ],
  "groups": [
    {
      "value": "1001_admin",
      "$ref": "https://example.com/scim/Groups/1001_admin",
      "display": "1001_app1_admin"
    }
  ],
  "meta": {
    "resourceType": "User",
    "created": "2025-12-01T22:00:25Z",
    "lastModified": "2025-12-01T22:00:25Z",
    "location": "https://example.com/scim/Users/RPUser1"
  },
  "name": {
    "formatted": "John Tan Xiao Ming"
  },
  "title": "Principal",
  "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User": {
    "uinFin": "S1234567A",
    "schoolOrHq": "School",
    "identityType": "Staff",
    "identitySource": "HRPS"
  }
}
```

:::

#### Update User - PATCH

A `PATCH` request to /Users/\<id> is used to selectively update attributes of a User resource using “add”, “remove” or “replace” operations.

##### Patch Request Body Schema

| **Attribute** | **Description**                                                                                                                                                                                                                               |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schemas`     | The value must be `["urn:ietf:params:scim:api:messages:2.0:PatchOp"]`                                                                                                                                                                         |
| `Operations`  | Array of Operations to be performed. Contains at least 1 Operation object. All operations within the same PATCH request must be treated as atomic.<br>**Operation object:**<br>See [`Operations` sub-attributes](#operations-sub-attributes). |

###### `Operations` sub-attributes

| **Attribute** | **Description**                                                                                                                                                                                                               |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| op            | Enum: `add`, `remove`, `replace`                                                                                                                                                                                              |
| path          | Attribute path in SCIM user schema.<br>Examples:<br>- title<br>- name.formatted<br>- [SCIM ABNF rules](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) for path matching. For example: `emails[type eq "WOG"]` |
| value         | Value to be added or replaced with. Omitted for `remove` operations                                                                                                                                                           |

##### Request

The following example updates the associated User resource’s title.

_PATCH_ _/Users/RPUser1_

:::details Request Body

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "replace",
      "path": "title",
      "value": "Principal"
    }
  ]
}
```

:::

##### Response

:::details Status 200: User resource for Edupass identity updated

Returned user schema object should minimally contain the mandatory SCIM user fields and updated values of the User record

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "id": "RPUser1", # RP's user identifier
  "externalId": "000012345678",
  "userName": "000012345678",
  "title": "Principal",
  "meta": {
    "resourceType": "User",
    "created": "2025-12-01T22:00:25Z",
    "lastModified": "2025-12-01T22:00:25Z",
    "location": "https://example.com/scim/Users/RPUser1"
  }
}
```

:::

#### Delete User

Edupass identities that should be removed will be deleted via a DELETE request to /Users/\<id>. RP should remove the associated user resource.

##### Request

_DELETE /Users/RPUser1_

##### Response

Status 204: User resource for Edupass identity deleted.

#### Get All Users

This should return a paginated list of User resources created from Edupass identities. Each request may include the following parameters for pagination:

| Parameter  | Description                                                                                                                                                                                                                                                                       |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| count      | A non-negative integer specifying the **maximum number of results** desired per page (e.g., 10). A negative value is interpreted as "0". If unspecified, the RP determines the maximum number of results that it can support.                                                     |
| startIndex | Defaults to 1 if not specified in the request.<br>The **1-based index** of the first query result to be returned. Any value provided that is less than 1 is interpreted as 1.<br>If there are 50 resources, and `count` is 25, `startIndex: 26` means return the next 25 results. |

##### Response Body Schema

| **Attribute**  | **Description**                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schemas`      | The value must be `["urn:ietf:params:scim:api:messages:2.0:ListResponse"]`                                                                                                                                                                                                                                                                                                                                      |
| `totalResults` | Integer, total number of resources                                                                                                                                                                                                                                                                                                                                                                              |
| `startIndex`   | Integer, 1-based index of first result in the current set of results.                                                                                                                                                                                                                                                                                                                                           |
| `itemsPerPage` | Integer, number of User resources returned in a list                                                                                                                                                                                                                                                                                                                                                            |
| `Resources`    | Array of SCIM User objects.<br>This should match the User schema supported by the RP. For RPs using the Edupass user schema extension, this should include the supported fields in the schema extension.<br>For all RPs with roles managed by Edupass, the list of Groups the user belongs to should be returned under the `groups` attribute. This should be omitted for RPs without roles managed by Edupass. |

##### Request

_GET /Users_

##### Response

:::details Status 200: List of User Resources

```
{
  "totalResults": 2,
  "startIndex": 1,
  "itemsPerPage": 50,
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
      ],
      "id": "RPUser1",
      "externalId": "000012345678",
      "userName": "000012345678",
      "emails": [
        {
          "primary": true,
          "type": "WOG",
          "value": "john_tan@moe.gov.sg"
        },
        {
          "primary": false,
          "type": "ICON",
          "value": "john_tan_xiao_ming@moe.edu.sg"
        }
      ],
      "groups": [
        {
          "value": "1001_admin",
          "$ref": "https://example.com/scim/Groups/1001_admin",
          "display": "1001_app1_admin"
        }
      ],
      "meta": {
        "resourceType": "User",
        "created": "2025-12-01T22:00:25Z",
        "lastModified": "2025-12-01T22:00:25Z",
        "location": "https://example.com/scim/Users/RPUser1"
      },
      "name": {
        "formatted": "John Tan Xiao Ming"
      }
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
      ],
      "id": "RPUser2",
      "externalId": "000012345679",
      "userName": "000012345679",
      "emails": [
        {
          "primary": true,
          "type": "CES",
          "value": "muhammad_ali@schools.gov.sg"
        },
        {
          "primary": false,
          "type": "ICON",
          "value": "muhammad_ali@moe.edu.sg"
        }
      ],
      "groups": [],
      "meta": {
        "resourceType": "User",
        "created": "2025-12-01T22:00:25Z",
        "lastModified": "2025-12-01T22:00:25Z",
        "location": "https://example.com/scim/Users/RPUser2"
      },
      "name": {
        "formatted": "Muhammad Ali"
      }
    }
  ]
}
```

:::

#### Get User by userName

To allow Edupass to retrieve the `id` of a User resource that had already been created, RPs should implement the [filter](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) on `userName` to allow Edupass to retrieve a User resource by username.

Such queries will be sent as the `filter` query param in the form `userName eq "value"`.

##### Request

_GET /Users?filter=userName eq "000012345678"_

##### Response

Return a `ListResponse` with `Resources` containing the SCIM User resource with the given `userName`. `Resources` will be an empty list if there are no matching resources.

:::details Status 200: List containing matching User resource

```
{
  "totalResults": 1,
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
      ],
      "id": "RPUser1",
      "externalId": "000012345678",
      "userName": "000012345678",
      "emails": [
        {
          "primary": true,
          "type": "WOG",
          "value": "john_tan@moe.gov.sg"
        },
        {
          "primary": false,
          "type": "ICON",
          "value": "john_tan_xiao_ming@moe.edu.sg"
        }
      ],
      "groups": [
        {
          "value": "1001_admin",
          "$ref": "https://example.com/scim/Groups/1001_admin",
          "display": "1001_app1_admin"
        }
      ],
      "meta": {
        "resourceType": "User",
        "created": "2025-12-01T22:00:25Z",
        "lastModified": "2025-12-01T22:00:25Z",
        "location": "https://example.com/scim/Users/RPUser1"
      },
      "name": {
        "formatted": "John Tan Xiao Ming"
      }
    }
  ]
}
```

:::

#### Get User by ID

This should return the User resource with the given `id`. The format of the SCIM User resource should match those returned in [Get all Users](#get-all-users)

##### Request

_GET /Users/RPUser1_

##### Response

:::details Status 200: User resource for Edupass identity found

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User",
    "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User"
  ],
  "id": "RPUser1", # RP's user identifier
  "externalId": "000012345678",
  "userName": "000012345678",
  "emails": [
    {
      "primary": true,
      "type": "WOG",
      "value": "john_tan@moe.gov.sg"
    },
    {
      "primary": false,
      "type": "ICON",
      "value": "john_tan_xiao_ming@moe.edu.sg"
    }
  ],
  "groups": [
    {
      "value": "1001_admin",
      "$ref": "https://example.com/scim/Groups/1001_admin",
      "display": "1001_app1_admin"
    }
  ],
  "meta": {
    "resourceType": "User",
    "created": "2025-12-01T22:00:25Z",
    "lastModified": "2025-12-01T22:00:25Z",
    "location": "https://example.com/scim/Users/RPUser1"
  },
  "name": {
    "formatted": "John Tan Xiao Ming"
  },
  "title": "Principal",
  "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User": {
    "uinFin": "S1234567A",
    "schoolOrHq": "School",
    "identityType": "Staff",
    "identitySource": "HRPS"
  }
}
```

:::

### Group Operations

#### Group Schema

| **Attribute** | **Description**                                                                                                                                                                                                                                                                 |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `externalId`  | Edupass Identifier for the Group encoding the application role                                                                                                                                                                                                                  |
| `id`          | RP’s identifier for the Group resource that will be used to retrieve the Group resource stored by the RP. This can be the Edupass identifier.<br>Edupass should be able to send HTTP GET/PATCH/DELETE requests for the resource at `https://{RP base URL for SCIM}/Groups/{id}` |
| `displayName` | Application role in the format `<location code>_<app code>_<role code>`, as described in [Interface Specifications](/specs/index.md#application-roles)                                                                                                                          |

##### Members Attribute

The `members` attribute is a SCIM Core Group Schema attribute with `returned` property set as `default`. Hence, Group operations (_Create Group_, _Get All Groups_, _Get Group By ID_) that return SCIM Group resource(s), should include the `members` attribute for each Group resource in the response. However, as each Group can have many members, RPs should implement the [excludedAttributes](https://datatracker.ietf.org/doc/html/rfc7644#section-3.9) query parameter for GET operations, so that the query parameter `excludedAttributes=members` excludes the `members` attribute from the response.

#### Create Group

RPs will be notified via this endpoint when a new Group encoding an application role for the RP is created in Edupass.

Like for the [Create User](#create-user) endpoint, the RP should check if a Group with the same `displayName` already exists. If it exists, it should return http 409 (Conflict) with `scimType` error code `uniqueness`.

##### Request

_POST /Groups_

:::details Request Body - All fields in the Group Schema table, excluding id

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:Group"
  ],
  "displayName": "1001_app1_admin",
  "externalId": "1001_app1_admin"
}
```

:::

##### Response

:::details Status 201: Group created

In addition to the attributes in the Request SCIM Group object, RPs should return the `id` attribute with their identifier for the created Group

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:Group"
  ],
  "id": "1001_admin", # RP's Group identifier, can be any value that's unique for the RP to the created Group object
  "displayName": "1001_app1_admin",
  "members": [],
  "externalId": "1001_app1_admin",
  "meta": {
    "resourceType": "Group",
    "location": "https://example.com/scim/Groups/1001_admin",
    "created": "2025-12-15T22:24:54Z",
    "lastModified": "2025-12-15T22:24:54Z"
  }
}
```

:::

:::details Status 409: Group already exists

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:Error"
  ],
  "status": "409",
  "scimType": "uniqueness",
  "detail": "Group with the specified displayName already exists."
}
```

:::

#### Update Group Membership

Changes to a user’s assigned application role are applied through changes in Group membership. RPs are notified of the change through a HTTP `PATCH` request to the `Update Group Membership` endpoint for the relevant Group at `/Groups/<Group id>`. `PATCH` request body is the same as in [Update User - Patch](#patch-request-body-schema).

Users are added to a Group via a `PATCH` request with an **add** operation. This will add the associated application role to the user. This should succeed with a no-op if the application role has already been assigned to the user.

Users are removed from a Group via a `PATCH` request with a **remove** operation. This will remove the associated application role from the user. This should succeed with a no-op if the application role has already been removed from the user, or if the user never had the application role.

During a full Group membership sync, the list of users in a group may be updated via a `PATCH` request with a **replace** operation.

Each `Update Group Membership` request could contain operations to modify the Group membership status for multiple Users. Each request could contain **add** and **remove** operations for different Users for the same Group. Updates for multiple operations sent in the same PATCH request should be **atomic**, if a single operation encounters an error, the whole request should fail, and no updates in the request should be applied.

##### Request

_PATCH /Groups/1001_admin_

:::details Request Body with add and remove operations

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "add",
      "path": "members",
      "value": [
        {
          "$ref": "https://example.com/scim/Users/RPUser1",
          "value": "RPUser1" # RP's user identifier
        },
         {
          "$ref": "https://example.com/scim/Users/RPUser3",
          "value": "RPUser3" # RP's user identifier
        }
      ]
    },
    {
      "op": "remove",
      "path": "members[value eq \"RPUser2\"]"
    }
  ]
}
```

:::

:::details Request Body with replace operation

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "replace",
      "path": "members",
      "value": [
        {
          "$ref": "https://example.com/scim/Users/RPUser1",
          "value": "RPUser1"
        },
        {
          "$ref": "https://example.com/scim/Users/RPUser2",
          "value": "RPUser2"
        }
      ]
    }
  ]
}
```

:::

##### Response

Status 204: PATCH applied

#### Delete Group

The group associated with an application role that should be removed will be deleted via a DELETE request to /Groups/\<id>. RPs should **delete** the associated Group resource.

RPs should remove the associated application role from all its users.

##### Request

_DELETE /Groups/1001_admin_

##### Response

Status 204: Group deleted

#### Get All Groups

This should return a paginated list of Groups. Pagination works the same way as in [Get all Users](#get-all-users), with optional query parameters `startIndex` and `count`.

##### Response Body Schema

| **Attribute**  | **Description**                                                            |
| -------------- | -------------------------------------------------------------------------- |
| `schemas`      | The value must be `["urn:ietf:params:scim:api:messages:2.0:ListResponse"]` |
| `totalResults` | Integer, total number of resources                                         |
| `startIndex`   | Integer, 1-based index of first result in the current set of results       |
| `itemsPerPage` | Integer, number of Group resources returned in a list                      |
| `Resources`    | Array of SCIM Group objects                                                |

##### Request

_GET /Groups_

##### Response

:::details Status 200: List of Groups

```
{
  "totalResults": 2,
  "startIndex": 1,
  "itemsPerPage": 50,
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group"
      ],
      "id": "1001_admin",
      "displayName": "1001_app1_admin",
      "members": [
        {
          "value": "RPUser1",
          "$ref": "https://example.com/scim/Users/RPUser1"
        }
      ],
      "externalId": "1001_app1_admin",
      "meta": {
        "resourceType": "Group",
        "location": "https://example.com/scim/Groups/1001_admin",
        "created": "2025-12-15T22:24:54Z",
        "lastModified": "2025-12-15T22:24:54Z"
      }
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group"
      ],
      "id": "1001_users",
      "displayName": "1001_app1_users",
      "members": [
        {
          "value": "RPUser2",
          "$ref": "https://example.com/scim/Users/RPUser2"
        }
      ],
      "externalId": "1001_app1_users",
      "meta": {
        "resourceType": "Group",
        "location": "https://example.com/scim/Groups/1001_users",
        "created": "2025-12-15T22:24:54Z",
        "lastModified": "2025-12-15T22:24:54Z"
      }
    }
  ]
}
```

:::

#### Get Group by displayName

To allow Edupass to retrieve the `id` of a Group resource that had already been created, RPs should implement the [filter](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) on `displayName` to allow Edupass to retrieve a Group resource by `displayName`.

Such queries will be sent as the `filter` query param in the form `displayName eq "value"`.

##### Request

_GET /Groups?filter=displayName eq "1001_app1_admin"_

##### Response

Return a `ListResponse` with `Resources` containing the SCIM Group resource with the given `displayName`. `Resources` will be an empty list if there are no matching resources.

:::details Status 200: List containing matching Group resource

```
{
  "totalResults": 1,
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Group"
      ],
      "id": "1001_admin",
      "displayName": "1001_app1_admin",
      "members": [
        {
          "value": "RPUser1",
          "$ref": "https://example.com/scim/Users/RPUser1"
        }
      ],
      "externalId": "1001_app1_admin",
      "meta": {
        "resourceType": "Group",
        "location": "https://example.com/scim/Groups/1001_admin",
        "created": "2025-12-15T22:24:54Z",
        "lastModified": "2025-12-15T22:24:54Z"
      }
    }
  ]
}
```

:::

#### Get Group by ID

This should return the Group with the given `id`. The list of Users belonging to the group should be returned in the `members` attribute.

##### Request

_GET /Groups/1001_admin_

:::details Status 200: Group with given id found

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:Group"
  ],
  "id": "1001_admin",
  "displayName": "1001_app1_admin",
  "members": [
    {
      "value": "RPUser1",
      "$ref": "https://example.com/scim/Users/RPUser1"
    }
  ],
  "externalId": "1001_app1_admin",
  "meta": {
    "resourceType": "Group",
    "location": "https://example.com/scim/Groups/1001_admin",
    "created": "2025-12-15T22:24:54Z",
    "lastModified": "2025-12-15T22:24:54Z"
  }
}
```

:::

## SCIM Discovery Endpoints

The SCIM protocol defines a set of endpoints to facilitate the discovery of SCIM features, resources and specific resource schema attributes supported by the RP.

### Service Provider Configuration Endpoint

This returns the RP's configuration details for the implemented SCIM endpoints.

##### Service Provider Configuration Schema

| **Attribute**           | **Required?** | **Description**                                                                                                                                                                                                                                                                  |
| ----------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `patch`                 | Required      | Specifies `PATCH` configuration options. `PATCH` should be implemented for `/Groups` and `/Users`. This should be an object with the following attributes:<br>See [`patch` sub-attributes](#patch-sub-attributes).                                                               |
| `bulk`                  | Required      | Note: Edupass does **not** use the `/Bulk` endpoint, hence Edupass will not use the value of this field.<br>Specifies `/Bulk` configuration options. This should be an object with the following attributes:<br>See [`bulk` sub-attributes](#bulk-sub-attributes).               |
| `filter`                | Required      | Specifies filter options for GET endpoints. This should be an object with the following attributes:<br>See [`filter` sub-attributes](#filter-sub-attributes).                                                                                                                    |
| `changePassword`        | Required      | Specifies configuration options related to changing a password. Edupass does **not** require this to be supported.                                                                                                                                                               |
| `sort`                  | Required      | Specifies sort configuration options. This should be an object with the following attributes:<br>See [`sort` sub-attributes](#sort-sub-attributes).                                                                                                                              |
| `etag`                  | Required      | Specifies ETag configuration options. This should be an object with the following attributes:<br>See [`etag` sub-attributes](#etag-sub-attributes).                                                                                                                              |
| `authenticationSchemes` | Required      | Specifies supported authentication scheme properties. Edupass requires the `oauthbearertoken` scheme to be supported.<br>This should be a list of objects with the following attributes:<br>See [`authenticationSchemes` sub-attributes](#authenticationschemes-sub-attributes). |
| `documentationUri`      | Optional      | An HTTP-addressable URL pointing to the service provider's human-consumable help documentation.                                                                                                                                                                                  |

###### `patch` sub-attributes

| **Attribute** | **Description**                                                                                                                                     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| supported     | Boolean value specifying whether or not the `PATCH` operation is supported. For RPs with roles managed by Edupass, Edupass expects this to be true. |

###### `bulk` sub-attributes

| **Attribute**  | **Description**                                                                                                                         |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| supported      | Boolean value specifying if the `/Bulk` endpoint is supported by the RP.                                                                |
| maxOperations  | Integer value specifying the maximum number of operations in a single `/Bulk` request.<br>If supported is `false`, this should be 0.    |
| maxPayloadSize | Integer value specifying the maximum payload size in bytes in a single `/Bulk` request.<br>If `supported` is `false`, this should be 0. |

###### `filter` sub-attributes

| **Attribute** | **Description**                                                                                                                                                                                                                                                                                                                                                                               |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| supported     | Boolean value specifying whether or not the `filter` operation is supported for the Users or Groups resource endpoints. This should be true.<br>Note: Edupass does not require the full filter functionality. Edupass only requires support for the `eq` comparison operator, applied to the `userName` attribute of the User resource and the `displayName` attribute of the Group resource. |
| maxResults    | Integer value specifying the maximum number of resources returned in a response                                                                                                                                                                                                                                                                                                               |

###### `sort` sub-attributes

| **Attribute** | **Description**                                                                                                               |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| supported     | Boolean value specifying whether or not the `sort` operation is supported. Edupass does **not** require this to be supported. |

###### `etag` sub-attributes

| **Attribute** | **Description**                                                                                                               |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| supported     | Boolean value specifying whether or not the `ETag` operation is supported. Edupass does **not** require this to be supported. |

###### `authenticationSchemes` sub-attributes

| **Attribute**    | **Required?** | **Description**                                                                      |
| ---------------- | ------------- | ------------------------------------------------------------------------------------ |
| type             | Required      | One of `oauth`, `oauth2`, `oauthbearertoken`, `httpbasic`, and `httpdigest`          |
| name             | Required      | The common authentication scheme name.                                               |
| description      | Required      | Description of the authentication scheme.                                            |
| specUri          | Optional      | An HTTP-addressable URL pointing to the authentication scheme's specification.       |
| documentationUri | Optional      | An HTTP-addressable URL pointing to the authentication scheme's usage documentation. |

##### Request

_GET /ServiceProviderConfig_

##### Response

:::details Status 200

```
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
  ],
  "patch": {
    "supported": true
  },
  "filter": {
    "maxResults": 200,
    "supported": true
  },
  "authenticationSchemes": [
    {
      "name": "OAuth Bearer Token",
      "description": "Authentication scheme using the OAuth Bearer Token Standard",
      "specUri": "http://www.rfc-editor.org/info/rfc6750",
      "type": "oauthbearertoken"
    }
  ],
  "etag": {
    "supported": false
  },
  "sort": {
    "supported": false
  },
  "bulk": {
    "maxPayloadSize": 0,
    "maxOperations": 0,
    "supported": false
  },
  "changePassword": {
    "supported": false
  }
}
```

:::

### Get All Schemas Endpoint

Returns a `ListResponse` with the list of SCIM resource schemas supported by the service provider. This should minimally include the core User schema (`urn:ietf:params:scim:schemas:core:2.0:User`). For RPs that support the `Group` resource, this must include the core Group schema (`urn:ietf:params:scim:schemas:core:2.0:Group`). RPs using Edupass’s User extension schema should also include the Edupass User extension and the set of attributes in the extension that they support.

##### Each Schema has the following attributes

| **Attribute** | **Required?** | **Description**                                                                    |
| ------------- | ------------- | ---------------------------------------------------------------------------------- |
| id            | Required      | The unique URI of the schema (e.g., `urn:ietf:params:scim:schemas:core:2.0:User`). |
| attributes    | Required      | See [`attributes` sub-attributes](#attributes-sub-attributes).                     |
| name          | Optional      | The schema's human-readable name, i.e: "User" or "Group".                          |
| description   | Optional      | A human-readable description of the schema.                                        |

###### `attributes` sub-attributes

| **Attribute**  | **Required?**                                        | **Description**                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name           | Required                                             | The specific name of the attribute.                                                                                                                                                                                                                                                                                                                                                                                     |
| type           | Required                                             | The attribute's data type (e.g., string, complex, boolean, decimal, integer, dateTime, reference).                                                                                                                                                                                                                                                                                                                      |
| multiValued    | Required                                             | Boolean value indicating the attribute's plurality.                                                                                                                                                                                                                                                                                                                                                                     |
| subAttributes  | Required for type `complex`                          | List of nested sub-attributes using this same set of metadata fields.                                                                                                                                                                                                                                                                                                                                                   |
| referenceTypes | Required for attributes that are of type `reference` | Array of strings that indicate the SCIM resource types that are referenced.                                                                                                                                                                                                                                                                                                                                             |
| mutability     | Required                                             | Default value: `readWrite`<br>Keyword indicating the circumstances under which the value of the attribute can be defined or redefined.<br>- `readOnly`: Not modifiable by the SCIM client<br>- `readWrite`: May be read or updated by the SCIM client.<br>- `immutable`: May be defined by the SCIM client at resource creation<br>- `writeOnly`: May be updated by the SCIM client but the attribute is never returned |
| required       | Required                                             | Default value: `false`<br>The attribute must be included in PUT/POST requests.                                                                                                                                                                                                                                                                                                                                          |
| returned       | Required                                             | Default value: `default`<br>Keyword indicating when the attribute is returned in a response to a GET, PUT, POST or PATCH request.<br>- `always`: Always returned<br>- `never`: Never returned<br>- `default`: Returned in all SCIM operation responses where attribute values are returned.<br>- `request`: Only returned if explicitly specified in the request body or `attributes` query parameter                   |
| uniqueness     | Required                                             | Default value: `none`<br>Defines how the RP enforces the uniqueness of the attribute value.<br>- `none`: Not unique<br>- `server`: Unique within the context of the current SCIM endpoint<br>- `global`: Globally unique, no two resources should possess the same attribute.                                                                                                                                           |
| caseExact      | Required for attributes of type `string`             | Whether the attribute is case sensitive.                                                                                                                                                                                                                                                                                                                                                                                |
| description    | Optional                                             | Human-readable description of the specific attribute.                                                                                                                                                                                                                                                                                                                                                                   |

##### Request

GET `/Schemas`

##### Response

###### Core User Schema

Note that the `urn:ietf:params:scim:schemas:core:2.0:User` schema should include the `userName` attribute

For RPs with roles managed by Edupass, `urn:ietf:params:scim:schemas:core:2.0:User` should also include the `groups` attribute with the `returned` property set to default. The `groups` attribute should be omitted for RPs without roles managed by Edupass.

###### Core Group Schema

For RPs with roles managed by Edupass, the `urn:ietf:params:scim:schemas:core:2.0:Group` schema should be present and include all attributes in the example below, namely `displayName` and `members`.

:::details Status 200

```
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 3,
  "startIndex": 1,
  "itemsPerPage": 3,
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Schema"
      ],
      "id": "urn:ietf:params:scim:schemas:core:2.0:User",
      "name": "User",
      "attributes": [
        {
          "name": "userName",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "server",
          "required": true,
          "caseExact": false
        },
        {
          "name": "name",
          "type": "complex",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "subAttributes": [
            {
              "name": "formatted",
              "type": "string",
              "multiValued": false,
              "mutability": "readWrite",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": false
            }
          ]
        },
        {
          "name": "emails",
          "type": "complex",
          "multiValued": true,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "subAttributes": [
            {
              "name": "value",
              "type": "string",
              "multiValued": false,
              "mutability": "readWrite",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": false
            },
            {
              "name": "type",
              "type": "string",
              "multiValued": false,
              "mutability": "readWrite",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": false
            },
            {
              "name": "primary",
              "type": "boolean",
              "multiValued": false,
              "mutability": "readWrite",
              "returned": "default",
              "uniqueness": "none",
              "required": false
            }
          ]
        },
        {
          "name": "title",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "caseExact": false
        },
        {
          "name": "groups",
          "type": "complex",
          "multiValued": true,
          "mutability": "readOnly",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "subAttributes": [
            {
              "name": "value",
              "type": "string",
              "multiValued": false,
              "mutability": "readOnly",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": true
            },
            {
              "name": "$ref",
              "type": "reference",
              "referenceTypes": [
                "Group"
              ],
              "multiValued": false,
              "mutability": "readOnly",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": true
            },
            {
              "name": "display",
              "type": "string",
              "multiValued": false,
              "mutability": "readOnly",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": true
            }
          ]
        }
      ]
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Schema"
      ],
      "id": "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User",
      "name": "EdupassUser",
      "attributes": [
        {
          "name": "uinFin",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "caseExact": false
        },
        {
          "name": "schoolOrHq",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "caseExact": false
        },
        {
          "name": "identityType",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "caseExact": false
        },
        {
          "name": "identitySource",
          "type": "string",
          "multiValued": false,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "caseExact": false
        }
      ]
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:Schema"
      ],
      "id": "urn:ietf:params:scim:schemas:core:2.0:Group",
      "name": "Group",
      "attributes": [
        {
          "name": "displayName",
          "type": "string",
          "multiValued": false,
          "mutability": "immutable",
          "returned": "default",
          "uniqueness": "server",
          "required": true,
          "caseExact": true
        },
        {
          "name": "members",
          "type": "complex",
          "multiValued": true,
          "mutability": "readWrite",
          "returned": "default",
          "uniqueness": "none",
          "required": false,
          "subAttributes": [
            {
              "name": "value",
              "type": "string",
              "multiValued": false,
              "mutability": "immutable",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": true
            },
            {
              "name": "$ref",
              "type": "reference",
              "referenceTypes": [
                "User"
              ],
              "multiValued": false,
              "mutability": "immutable",
              "returned": "default",
              "uniqueness": "none",
              "required": false,
              "caseExact": true
            }
          ]
        }
      ]
    }
  ]
}
```

:::

### Get All Resource Types Endpoint

Returns a `ListResponse` with the list of SCIM resources that the RP supports. RPs must minimally support the `User` resource.

##### Resource Type Schema

| **Attribute**        | **Required?** | **Description**                                                                                                                                                                                                                                |
| -------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **name**             | Required      | The resource type name, i.e, "User" or "Group".                                                                                                                                                                                                |
| **endpoint**         | Required      | The resource type's HTTP-addressable endpoint relative to the Base URL of the service provider<br>- `/Users` for User<br>- `/Groups` for Group                                                                                                 |
| **schema**           | Required      | The resource type's primary/base schema URI<br>- `urn:ietf:params:scim:schemas:core:2.0:User` for User<br>- `urn:ietf:params:scim:schemas:core:2.0:Group` for Group                                                                            |
| **description**      | Optional      | Description of the resource type                                                                                                                                                                                                               |
| **schemaExtensions** | Optional      | Applicable to the `User` resource. The list of URIs of the resource type's schema extensions.<br>This should be a list of objects with the following attributes:<br>See [`schemaExtensions` sub-attributes](#schemaextensions-sub-attributes). |

###### `schemaExtensions` sub-attributes

| **Attribute** | **Required?** | **Description**                                                                     |
| ------------- | ------------- | ----------------------------------------------------------------------------------- |
| schema        | Required      | Extension URI                                                                       |
| required      | Required      | Boolean value indicating if the extension must be present on resources of this type |

If an RP supports Edupass' user schema extension, this will be a list that includes the object

```json
{
  "schema": "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User",
  "required": true
}
```

This can be an empty list if the RP does not require any user schema extensions.

##### Request

GET `/ResourceTypes`

##### Response

:::details Status 200

```
{
  "totalResults": 2,
  "itemsPerPage": 2,
  "startIndex": 1,
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:ResourceType"
      ],
      "id": "User",
      "name": "User",
      "endpoint": "/Users",
      "schema": "urn:ietf:params:scim:schemas:core:2.0:User",
      "schemaExtensions": [
        {
          "schema": "urn:ietf:params:scim:schemas:extension:Edupass:2.0:User",
          "required": true
        }
      ]
    },
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:ResourceType"
      ],
      "name": "Group",
      "endpoint": "/Groups",
      "schema": "urn:ietf:params:scim:schemas:core:2.0:Group",
      "schemaExtensions": []
    }
  ]
}
```

:::

## Rate Limits

To avoid getting overloaded by too many concurrent requests, RPs should implement rate-limits on the Create, Update and Delete endpoints. A response with HTTP 429 should be returned to indicate that the rate-limit is reached.

RPs can indicate when Edupass can make a retry attempt using the `Retry-After` header.

## Authentication for Specific RP Hosting Setups

The standard way to secure SCIM endpoints is described in [Securing SCIM Endpoints](#securing-scim-endpoints). This section covers RPs whose hosting setup or credential requirements need something different.

### RPs Hosted on AWS API Gateway

RPs that host their SCIM endpoints behind AWS API Gateway can use a built-in JWT authorizer to validate Edupass tokens, instead of writing their own validation code. This works for both API types:

- REST APIs (`aws apigateway`)
- HTTP APIs (`aws apigatewayv2`)

The API Gateway must be able to reach the following Edupass endpoints:

| **Environment** | **Issuer**                               | **OpenID configuration**            | **JWKS**            |
| --------------- | ---------------------------------------- | ----------------------------------- | ------------------- |
| Preprod         | `https://api.preprod.edupass.moe.gov.sg` | `/.well-known/openid-configuration` | `/.well-known/keys` |
| Production      | `https://api.edupass.moe.gov.sg`         | `/.well-known/openid-configuration` | `/.well-known/keys` |

For HTTP APIs (`aws apigatewayv2`), inform the Edupass team that the JWTs must be signed by **RS384**.

#### Setup: REST API / `aws apigateway`

The REST API authorizer has an explicit list of allowed signing algorithms, which must be set to `ES256`. Create a file `jwt-config.json`:

```
{
  "issuers": [
    { "issuer": "https://api.preprod.edupass.moe.gov.sg", "audiences": ["<APP_CODE>"] }
  ],
  "defaultAlgorithms": ["ES256"]
}
```

Then create the authorizer, attach it to the SCIM methods, and deploy:

```
aws apigateway create-authorizer \
    --rest-api-id <API_ID> \
    --name edupass-jwt-authorizer \
    --type JWT \
    --identity-source method.request.header.Authorization \
    --jwt-configuration file://jwt-config.json

aws apigateway put-method ... --authorization-type JWT --authorizer-id <AUTHORIZER_ID>
aws apigateway create-deployment --rest-api-id <API_ID> --stage-name <STAGE>
```

For production, use `https://api.edupass.moe.gov.sg` as the issuer.

Do not set required scopes on the methods - Edupass tokens do not carry a `scope` claim.

#### Setup: HTTP API / `aws apigatewayv2`

```
aws apigatewayv2 create-authorizer \
    --name my-jwt-authorizer \
    --api-id <API_ID> \
    --authorizer-type JWT \
    --identity-source '$request.header.Authorization' \
    --jwt-configuration Audience=<APP_CODE>,Issuer=https://api.preprod.edupass.moe.gov.sg
```

For production, use `Issuer=https://api.edupass.moe.gov.sg`. Then attach the authorizer to the SCIM routes.

### RPs Hosted on APEX

APEX is the WOG's central API management hub. RPs hosting their SCIM endpoints on APEX must use [JWT authentication](https://docs.developer.tech.gov.sg/docs/v2-apex-user-guide/v2/consuming/jwt-auth?product=APEX+Cloud). Edupass does not support API keys as the authentication method for APEX-hosted endpoints.

The JWTs that Edupass sends to APEX-hosted endpoints meet APEX's JWT requirements and are signed with ES256.

#### Prerequisites

RPs must do the following before Edupass can call their APEX-hosted SCIM endpoints:

1. Set up the APEX endpoint for [JWT authentication](https://docs.developer.tech.gov.sg/docs/v2-apex-user-guide/v2/consuming/jwt-auth-full-walkthrough?product=APEX+Cloud), and register the Edupass JWKS endpoint (see [Verifying Edupass JWT Signature](#verifying-edupass-jwt-signature)) on it. Refer to the APEX documentation "Adding JWKS to application".
2. Inform the Edupass team that the SCIM server is hosted on APEX, and provide the APEX API key for their application.

#### Request Handling and Testing

Edupass will send the `x-apex-jwt` in the `Authorization` header, which will be validated by APEX before it reaches the SCIM server.

As APEX requires unique JWTs on each request, the Edupass SCIM Postman collection will not be usable as it uses a long-lived JWT and APEX will reject the JWTs.
RPs should test their SCIM servers on a setup that is not on APEX.

Edupass will still perform functional tests on servers hosted in APEX.

### RPs Requiring API Keys or Long-Lived Tokens

Edupass SCIM does not support API keys or long-lived tokens. Every request carries a short-lived JWT signed by Edupass.

#### Workaround: RP-Operated Verification Middleware

RPs whose SCIM server can only authenticate with an API key or long-lived token can run a small middleware / service in front of it. This should:

1. Receive the SCIM request from Edupass with `Authorization: Bearer <JWT>`.
2. Fetch and cache the Edupass JWKS from `/.well-known/keys`, and re-fetch it whenever it sees an unknown `kid`.
3. Verify the signature, `iss`, `aud` and `exp`, following the same rules as [Securing SCIM Endpoints](#securing-scim-endpoints).
4. If the token is valid, forward the request to the RP's SCIM server using the RP's own API key or token, and relay the response unchanged.
5. If the token is invalid, return `401`.

The RP owns and operates this middleware, so no exchange of long-lived credentials is needed between Edupass and the RP.

```mermaid
sequenceDiagram
    participant E as Edupass
    participant M as RP middleware
    participant S as RP SCIM server

    E->>M: SCIM request<br/>Authorization: Bearer JWT
    M->>M: Verify JWT using Edupass JWKS<br/>(signature, iss, aud, exp)
    alt JWT is valid
        M->>S: SCIM request<br/>with RP's API key or token
        S-->>M: SCIM response
        M-->>E: SCIM response (unchanged)
    else JWT is invalid
        M-->>E: 401 Unauthorized
    end
```
