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

# Sanity

> Send Content Agent articles into your Sanity project as draft documents, per brand. 3RD never publishes.

Connect Sanity and the [Content Agent](https://docs.get3rd.com/actions/content-agent.md) can send a finished article straight into your Sanity dataset as a **draft document**. Headings, lists, links and images come across with it. Your team reviews the draft in Sanity Studio and publishes it there.

> [!NOTE]
>
> The Sanity integration is in **Beta**. Connect it per brand; nothing is shared across brands.

## Before you start

* Your organization needs an **active 3RD subscription** with the Content Agent.
* You need **edit access** to the brand in 3RD. View-only members don't see the **Connect** button.
* You connect **per brand**. Each brand links its own Sanity project and dataset.
* You need access to the project in **sanity.io/manage** to add an API token.
* The dataset needs at least **one document** of the type articles should go to, such as one blog post. 3RD lists only document types that already have a document. The type needs a **text field** for the title, a **slug field** and a **Portable Text field** for the body.

## Connect Sanity

**1. Open Integrations**

In 3RD, open **Settings → Integrations** for the brand.

**2. Click Connect**

In the **Sanity** row, click **Connect**. The **Connect Sanity** window opens. Go to **sanity.io/manage**, open your project and copy the **Project ID** shown at the top. Paste it into 3RD and click **Open this page in Sanity** to jump to the project's API settings.

**3. Add an API token**

In Sanity, open **API**, then **Tokens**, and click **Add API token**. Type `3RD` as the name, choose **Editor**, and save. Copy the token. Sanity shows it only once.

**4. Paste your details**

Back in 3RD, click **Next**. Check the **Project ID**, enter the **Dataset** (usually `production`) and paste the **API token**, which starts with `sk`. Optionally add your **Studio address**, such as `https://example.sanity.studio`, so 3RD can link straight to each draft. Click **Connect**.

**5. Choose where pieces go**

3RD checks the details with your project, then the **Where pieces go** window opens by itself. Pick the **Document type**, check the fields 3RD suggests, and click **Save**.

If you already have your details, click **I already have my details** to go straight to the fields.

> [!TIP]
>
> 3RD only ever writes drafts, so **Editor** is the role we recommend. If you'd rather Sanity itself stop 3RD from publishing, choose **Contributor** instead. Sanity doesn't let Contributor tokens add images, so images then stay as links to their original address.

## Choose where pieces go

Sanity needs a document type chosen before you can push. Until then, the Sanity row says **Choose where pieces go before pushing.** with a **Choose** button.

3RD fills these fields in each new draft:

| In Sanity | From 3RD |
| - | - |
| **Title field** (required) | The article's opening heading, or the piece title when the article has none |
| **Slug field** (required) | The address you set when pushing |
| **Body field** (Portable Text, required) | The article |
| **Summary field** (optional) | The article's first paragraph |
| **Cover image field** (optional) | The article's first image |

Pick **None** for an optional field to leave it empty. If a type lacks a field 3RD needs, the window names the missing field. Pick another type, or add the field in your Studio.

Images are uploaded to your dataset. An image that can't be copied stays a link to its original address, and 3RD tells you how many. Formatting your body field doesn't support is written with the nearest style it has.

To change the type or fields later, open the **⋯** menu in the Sanity row and click **Choose where pieces go**.

## Push an article to Sanity

**1. Open the article**

In the Content Agent, open a new article (not an optimization of an existing page).

**2. Send it as a draft**

Click **Push to Sanity**. If the brand has more than one CMS connected, the button says **Push to CMS** and you pick **Sanity** in the window. Check the **Address** and click **Send as draft**. 3RD shows **Draft created in Sanity** when it's done.

**3. Review it in Sanity Studio**

Open the document type in your Studio. The new document is a **draft**.

Pushing the same article again updates the **same draft** instead of creating a new one, so you can keep editing in 3RD and push again. Only the fields 3RD fills are changed. If the draft was deleted in Sanity, 3RD makes a new one.

## Drafts only

3RD only ever creates or updates **drafts**. It never publishes and never deletes anything, whatever role the token has.

Once a document is published in Sanity, 3RD leaves it alone, even if someone has started a new draft on it. Pushing that article again shows a message asking you to edit it in Sanity.

If someone edits the draft in Sanity while 3RD is sending it, 3RD overwrites nothing and asks you to push again.

## Disconnect

Open the **⋯** menu in the Sanity row and click **Disconnect**. 3RD stops sending anything to Sanity and deletes the token it stored. Documents already in Sanity stay where they are.

Deleting the `3RD` token in sanity.io/manage also removes 3RD's access. The next time 3RD tries to reach your project, the row shows **Reconnect needed**.

## Troubleshooting

| You see | What to do |
| - | - |
| **We couldn't find a Sanity project with this ID** | Copy the Project ID again from the top of your project in sanity.io/manage. |
| **This project has no dataset with this name** | Check the dataset name. Your project lists its datasets under **Datasets**. |
| **The token was refused** | Check the token. It may have been deleted or expired. Add a new one and connect again. |
| **This token can only read** | Add a new token with the **Editor** role. |
| **This dataset has no documents yet** | Create one example of the type articles should go to in your Studio, then open **Choose where pieces go** again. |
| **Choose where pieces go for Sanity in Settings first** | Open **Choose where pieces go** in the Sanity row and save a document type. |
| **The fields chosen for Sanity changed there** | The type changed in your Studio. Open **Choose where pieces go** and pick the fields again. |
| **An item with this slug already exists** | Change the address and push again. |
| A message that Sanity didn't let the connected key add images | The token can't add images, for example a **Contributor** token. Reconnect with an **Editor** token. |
| A message that the piece was already published | Edit the document in Sanity. 3RD doesn't change it. |

## Related

* [Content Agent](https://docs.get3rd.com/actions/content-agent.md): where the articles are written
* [HubSpot](https://docs.get3rd.com/integrations/hubspot.md): the same flow for HubSpot blogs and pages


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