--- title: Provisioning users and groups with SCIM using the REST API shortTitle: SCIM using REST API intro: 'Manage the lifecycle of user accounts from your identity provider using {% data variables.product.company_short %}''s REST API for System for Cross-domain Identity Management (SCIM).' product: '{% data reusables.gated-features.emus %}' versions: ghec: '*' feature: scim-for-ghes-public-beta type: tutorial redirect_from: - /admin/identity-and-access-management/provisioning-user-accounts-for-enterprise-managed-users/provisioning-users-with-scim-using-the-rest-api - /admin/identity-and-access-management/provisioning-user-accounts-for-enterprise-managed-users/provisioning-users-and-groups-with-scim-using-the-rest-api - /admin/managing-iam/provisioning-user-accounts-for-enterprise-managed-users/provisioning-users-and-groups-with-scim-using-the-rest-api topics: - Accounts - Authentication - Enterprise - SSO --- {% ifversion ghec %} > [!NOTE] {% data reusables.scim.ghec-open-scim-test-in-isolation %} {% else %} {% data reusables.scim.ghes-beta-note %} {% endif %} {% ifversion ghec %} ## About IAM for {% data variables.product.prodname_emus %} If your enterprise on {% data variables.product.prodname_dotcom %} is created for {% data variables.product.prodname_emus %}, you must configure an external identity management system to provision and maintain user accounts. Your identity management system must offer the following functionality: * Single sign-on authentication implementing one of the following two single sign-on (SSO) standards: * Security Assertion Markup Language (SAML) 2.0 * OpenID Connect (OIDC), which is only supported if you use Microsoft Entra ID (previously known as Azure AD) * User lifecycle management with System for Cross-domain Identity Management (SCIM) {% else %} ## About SCIM provisioning on {% data variables.product.prodname_ghe_server %} To provision and maintain user accounts using SCIM, your identity management system must offer the following functionality: * Single sign-on authentication implementing Security Assertion Markup Language (SAML) 2.0 * User lifecycle management with System for Cross-domain Identity Management (SCIM) {% endif %} When you configure authentication and provisioning for your enterprise, you can either use a partner IdP, or you can use another combination of identity management systems. * [Using a partner identity provider](#using-a-partner-identity-provider) * [Using other identity management systems](#using-other-identity-management-systems) ### Using a partner identity provider Each partner IdP provides a "paved-path" application, which implements both SSO and user lifecycle management. To simplify configuration, {% data variables.product.company_short %} recommends that you use a single partner IdP application for both authentication and provisioning. For more information and a list of partner IdPs, see {% ifversion ghec %}[AUTOTITLE](/admin/identity-and-access-management/understanding-iam-for-enterprises/about-enterprise-managed-users#identity-management-systems).{% else %}[AUTOTITLE](/admin/managing-iam/provisioning-user-accounts-with-scim/user-provisioning-with-scim-on-ghes#supported-identity-providers).{% endif %} For more information about configuring SCIM provisioning using a partner IdP, see [AUTOTITLE](/admin/identity-and-access-management/provisioning-user-accounts-for-enterprise-managed-users/configuring-scim-provisioning-for-enterprise-managed-users). ### Using other identity management systems If you cannot use a single partner IdP for both authentication and provisioning due to migration overhead, licensing costs, or organizational inertia, you can use another identity management system or combination of systems. The systems must provide authentication using SAML and user lifecycle management using SCIM, and must adhere to {% data variables.product.company_short %}'s integration guidelines. {% data reusables.emus.mixed-systems-note %} ## Prerequisites {%- ifversion ghec %} * {% data reusables.enterprise-managed.emu-prerequisite %} * {% data reusables.scim.emu-prerequisite-authentication %} * You must enable an open SCIM configuration for your enterprise. For more information, see [AUTOTITLE](/admin/identity-and-access-management/provisioning-user-accounts-for-enterprise-managed-users/configuring-scim-provisioning-for-enterprise-managed-users#configuring-provisioning-for-other-identity-management-systems). * To authenticate requests to the REST API endpoints for SCIM, you must use a {% data variables.product.pat_v1 %} associated with your enterprise's setup user. The token requires the **scim:enterprise** scope. {% data variables.product.company_short %} recommends that you do not configure an expiration date for the token. See [AUTOTITLE](/admin/managing-iam/understanding-iam-for-enterprises/getting-started-with-enterprise-managed-users#create-a-personal-access-token). {%- else %} To implement SCIM using the REST API, the general prerequisites for using SCIM on {% data variables.product.prodname_ghe_server %} apply. See the "Prerequisites" section in [AUTOTITLE](/admin/managing-iam/provisioning-user-accounts-with-scim/configuring-scim-provisioning-for-users#prerequisites). In addition, the following prerequisites apply: * You must have completed steps 1 to 3 in [AUTOTITLE](/admin/managing-iam/provisioning-user-accounts-with-scim/configuring-scim-provisioning-for-users). * You must use the {% data variables.product.pat_v1 %} created for the built-in setup user to authenticate requests to the REST API. {%- endif %} {% data reusables.scim.scim-standard-prerequisite %} * The user records for the systems that you use for authentication and provisioning must share a unique identifier and satisfy {% data variables.product.company_short %}'s matching criteria. For more information, see [AUTOTITLE](/rest/enterprise-admin/scim#mapping-of-saml-and-scim-data) in the REST API documentation. ## Best practices for SCIM provisioning with {% data variables.product.github %}'s REST API When you configure your identity management system to provision users or groups of users on {% data variables.product.github %}, {% data variables.product.company_short %} strongly recommends that you adhere to the following guidelines. * [Ensure your identity management system is the only source of write operations](#ensure-your-identity-management-system-is-the-only-source-of-write-operations) * [Send valid requests to REST API endpoints](#send-valid-requests-to-rest-api-endpoints) * [Provision users before you provision groups](#provision-users-before-you-provision-groups) * [Validate access for groups on {% data variables.product.prodname_dotcom %}](#validate-access-for-groups-on-github) * [Understand rate limits on {% data variables.product.prodname_dotcom %}](#understand-rate-limits-on-github) * [Configure audit log streaming](#configure-audit-log-streaming) {%- ifversion scim-enterprise-scope %} * [Limit the scope of the SCIM token](#limit-the-scope-of-the-scim-token) {%- endif %} * [Understand the effects of deprovisioning](#understand-the-effects-of-deprovisioning) ### Ensure your identity management system is the only source of write operations To ensure that your environment has a single source of truth, you should only programmatically write to the REST API for SCIM provisioning from your identity management system. {% data variables.product.company_short %} strongly recommends that only one system sends `POST`, `PUT`, `PATCH`, or `DELETE` requests to the API. However, you can safely retrieve information from {% data variables.product.company_short %}'s APIs with `GET` requests in scripts or ad hoc requests by an enterprise owner. > [!WARNING] > If you use a partner IdP for SCIM provisioning, the application on the IdP must be the only system that makes write requests to the API. If you make ad hoc requests using the `POST`, `PUT`, `PATCH`, or `DELETE` methods, subsequent synchronization attempts will fail, and provisioning won't function properly for your enterprise. ### Send valid requests to REST API endpoints {% data variables.product.prodname_dotcom %}'s REST API endpoints for provisioning users with SCIM require well-formed requests. Bear in mind the following guidelines: * Requests that don't match the API's expectations will return a `400 Bad Request` error. * REST API endpoints for provisioning users with SCIM require a `User-Agent` header. {% data variables.product.github %} will reject requests without this header. {%- ifversion ghec %} * If your enterprise is on {% data variables.enterprise.data_residency_site %}, ensure you send API requests to the endpoint for your enterprise at `{% data variables.enterprise.data_residency_api %}`. {%- endif %} ### Provision users before you provision groups SCIM groups are effective for the management of user access at scale. For example, you can use groups on your identity management system to manage team and organization membership on {% data variables.product.github %}. To manage team membership with groups on your identity management system, you must sequentially complete the following steps: 1. Provision user accounts on {% data variables.product.github %}. 1. Provision a group on {% data variables.product.github %}. 1. Update the membership of the group on your identity management system. 1. Create a team on {% data variables.product.github %} that's mapped to the group on your identity management system. ### Validate access for groups on {% data variables.product.github %} If you manage access using groups on your identity management system, you can validate that users get the access you intend. You can use the REST API to compare your system's group memberships with {% data variables.product.prodname_dotcom %}'s understanding of those groups. For more information, see [AUTOTITLE](/rest/teams/external-groups#about-external-groups) and [AUTOTITLE](/rest/teams/teams#get-a-team-by-name) in the REST API documentation. ### Understand rate limits on {% data variables.product.prodname_dotcom %} {% ifversion ghec %} To ensure the availability and reliability of the platform, {% data variables.product.company_short %} implements rate limits. Without considering rate limits, large enterprises onboarding with {% data variables.product.prodname_emus %} for the first time are likely to exceed the limits. {% data reusables.scim.emu-scim-rate-limit-details %} {% else %} If a site administrator has enabled rate limits on your instance, you may encounter errors when you provision users for the first time. You can review your IdP logs to confirm if attempted SCIM provisioning or push operations failed due to a rate limit error. The response to a failed provisioning attempt will depend on the IdP. {% endif %} For more information, see [AUTOTITLE](/rest/using-the-rest-api/rate-limits-for-the-rest-api). ### Configure audit log streaming The audit log for your enterprise displays details about activity in your enterprise. You can use the audit log to support your configuration of SCIM. For more information, see [AUTOTITLE](/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/about-the-audit-log-for-your-enterprise). Due to the volume of events in this log, {% data variables.product.company_short %} retains the data for 180 days. To ensure that you don't lose audit log data, and to view more granular activity in the audit log, {% data variables.product.company_short %} recommends that you configure audit log streaming. When you stream the audit log, you can optionally choose to stream events for API requests, including requests to REST API endpoints for SCIM provisioning. For more information, see [AUTOTITLE](/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/streaming-the-audit-log-for-your-enterprise). {% ifversion scim-enterprise-scope %} ### Limit the scope of the SCIM token For a better security posture, we recommend using a {% data variables.product.pat_v1 %} with only the `scim:enterprise` scope to limit the token's access to the REST API endpoints required to make SCIM calls. If you currently use a token with the `admin:enterprise` scope, be aware that this token grants access to all actions on the enterprise. You can swap your token for a new token with just the `scim:enterprise` scope without disruption. {% endif %} ### Understand the effects of deprovisioning To remove a user's access from {% data variables.product.github %}, you can send either a "soft deprovision" or a "hard deprovision" request to your SCIM provider. Hard deprovisioning is an irreversible action that permanently suspends a user's {% data variables.product.github %} account. Before implementing an API integration, ensure you understand the types of deprovisioning and the effects they have. To learn about the different types of deprovisioning, their effects, and the audit log events they generate, see [AUTOTITLE](/admin/managing-iam/provisioning-user-accounts-with-scim/deprovisioning-and-reinstating-users). ## Provisioning users with the REST API To provision, list, or manage users, make requests to the following REST API endpoints. You can read about the associated API endpoints in the REST API documentation and see code examples, and you can review audit log events associated with each request. Before a person with an identity on your identity management system can sign in to your enterprise, you must create the corresponding user. Your enterprise doesn't require an available license to provision a new user account. * For an overview of the supported attributes for users, see [SCIM](/rest/enterprise-admin/scim#supported-scim-user-attributes) in the REST API documentation. * You can view provisioned users in the {% data variables.product.github %} UI. For more information, see [AUTOTITLE](/admin/managing-accounts-and-repositories/managing-users-in-your-enterprise/viewing-people-in-your-enterprise). {% ifversion scim-for-ghes-ga %}* {% data reusables.scim.ghe-scim-identities-csv %}{% endif %} | Action | Method | Endpoint and more information | Events in the audit log | | :- | :- | :- | :- | | List all provisioned users for your enterprise, which includes all users who are soft-deprovisioned by setting `active` to `false`. | `GET` | [`/scim/v2/{% ifversion ghec %}enterprises/{enterprise}/{% endif %}Users`](/rest/enterprise-admin/scim#list-scim-provisioned-identities-for-an-enterprise) | N/A | | Create a user. The API's response includes an `id` field for uniquely identifying the user. | `POST` | [`/scim/v2/{% ifversion ghec %}enterprises/{enterprise}/{% endif %}Users`](/rest/enterprise-admin/scim#provision-a-scim-enterprise-user) |