Skip to main content
Sanity logo

Sanity

Lets an agent read and write content in your Sanity project. Run GROQ queries to fetch documents, apply mutations to create / update / delete documents, list datasets, get a document by id, and list image and file assets.

What it can do

MethodWhat it does
sanity_queryRun a GROQ query against the dataset, with optional parameters.
sanity_mutateApply mutations: create, createOrReplace, createIfNotExists, patch, or delete documents.
sanity_datasets_listList datasets in the project.
sanity_document_getGet a single document by its _id.
sanity_assets_listList image and file assets (url, filename, size, mime type).
sanity_requestGeneric passthrough to any Sanity endpoint (data or project-management host).

How to get your token

Sanity authenticates API calls with a project token sent as Authorization: Bearer <TOKEN>.

  1. Go to sanity.io/manage and open your project.
  2. Open the API tab, then Tokens.
  3. Click Add API token, give it a name, and choose the permission (Viewer for read-only, Editor / Deploy Studio to also write).
  4. Copy the token - it is shown once - and paste it into FlyMyAI.
  5. Find your Project ID on the same management page (it also appears in your sanity.config.ts).
  6. Note your Dataset name - it is usually production.

Fields to fill

FlyMyAI fieldWhere it comes from
SANITY_TOKENsanity.io/manage -> project -> API -> Tokens
SANITY_PROJECT_IDsanity.io/manage -> project (the short project ID)
SANITY_DATASETOptional - the dataset name, usually production

Troubleshooting

  • 401 Unauthorized - the token is wrong or revoked. Create a new one in API -> Tokens.
  • 403 Forbidden on sanity_mutate - the token is read-only. Issue a token with Editor (or higher) permission to write documents.
  • Empty query results - check the dataset name. If your content lives in staging, set SANITY_DATASET=staging (the default is production).
  • project not found - the SANITY_PROJECT_ID is wrong; copy it exactly from sanity.io/manage.
We love our partners - FlyMy.AI builds with the best. Thanks, Sanity!