Developer guides

Set up a default relay state for IdP-initiated SAML logins

Add a default landing URL for users logging in through SSO

When users open Sanity from their identity provider (IdP) dashboard, the IdP can send a relay state with the login: the URL Sanity opens after login. Without a default relay state, Sanity has no page to send them to and shows their user record as JSON instead. This guide expands on the SAML setup guide and shows how to set a default relay state, so IdP-initiated single sign-on (SSO) logins land in Sanity Manage or your studio.

Prerequisites

  • SAML SSO configured for your organization and enabled for the project, as described in Set up single sign-on with SAML.
  • The Administrator role in your Sanity organization.
  • Enable InResponseTo cleared in the Your Identity Provider details section of your SAML SSO configuration. IdP-initiated logins don't include InResponseTo, so Sanity rejects them while this option is selected.
  • Permission to edit the Sanity application's SAML settings in your IdP.

During the setup and configuration process, it's a good idea to keep two windows side by side:

  • One with Sanity Manage.
  • The other with your IdP's configuration settings. The screenshots in this guide show Okta.

Setup

Copy the login URL from Sanity Manage

Go to Sanity Manage and select the organization where you configured SAML SSO.

To navigate to the service provider configuration inside Sanity Manage:

  • In your organization, go to Settings > SAML SSO.
  • Find the project, click its menu (the vertical ellipsis icon), and select Copy login url.
Select Copy login url in the project's menu in Sanity Manage.

Customize the URL

This login URL takes users to Sanity Manage after they log in. To send users directly to your studio instead, edit the URL: replace the value of the origin parameter with your URL-encoded studio URL. For example, the Copied tab shows the login URL from Sanity Manage, and the Customized tab shows the same URL pointing to your studio:

https://api.sanity.io/v2021-10-01/auth/saml/login/SAML_PROVIDER_ID?origin=https%3A%2F%2Fwww.sanity.io%2Fmanage&projectId=PROJECT_ID

Add your studio URL (not the encoded value) to your project's CORS origin list. Otherwise, the customized login URL fails with a 403 error.

Update the default relay state in your IdP

In your IdP's SAML settings for the Sanity application, set the default relay state to the login URL you copied from Sanity Manage, or to your customized URL. In Okta, open the application's Sign On tab, click Edit in the Settings section, and enter the URL in Default Relay State.

Set the default relay state to the login URL from Sanity Manage, or to your customized URL.

Common errors

These errors relate to the relay state configuration. For other SSO login problems, such as SSO not appearing as a login option in the studio, see the troubleshooting section of Set up single sign-on with SAML.

  • Opening Sanity from your IdP dashboard shows a JSON user object instead of Sanity Manage or your studio: your IdP doesn't send a default relay state, so Sanity has no page to redirect you to and returns your user object. Set the default relay state in your IdP settings to the login URL from Sanity Manage. The response looks like the following example.
{
  "id": "3431pXO",
  "displayName": "Sanity Support",
  "email": "sanity@sanity.io",
  "familyName": "Sanity Support",
  "givenName": "Sanity",
  "middleName": null,
  "imageUrl": null,
  "provider": "saml-f6a94",
  "tosAcceptedAt": "2024-11-20T18:51:57.264Z",
  "createdAt": "2024-11-20T18:51:57.264Z",
  "updatedAt": "2024-11-20T18:51:57.535Z",
  "isCurrentUser": true,
  "providerId": "49jc94jf949930304jkojfciojlj934003490943"
}
  • Login fails with a 403 error, such as The origin '...' is not allowed: the studio URL in the origin parameter isn't an allowed CORS origin for the project. Add your studio URL (not the encoded value) to your project's CORS origin list.

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme