post. You connect with a project ID, a dataset name and an API token, confirm which fields an article fills in, and then save drafts, publish, or schedule from the article editor, the agent, or MCP.
Status: Available | Setup time: 10 minutes | Complexity: Intermediate
Before you start
Sanity is headless: your content lives in Sanity, and your own site (often Next.js on Vercel) renders it. That has two consequences for this integration:- ChatFeatured fills in fields on your schema, so you confirm a field mapping when you connect. ChatFeatured suggests one by reading your newest document of that type.
- Sanity doesn’t know where your posts appear on your site. Give ChatFeatured your site URL and post URL pattern so it can track each published post’s live page.
Setup
Step 1: Find your project ID and dataset
- Go to sanity.io/manage and open your project.
- The project ID is shown under the project name. It’s also the
projectIdin yoursanity.config.ts. - Open Datasets and note the dataset your site reads from. It’s usually
production.
Step 2: Create an API token
- In the same project, go to API → Tokens and click Add API token.
- Name it “ChatFeatured”.
- Under Permissions, choose Editor.
- Click Save and copy the token. Sanity shows it only once.
Step 3: Connect in ChatFeatured
- In ChatFeatured, go to Integrations → Sanity.
- Enter your project ID and dataset, paste the API token, and click Check connection.
Step 4: Confirm the field mapping
- Pick the document type articles should be created as.
- Check the field mapping. Each row names the field on your schema that an article value goes into. Clear a row to skip that field.
- Pick the body format. Use Portable Text if your body field is block content (the Sanity default). Use HTML or Markdown if it’s a string field your site renders.
- For Portable Text, tick what your body field allows. See Matching your body field below.
- If your schema has an author reference, pick a default author.
- Add your site URL and post URL pattern, for example
https://www.example.comand/blog/{slug}. The form shows the URL a post will be tracked at. - Optionally add your Studio URL, for example
https://your-project.sanity.studio, so published articles link straight to the document. - Click Connect dataset.
If the dataset has no documents of that type yet, ChatFeatured fills in the field names from Sanity’s blog template (
title, slug, body, publishedAt, mainImage, author). The type doesn’t need any documents to connect. Check the field names against your schema before connecting.Matching your body field
Sanity Studio won’t display a body field that contains a block type, style, list, or mark its schema doesn’t declare. It shows “Invalid Portable Text value” in place of the whole body. So ChatFeatured only sends what you tell it your body field allows, and turns everything else into something Sanity’s blog template accepts:
When you connect, ChatFeatured ticks anything your newest document already uses. Sanity’s blog template allows none of these except images. A body field declared as a plain
{ type: 'block' } allows the first three, and code blocks and tables need their plugins added to the field’s of array.
Connecting more than one dataset
Repeat Step 3 and Step 4 for each dataset. Each connection is a separate publish destination, and you pick one at publish time. A dataset can only be connected once.Publishing articles
From the article editor, click Publish (or Schedule) and choose your Sanity connection.Updating a published article
Edit the article in ChatFeatured and publish again. This updates the same Sanity document instead of creating a new one. Fields ChatFeatured doesn’t map, such as categories your team set in Studio, are kept.Publishing works like Sanity’s own Publish button: unpublished edits open in Studio for that document are replaced by the version you publish from ChatFeatured.
What gets sent
In Portable Text, headings, paragraphs, quotes, lists, and links map to standard Sanity blocks and marks, limited to what your body field allows (see Matching your body field). Images inside the article are uploaded to your Sanity media and added as
image blocks. Code blocks use the code type from @sanity/code-input and tables the table type from @sanity/table.
Live URL tracking
Once a post is published, ChatFeatured records its URL from your site URL and post URL pattern, and starts attributing AI citations of that page to the article. Drafts and scheduled posts aren’t tracked until they’re published. Without a site URL, publishing still works, but there’s no live page to track.Publishing with the agent and MCP
Sanity works the same way through automation as it does in the editor.- The agent: ask it to publish an article and it offers your Sanity connections alongside your other destinations.
- MCP:
list_integrationsreturns each Sanity connection with its project, dataset, document type, and available authors (with their ids).publish_articleaccepts the connection’sintegrationId, andsanityAuthorIdto override the default author.
Troubleshooting
Sanity says the API token is invalid or revoked
Sanity says the API token is invalid or revoked
The token was deleted in Sanity. Create a new Editor token, then edit the connection in ChatFeatured and paste it.
The Sanity API token can't write to this dataset
The Sanity API token can't write to this dataset
The token has Viewer permissions. Create a token with Editor permissions and use that one.
This API token belongs to a different Sanity project
This API token belongs to a different Sanity project
Tokens only work in the project they were created in. Check the project ID, or create a token in the project you’re connecting.
This Sanity project has no dataset called ...
This Sanity project has no dataset called ...
Check the dataset name under Datasets in sanity.io/manage. Dataset names are case-sensitive.
Studio shows an unknown field on published documents
Studio shows an unknown field on published documents
A mapped field doesn’t exist on your schema. Edit the connection and correct the field name, or clear it to stop writing that field.
Studio shows "Invalid Portable Text value" on the body
Studio shows "Invalid Portable Text value" on the body
The connection sends something your body field doesn’t declare, such as a numbered list or a table. Edit the connection, untick that item under What your body field allows, and publish the article again. Or add it to your schema and leave it ticked.
The live URL is wrong or missing
The live URL is wrong or missing
Edit the connection and check the site URL and post URL pattern. The pattern must contain
{slug}. Publish the article again to record the corrected URL.