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

# Sanity

> Connect a Sanity project to Slate and create, update, and publish Sanity documents from your workflows.

The Sanity integration connects Slate workflows to one dataset in a Sanity project. Use it to write AI-generated content into Sanity documents as drafts, then publish them when they're ready.

## Why connect Sanity to Slate?

Slate generates content through AI-powered workflows. Sanity stores your structured content. Connecting the two moves content from generation into your Sanity dataset in a single automated flow.

## Prerequisites

* The **Admin** role in your Slate workspace. Members can view integrations but can't connect them.
* A Sanity project ID and dataset name
* A Sanity API token that can read and write documents in that dataset

## Setup

### Step 1: Gather your Sanity details

Have these values ready before you connect:

| Detail | Format Slate accepts |
| - | - |
| Project ID | Lowercase letters, numbers, and dashes |
| Dataset | Lowercase letters, numbers, underscores, and dashes |
| API token | A token with read and write access to the dataset |

Each connection covers one project and one dataset. To work with another dataset, add another connection.

### Step 2: Connect Sanity in Slate

1. Open Slate and go to **Workspace settings → Integrations**.
2. Under **More integrations**, find **Sanity** and click **Connect**.
3. Optionally, enter a **Connection name** (e.g., "Marketing Site" or "Blog").
4. Enter your project ID in **ProjectId**.
5. Enter your dataset name in **Dataset**.
6. Paste your API token into **Access token**.
7. Click **Connect**.

Slate checks the token with a test read and a test write. The test write isn't saved to your dataset. If both checks pass, the row shows **Connected**.

### Step 3: Use the connection in a workflow

1. Open or create a workflow.
2. Add the **Sanity** block from the **Apps** section.
3. Select your connection in **Sanity connection**.
4. Choose an **Action** and enter a **Document type**.
5. Map your workflow data to document fields.

For full details on configuring the Sanity block, see the [Sanity Block guide](/docs/workflows/blocks/apps/sanity).

## What you can do

Once connected, the Sanity integration enables the following through the Sanity workflow block:

| Capability | Description |
| - | - |
| **Create documents** | Add a new document of any document type in your dataset |
| **Update documents** | Change fields on a document you select |
| **Publish drafts** | Publish an existing draft document |
| **Draft or live writes** | Save new content as a draft (the default) or write it live |
| **Convert rich text** | Turn Markdown, HTML, or plain text into Sanity Portable Text |
| **Connect multiple datasets** | Add a connection for each project and dataset you use |

## Use cases

### AI-assisted blog drafts

Generate articles with the LLM block, then save them as Sanity drafts for your editors to review in Sanity Studio.

**Example flow:** Input keywords → LLM generates article → Sanity block creates a draft `post` document

### SEO landing pages at scale

Create one draft document per keyword. Map a `slug` field so each document gets a stable ID.

**Example flow:** Keyword list → Loop block iterates keywords → LLM writes page copy → Sanity block creates a draft for each keyword

### Publishing with approval

Use the Human Review block to get sign-off before content goes live.

**Example flow:** LLM drafts case study → Human Review for approval → Sanity block creates the document with **Save as draft** turned off

## Managing connections

### View connections

Go to **Workspace settings → Integrations** to see your Sanity connections. Each connection shows **Connected** or **Needs attention**.

### Fix a connection that needs attention

A connection shows **Needs attention** when Slate marks it invalid. For example, Slate marks a connection invalid when Sanity rejects its token. To fix it:

1. Create a new API token in Sanity with read and write access to the dataset.
2. Open the **⋮** menu on the **Sanity** row and choose **Add another connection**.
3. Enter the project ID and dataset, paste the new token, and click **Connect**.
4. In each Sanity block that used the old connection, select the new connection.
5. Remove the old connection.

<Note>Selecting a different connection in a Sanity block clears the block's document type, selected document, and field mappings. Set them again after you switch.</Note>

### Remove a connection

Open the **⋮** menu on the **Sanity** row and choose **Disconnect**. If you have more than one connection, expand the row and click **Remove** next to the connection. Workflows that use the removed connection need a new one.

## Troubleshooting

| Issue | Cause | Solution |
| - | - | - |
| Connection fails when you click **Connect** | Invalid token, or the token can't read or write the dataset | Check the token in Sanity and confirm it has read and write access |
| "Invalid Sanity projectId" or "Invalid Sanity dataset" | The value has characters Slate doesn't accept | Check the formats in [Step 1](#step-1-gather-your-sanity-details) |
| **Needs attention** on the connection | Sanity rejected the token | [Connect again with a new token](#fix-a-connection-that-needs-attention) |
| No suggestions under **Document type** | The dataset has no documents yet, or the wrong dataset is connected | Type the exact document type name, or check the connection's dataset |
| Rate limit errors during workflow | Too many Sanity API calls | Add delays between iterations in loop-based workflows |

## What's next

* [Sanity Block](/docs/workflows/blocks/apps/sanity) — detailed guide on configuring the Sanity workflow block
* [Building Workflows](/docs/workflows/building-workflows) — learn how to create workflows from scratch
* [Loop Block](/docs/workflows/blocks/flow/loop) — process multiple items in a workflow
* [Human Review Block](/docs/workflows/blocks/flow/human-review) — add approval steps before publishing


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