Using CMS AI Agent with Sanity

Everything you need for Sanity, in the order you will actually do it. If you are stuck, the last section has the real error messages and what each one means.

Switch these on first

  • A Sanity project at sanity.io/manage, and the dataset you want worked on — usually the one called production.
  • Sanity is not a website. It holds your content and hands it out through an API; your website is whatever you built on top of it. So the address you give us is the project, not the site your visitors see.
  • A token with Editor permissions. Editor is the lowest level that can write — Viewer can only read, and Administrator is more than this needs.
  • Worth doing first if you can: run `npx sanity@latest schemas deploy` in your Studio. Sanity keeps your schema in your Studio's code rather than in the API, so without this we can only offer the document types that already have documents in them.

Connecting your website

  1. Open your project at sanity.io/manage and give us its address. To connect a dataset other than production, write it as `projectid/dataset`.
  2. Go to API → Tokens and add a token with Editor permissions.
  3. Copy it and paste it into CMS AI Agent. Sanity shows it once.
  4. Choose which document type holds your articles, and which of its fields are the title and the body.
  5. One website here means one dataset, and nothing we do will reach another. Connect a second dataset as a second website if you need both.
1Find the tokensAPITokens2Editor, not the othersViewer — cannot writeEditorAdministrator — too much3Copy it onceToken (shown once)Then pick your document type
What those screens look like. Drawn rather than photographed, so they stay true when your CMS is redesigned.

What you can ask for on Sanity

  • Read content

    Looking at what is already on the website: the list of pages and posts, who wrote each one, when it last changed, whether it is published, and the full text of any one of them.

    "Which pages have not been touched in over a year?"

  • Create content

    Adding something that was not there before: a new page, a new post, a new entry of whatever kind your website uses. It arrives as a draft, with a title, the body text and a short summary, ready for you to read before anyone else can.

    "Add a page about our new opening hours and leave it as a draft."

  • Edit content

    Changing something that is already there: the title, the body text, the summary. You are told exactly which items were touched, and your website keeps its own history of what they said before.

    "Change the phone number on the Contact page to the new one."

  • Publish content

    Moving something between draft, published and private. This is the step that decides whether the public can see a page, which is why it is a thing you ask for on purpose rather than something that happens on the way past.

    "Publish the draft about the Saturday market."

  • Manage images and files

    Putting images and files onto the website and filling in the text that belongs with them: the title, the caption, and the alt text that a screen reader speaks and a search engine reads in place of the picture.

    "Put last week's photos into the gallery and write alt text for each one."

  • Edit SEO information

    The text that does not appear on the page but decides how the page looks in a search result and when somebody shares it: the SEO title, the description under it, and the alt text on images.

    "Which pages have no SEO description? Write one for each of them."

  • Custom content types

    Few websites hold only pages and posts. A property site has properties, a restaurant has dishes, a school has courses. This is working with those, in their own fields, instead of forcing everything to be a blog post.

    "Add a new dish to the menu: the name, the description and the price."

  • Site information

    The plain facts about the website: what it is called, what software and which version it runs, how many pages and posts it holds, which languages it is written in, and when it last changed.

    "How many pages does my website have, and when was each one last updated?"

  • Administrative information

    What is installed, what has an update waiting, and who has an account on the website. Reads only: it cannot install, update, activate or remove a plugin or theme, change a setting, or add or change a user.

    "Is anything on my website waiting for an update?"

What it will not do on Sanity

Sanity has no way to do this, so this agent does not offer it. What it would have meant:

  • Schedule content

    Setting a date and a time in the future for something to appear, so a post written on a Tuesday afternoon goes live on Monday morning with nobody at a keyboard.

  • Manage categories and tags

    Organising content so people can find it: which category a post sits in, which tags it carries, and creating a new category or tag where there is a real need for one.

  • Manage menus

    The menus a visitor clicks: adding an item, renaming one, putting them in a different order, moving one underneath another.

  • Bulk changes

    The same change across many items at once. Nothing happens straight away: you are shown the whole list first, with the value as it is now beside the value proposed for it, and it runs only after you have said yes. It can be stopped partway and it can be undone.

  • Manage redirects

    Sending an old address to a new one, so a link somebody saved or a result still sitting in Google lands on the right page instead of an error. It can also list everything that is already being sent somewhere else.

Worth knowing about Sanity

  • We do not ask you to prove the project is yours by putting a file on it, because there is nowhere to put one: a Sanity project lives at an address on sanity.io. An Editor token cannot be obtained without access to the project, so the token is the proof.
  • Your content model is yours, so a short setup step maps your field names onto the ones an assistant uses. Sanity can list the fields; it cannot know which one you think of as the article.
  • If you have not deployed your schema, the document types we can offer are only the ones that already have documents in them. A type you have defined but never used will not appear until you deploy.
  • Sanity has drafts of its own, and anything written here arrives as one. Publishing is a separate thing you ask for.
  • Publishing in Sanity does not put a page on a website — it makes the document live in the dataset. What your visitors see depends on the site you built on top, and when that site rebuilds.

When something goes wrong

The failures people actually meet, with the exact words CMS AI Agent will show you. The message is in English wherever you are, because that is what the software says.

The token stops being accepted.

What you will see

Sanity no longer accepts the saved token. Reconnect the site.

What to do

Sanity tokens can be revoked at sanity.io/manage under API → Tokens, and a token deleted there stops immediately. Add a new one with Editor permissions and reconnect.

Reading works and nothing can be written or published.

What you will see

That Sanity token is not allowed to do that. Creating and publishing need Editor, not Viewer.

What to do

The token is a Viewer. Viewer can only read. Make a new token with Editor permissions — that is the lowest level that can write — and reconnect with it.

The project connects, and then everything says setup is not finished.

What you will see

CMS AI Agent has not been told which document type in this project holds articles. Open the website in your dashboard to finish setting it up.

What to do

Your document types are yours, so we have to be told which one holds your articles. Open the website in your dashboard and choose it. If the type you want is not in the list, deploy your schema with `npx sanity@latest schemas deploy` — without that we only see types that already have documents.

An SEO title, a menu or a redirect is refused.

What you will see

An SEO title belongs to a page, and Sanity has no pages — your front end makes those. A meta description can be written if your document type has a field for it.

What to do

Sanity has no pages, no menus and no redirects — it holds content, and your front end makes the pages. A meta description can be written if your document type has a field for it; the rest belongs to whatever you built on top.

More about Sanity AI Agent