## Sanity integration Sanity is a headless content platform with a structured content lake and a real-time editing environment. Integrating Sanity with Frontegg lets your application read and write documents, run GROQ queries, publish and schedule content releases, browse earlier document revisions, and manage datasets and assets on behalf of your users — all through Frontegg's integration layer. You can authenticate with either a Sanity project **API token** (recommended and self-serve) or OAuth 2.0. Prerequisites - A [Sanity](https://www.sanity.io/) account with a project - Access to your project's **API → Tokens** page in [Sanity Manage](https://www.sanity.io/manage) ### Connect to Sanity with an API token Sanity authenticates API requests with a project token, sent on every request as the `Authorization: Bearer ` header. You create the token in Sanity Manage and choose its permission level. #### Step 1: Open API tokens Sign in to [Sanity Manage](https://www.sanity.io/manage), open your project, and go to the **API** tab → **Tokens**. Click **Add API token**. ![Sanity project API Tokens page with the Add API token button](/assets/sanity-1.f6cefff88b6459b3956a1bc21dc47370881dab5284d46301ac6506af23046186.1ce25488.png) #### Step 2: Create the token Fill in the token details: - **Name** — A descriptive name, for example `Frontegg Integration`. - **Permissions** — Choose a role that matches the access you need. **Editor** or **Developer** grant read and write access (`read+write`); **Viewer** is read-only. Click **Save** and copy the token value. Copy your token now The token value is shown only once, when it is created. Copy it immediately and store it securely — treat it like a password. If it is exposed or lost, delete it and create a new one on the same **Tokens** page. ![Sanity Add API token form with a name and the Editor permission selected](/assets/sanity-2.2f661091555a0405f34766d69b7f6230d1b08e67f4aeec4443484cedc2971382.1ce25488.png) ### Use OAuth instead Sanity's OAuth 2.0 is not self-serve — credentials are issued manually and only to Sanity technology partners. If Sanity has already issued you a **Client ID** and **Client Secret**, enter those instead of a project token. Everyone else should use the API token flow above. For the OAuth flow you also need your Frontegg Redirect URL — see [How to get your Redirect URL](/agen-for-work/connectors/redirect-url). ### Configure the Frontegg portal Configure the integration in the Frontegg portal using the method you chose: 1. Open the **Frontegg portal** and navigate to [ENVIRONMENT] → Integrations → Sanity. 2. For an **API token**, paste it into the **API Token** field. For **OAuth**, enter the **Client ID** and **Client Secret** instead. 3. Click **Save**. You configure the credential only — the project and dataset are supplied per request, so a single integration can reach every project the token has access to. The token or OAuth grant provides the following access: | Scope | Description | | --- | --- | | `read` | Read access to content | | `write` | Write access to content | Keep your credentials secure Never share or commit your API token or Client Secret to version control. ### Additional resources - [Sanity HTTP API reference](https://www.sanity.io/docs/http-api) - [Sanity API tokens and permissions](https://www.sanity.io/docs/http-auth)