A Sanity MCP for workflows that run when nobody is watching
Connect one Sanity robot token and 40 nodes land on the canvas: run GROQ against any dataset, create and patch and publish documents through the transactional Mutation and Actions APIs, upload assets from a URL, and manage datasets, CORS origins, tokens and webhooks. The same nodes answer to Claude and ChatGPT over MCP and run on a schedule with nobody present.
What the Sanity MCP connector does
The Sanity connector for Mattering Automations is 40 nodes across two Sanity hosts that one robot token reaches: the Content Lake for your project's data, and the project management API for the infrastructure around it. Eighteen nodes read and twenty-two act, and six are flagged destructive. Content reads cover GROQ, direct document fetches, revision history, per-document transactions and a full dataset export. Content writes cover all five mutation types plus the publish and unpublish actions and asset uploads. Management covers projects, datasets, CORS origins, API tokens, roles, permissions, features and webhooks.
Every node speaks MCP, the open protocol for connecting AI assistants to tools, so Claude, ChatGPT, and any other MCP-capable assistant can use them, alongside Matter, the AI assistant built into the platform. An agent can find content with Sanity: Run GROQ Query, patch a field with Sanity: Patch Document, and push it live with Sanity: Publish Document. The point of doing it here rather than in an editor is what happens next: the same nodes are steps on an automation canvas, so they run on a schedule or a webhook with nobody present, chain with every other connector in one workflow, and hold the credential once in a shared workspace store rather than in each person's local client config.
GROQ carries the read half, and that is a fact about Sanity rather than a shortcut here. Sanity ships no filter-by-field REST surface: the Doc API fetches by _id and nothing else, so GROQ is the documented way to find content by anything you do not already know the id of. Sanity: Run GROQ Query is therefore the whole read API in one node, and it is read-only by construction, because Sanity's own documentation states that mutations are not exposed through queries at all. Two typed nodes sit beside it and assemble the GROQ themselves from a document type, an optional filter fragment, a projection, an ordering and a page window: Sanity: List Documents by Type and Sanity: Count Documents. Someone who has never written GROQ gets an ordinary config panel; someone who has gets the full language.
The role on your token decides what this connector can do, and it is the single most useful thing to understand before connecting. Sanity's own documentation describes the built-in roles as a ladder: a viewer reads, a contributor writes drafts, an editor writes and publishes, and a developer additionally manages datasets, CORS, tokens and webhooks. Which of those exist depends on the plan, and Sanity documents Free as shipping administrator and viewer with editor, developer and contributor arriving on Growth. One more thing catches people out: Sanity's roles carry a flag deciding whether each role can be given to a robot token at all, so the role you had in mind may not be assignable to one. Sanity: List Roles reports which roles can actually be given to a robot token, and Sanity: List Project Permissions reports what the token you connected is allowed to do, which turns a mystery 403 into a one-node answer.
Six nodes are flagged destructive and the honesty about recovery is deliberately precise. Sanity: Delete Document, Sanity: Delete Documents by Query and Sanity: Run Mutation Batch can remove content; without the purge option the transaction history remains, so a determined operator can reconstruct a document through Sanity: Get Document Revision, but Sanity documents no retention window for that history, so it is a chance rather than a backup. Sanity: Delete Dataset is the one history cannot soften, because the history goes with the dataset. Sanity: Delete API Token and Sanity: Delete Webhook take an unrecoverable secret and an unrecoverable delivery log respectively. The two widest-blast-radius write nodes, Sanity: Run Mutation Batch and Sanity: Delete Documents by Query, default their dry run option ON, so the first execution is a report rather than a change.
One connection, three surfaces
- Visual automations. Drag Sanity nodes onto the canvas and wire them to triggers, conditions, and other apps.
- AI agents, yours or ours. These nodes speak MCP, the open protocol, so Claude, ChatGPT, and any MCP-capable assistant can use them, and Matter, the agent built into the platform, uses them natively.
- The whole platform. Combine with native tasks, projects, and other connectors, no middleware in between.
Every Sanity node, ready to drop on the canvas
40 nodes, generated from the connector itself so this list always matches what ships. Expand a category to browse.
Read and query nodes 18
Sanity: Count Documents
Count the documents of one type that match an optional filter without transferring them. The answer is a single number at data.result. Use this to gate an automation (only run the digest when there is something new) or to check a delete-by-query's blast radius before running it.
Sanity: Export Documents
Export every document the token can read from a dataset as one stream. Sanity sends newline-delimited JSON; the node parses it into data.documents with a data.count. This is the snapshot to take BEFORE anything destructive - on Free and Growth plans it is the only backup available, since the Backups API is enterprise-only. Export execution is capped at 5 minutes; on a large dataset use cursor mode by setting the cursor field to an empty string and following the cursor Sanity returns.
Sanity: Get Document
Fetch one document by _id straight from the Content Lake. This bypasses the caching layers so it always returns the very latest state, which is what you want immediately after a write. Sanity documents it as less scalable than a GROQ query and asks that it be used sparingly - prefer Sanity: Run GROQ Query for anything you will call in a loop. The response carries data.documents as an array even for one id.
Sanity: Get Document Revision
Fetch a document as it looked at a past revision or at a point in time. Give either a revision id or a timestamp; the timestamp is matched against when the transaction landed. This is the read half of any restore-what-changed workflow, and the only route back to a document that was deleted without purge. Sanity documents no retention window for history so do not rely on it as a backup.
Sanity: Get Project
Fetch the connected project: display name studio host organization members and whether it is blocked or disabled. The project comes from the Sanity connection so this node has nothing to configure. Useful as a health check inside a workflow and to read data.members for who has access.
Sanity: Get Project User
Fetch one user of this project by id, or the caller's own identity by leaving the default value of me. Turns the user id on a transaction or a document's _updatedBy into a name an automation can put in a message.
Sanity: List API Tokens
List the project's API tokens with their labels and roles. Sanity never reveals a token's value again after creation, so this returns details ABOUT each token and not the secret. Use it to audit what has access and with which role.
Sanity: List CORS Origins
List the browser origins allowed to call this project's API directly, and whether each may send credentials. The first thing to check when a front end works from the server but fails in the browser.
Sanity: List Datasets
List the datasets in the connected project with their names and access mode (public datasets are readable without a token; private ones are not). Every dataset-scoped node in this connector sources its dataset picker from here, so this is the node that makes the rest of the connector configurable without typing.
Sanity: List Document Transactions
List the transactions that touched specific documents: who changed what and when. Answers audit questions (who last edited this page) and drives change-detection automations. Sanity streams this as newline-delimited JSON; the node parses it into data.transactions with a data.count. Scoped to document ids on purpose - the whole-dataset variant is a firehose and is not built.
Sanity: List Documents by Type
List documents of one type without writing GROQ by hand. Choose the document type and optionally add a filter fragment an ordering and a projection; this node assembles the GROQ and runs it. The document type is passed as a query parameter rather than pasted into the query text. Results arrive at data.result as an array.
Sanity: List Project Features
List the features enabled for this project, which is how the plan shows up in the API. Check this before building a workflow on something plan-gated rather than discovering it from a 402 at runtime.
Sanity: List Project Permissions
List what the CURRENT token is actually allowed to do in this project. The right first call when a write returns 403: it separates a wrong token from a wrong request, which is otherwise guesswork.
Sanity: List Projects
List the projects this token can see, with their ids display names and organization. Mostly used once, to find the project id that goes on the Sanity connection - every other node takes the project from the credential rather than from a field, because a project robot token only works against its own project. Also the credential health check: a bad token returns 401.
Sanity: List Roles
List the roles available in this project - the built-in ones and any custom roles - with the grants each carries and whether it can be given to a robot token. Read this before Sanity: Create API Token, because the role decides what the new token can do. Which built-in roles exist depends on the plan: Free ships administrator and viewer while editor, developer and contributor arrive on Growth.
Sanity: List Webhook Attempts
List a webhook's recent delivery attempts with the status code the endpoint returned, how long it took and why it failed. The answer to did my webhook actually fire, and the first thing to read when a content-triggered workflow did not run.
Sanity: List Webhooks
List the project's webhooks with their target URLs, the dataset and GROQ filter each listens on, and whether they are disabled. Webhooks are how Sanity pushes content changes into an automation, so this is the inventory of what is already wired up.
Sanity: Run GROQ Query
Run a GROQ query against a dataset and get the result. GROQ is Sanity's query language and it is the whole read API - there is no filter-by-field REST surface, so this is how an automation finds content by anything other than a known id. Read-only by construction: GROQ cannot write, so this node can never mutate content. Sent as a POST because Sanity caps GET query URLs at 11 KB. The response carries the result at data.result plus the server time in data.ms.
Action nodes 22
Sanity: Add CORS Origin
Allow a browser origin to call this project's API - the step a preview deployment needs before its front end can read content. Requires a token with infrastructure permissions. Reversible with Sanity: Remove CORS Origin.
Sanity: Create API Token
Create a new API token for the project with a chosen role. The secret is returned ONCE at data.key and never again, so whatever consumes this node's output is the only chance to store it - route it to a secret store rather than to a log or a chat message. Robot tokens cannot hold Sanity's default administrator role. Requires a token with infrastructure permissions. Reversible with Sanity: Delete API Token.
Sanity: Create Dataset
Create a dataset in the connected project. Datasets are how Sanity separates production from staging or one tenant from another, and content does not move between them by itself. Requires a token with infrastructure permissions (administrator or developer). Reversible with Sanity: Delete Dataset while the dataset is still empty.
Sanity: Create Document
Create a new document. Fails if the id already exists - use Sanity: Create or Replace Document to overwrite or Sanity: Create Document If Not Exists to skip silently. Leave the id blank and Sanity generates one; end it with a dot to use it as a prefix for a generated id. Create the id as drafts.<id> to write a draft rather than published content. Reversible with Sanity: Delete Document.
Sanity: Create Document If Not Exists
Create a document only if that id is free and do nothing at all if it already exists. The idempotent seeding node: a workflow that runs twice cannot create the record twice and cannot overwrite what someone edited in between. Use a stable id derived from the source system.
Sanity: Create Webhook
Create a webhook so Sanity calls a URL whenever matching content changes. Point it at an Automations webhook trigger and the workflow starts the moment an editor publishes, instead of on a schedule. The GROQ filter narrows what fires and the projection controls what is sent, so the receiving workflow gets only the fields it needs. Set a secret to sign deliveries. Reversible with Sanity: Delete Webhook.
Sanity: Create or Replace Document
Create a document with the id you choose or REPLACE it whole if it already exists. This is a replacement and not a merge: any field you leave out is gone from the new revision. Use Sanity: Patch Document to change some fields and keep the rest. The prior revision remains in the document's history so this is recoverable through Sanity: Get Document Revision. The natural node for a sync that mirrors an external system into Sanity.
Sanity: Delete API Token
DESTRUCTIVE: revoke an API token. Everything using it stops working the moment this runs, and the secret cannot be recovered because Sanity only ever shows it once. Access is recoverable by issuing a NEW token and updating every consumer; the old value is not. Check Sanity: List API Tokens and confirm the label before running this - deleting the token this connection uses breaks the connector itself.
Sanity: Delete Dataset
DESTRUCTIVE: delete a dataset and everything inside it - every document, every asset and the whole revision history. This is the one delete in this connector that history cannot soften, because the history goes with the dataset. Sanity's Backups API is enterprise-only and dataset copy is Business/Enterprise, so on Free and Growth plans the only safety net is running Sanity: Export Documents first and keeping the output. There is no undelete.
Sanity: Delete Document
DESTRUCTIVE: delete one document by _id. Sanity has no trash and no undelete. Without the purge option the document's transaction history remains so a determined operator can reconstruct it through Sanity: Get Document Revision - Sanity documents no retention window for that history so treat it as a chance and not a backup. With purge on there is nothing left to reconstruct from. Deleting the published document does not delete its draft; delete drafts.<id> too. Run Sanity: Export Documents first if the content matters.
Sanity: Delete Documents by Query
DESTRUCTIVE: delete every document a GROQ query matches. The blast radius is whatever the query returns at the moment it runs, so run the SAME query through Sanity: Count Documents or Sanity: Run GROQ Query first and leave the dry run option on for the first execution. Sanity caps this at 10,000 documents per query and asks that larger jobs be split and paginated. Same recovery position as a single delete: history may allow reconstruction unless purge is set.
Sanity: Delete Webhook
DESTRUCTIVE: delete a webhook. The definition and its delivery history go with it and nothing restores the history. The definition itself is recoverable only by hand, from a copy of its URL filter and projection - read Sanity: List Webhooks and keep the output first. If the goal is a temporary pause use Sanity: Enable or Disable Webhook instead.
Sanity: Enable or Disable Webhook
Turn a webhook off or back on without deleting it. The way to pause deliveries during a bulk import or a migration so the downstream workflow is not flooded, and then restore it with the same node. Disabling is the only field this endpoint updates - change a URL or filter by deleting and recreating the webhook.
Sanity: Patch Document
Change specific fields on an existing document and leave everything else alone. The surgical alternative to Sanity: Create or Replace Document. Fails if the document does not exist. Sanity applies the operations in a fixed order: set then setIfMissing then unset then inc then dec then insert. Fill the revision field to refuse the write if someone else edited the document since you read it.
Sanity: Publish Document
Publish a draft: promote the draft version onto the published document so the live site sees it. This runs through Sanity's Actions API rather than the Mutation API, which is what makes it a real publish rather than a copy. Reversible with Sanity: Unpublish Document. The optimistic lock fields refuse the publish if either side changed since you read it.
Sanity: Remove CORS Origin
Remove a browser origin from the allow list. Browser calls from that origin start failing immediately, so check what is deployed there first. Not classed destructive: the entry is a two-field record that Sanity: Add CORS Origin recreates exactly.
Sanity: Run Mutation Batch
DESTRUCTIVE: run several mutations as ONE atomic transaction - either every mutation applies or none does. Flagged destructive because a batch may contain delete mutations and the connector cannot know what you put in it; the typed nodes beside this one carry honest per-operation flags and should be preferred when one operation is enough. Use this when several documents must change together (create an author and the post that references it) or to write hundreds of records in one call. Sanity caps a mutation request body at 4 MB so split large imports.
Sanity: Unpublish Document
Unpublish a document: remove the published version so the live site stops serving it while the draft remains for editors. This is the safe way to take a page down - the content is not deleted and Sanity: Publish Document puts it straight back. Prefer this over a delete whenever the content might return.
Sanity: Update Dataset
Change a dataset's access mode between public and private. Flipping a dataset to private immediately stops every tokenless reader - including a live website that reads with no token - so make sure the front end has a token before running it. Reversible by running the node again the other way.
Sanity: Update Project
Update the connected project's settings: its display name, the studio host it is served on, its metadata and whether the activity feed is on. Only the fields you fill are sent. Requires a token with infrastructure permissions (administrator or developer role); an editor token gets a 403 here.
Sanity: Upload File from URL
Upload a non-image file (PDF, video, zip) into a dataset by giving its public https URL. Same mechanics as the image node: Sanity takes raw bytes so this node downloads the file and forwards them (https only; capped at 50 MB), and the new asset document comes back at data.document for referencing from a file field.
Sanity: Upload Image from URL
Upload an image into a dataset by giving its public https URL. Sanity's asset endpoint takes raw bytes rather than a URL so this node downloads the image and posts the bytes for you (https only; capped at 50 MB). The response carries the new asset document at data.document - reference data.document._id from an image field on a document you create next. Sanity de-duplicates by content hash so uploading the same bytes twice returns the same asset. Uploads are limited to 25 requests/second.
Connecting Sanity takes one credential
Sanity calls a machine token a robot token, and its own documentation recommends generating a dedicated one for any application or third-party service rather than reusing a personal token. Create it at sanity.io/manage, under the project's Settings and then API, in the Tokens section. The connection also takes the project id, which is not a secret: it appears in sanity.io/manage and in your studio's configuration file, and it is part of both the content host and every management path. It lives on the credential rather than on the nodes for a documented reason: Sanity states that a project robot token can only act on its own project, so the token and the project are one to one and a per-node field could never legally hold two values for one connection. The dataset is the opposite case and does sit on the nodes, with a picker, because one token reaches every dataset in its project. An optional default dataset on the credential fills in when a node's dataset is left blank, so a single-dataset project does not retype the same word on every node. Before designing a workflow around the write half, check what the token can do rather than assuming: Sanity documents Free-plan roles as administrator and viewer, with editor, developer and contributor arriving on Growth, and each role carries a flag for whether it can be given to a robot token at all. Sanity: List Roles shows which roles are assignable to a robot, and Sanity: List Project Permissions shows what your connected token actually has.
Sign in at sanity.io/manage and open the project you want to reach. Copy its project id.
Open the project's Settings, then API, then Tokens, and add a new token. Give it the narrowest role that covers your workflows: a read-only automation wants a viewer token, and only workflows that manage datasets, CORS, tokens or webhooks need a developer token.
Copy the token value. Sanity shows a token's secret once, so store it as you create it.
In Mattering Automations, open Connectors, click Add Connector, choose Sanity, and create a credential with the project id and the token. Set a default dataset if your project only really uses one.
Click Test Connection. Mattering calls Sanity's project list on the management host, which takes no parameters and no dataset, so it proves the token on its own. An invalid token answers 401.
All 40 Sanity nodes appear in the canvas palette. Run Sanity: List Datasets first: it is where the dataset picker on the other 27 dataset-scoped nodes gets its options, and it also reports each dataset's access mode.
Common uses for the Sanity MCP
Retrieval and reporting straight out of the Content Lake
Sanity: Run GROQ Query is the whole read API in one node, so any question GROQ can answer becomes a workflow step: every article missing a hero image, every product whose price changed this week, every reference to a document about to be retired. Sanity: List Documents by Type and Sanity: Count Documents cover the same ground without writing GROQ, assembling it from a document type, a filter fragment, an ordering and a page window. The count node earns its place as a gate rather than a report: run it before a digest so the workflow only continues when there is something new, and run it before a delete-by-query so the blast radius is a number somebody read rather than a surprise.
Mirror an external system into Sanity without drift
Sanity: Create or Replace Document is the natural node for a sync that mirrors a source of truth into content: it writes at an id you choose and replaces what was there, so a re-run converges rather than duplicating. Sanity: Create Document If Not Exists is the idempotent seeding half, doing nothing at all when the id is taken, which is what a workflow that might run twice actually wants. Sanity: Patch Document is the surgical one, changing only the fields you name and leaving the rest alone, with an optional revision field that refuses the write if somebody edited the document since you read it. The trade worth stating: replace is a replacement and not a merge, so anything you leave out is gone from the new revision, and patch exists precisely so you do not have to carry the whole document to change one field.
Publish on a schedule or on an approval, not by hand
Publishing is not a mutation in Sanity, it runs through the Actions API, and it gets its own nodes: Sanity: Publish Document promotes a draft onto the published document so the live site sees it, and Sanity: Unpublish Document takes it back down while leaving the draft for editors. Both carry optimistic lock fields that refuse the operation if either side changed since you read it. That makes unpublish the right node for taking a page down temporarily, because publish puts it straight back and nothing is deleted. An approval task in Mattering, a date on a document, or a message in Slack can all become the thing that triggers the publish.
Let Sanity start the workflow instead of polling for it
Sanity: Create Webhook subscribes a URL to content changes, and its GROQ filter narrows what fires while its projection controls what is sent, so the receiving workflow gets only the fields it needs rather than a whole document. Point it at an Automations webhook trigger and the workflow starts the moment an editor publishes rather than on the next scheduled sweep. Sanity: List Webhook Attempts is the node that answers whether a delivery actually happened, carrying the status code the endpoint returned and why it failed, and Sanity: Enable or Disable Webhook pauses deliveries during a bulk import so the downstream workflow is not flooded, then restores them.
Move media in without running an upload service
Sanity: Upload Image from URL and Sanity: Upload File from URL take a public https URL, download it server side and post the raw bytes, because Sanity's asset endpoints take bytes and document no URL-based upload. Downloads are https only and capped at 50 MB. The new asset document comes back so the next node can reference its id from an image or file field on a document it creates. Sanity de-duplicates by content hash, so uploading the same bytes twice returns the same asset rather than a second copy, which makes a re-run of an import cheap instead of messy.
Run the project's plumbing from a workflow
Sanity: Create Dataset, Sanity: Update Dataset, Sanity: Add CORS Origin and Sanity: Create API Token turn the setup work around a preview deployment into steps rather than a checklist: spin a dataset for a branch, allow its origin, mint a scoped token, and tear the whole thing down afterwards. These need a token with infrastructure permissions, so check Sanity: List Project Permissions before building on them. Two of them deserve care rather than automation reflexes. Flipping a dataset to private stops every tokenless reader immediately, including a live website that reads with no token. And a created token's secret is returned exactly once, so whatever consumes that node's output is the only chance to store it: route it to a secret store, never to a log or a chat message.
Example: A content publish that fans out safely, with a dry run in front of the risky part
Built on the Automations canvas in a few minutes, or described in plain language to Matter and built for you.
Trigger: Sanity: Create Webhook was configured once to post to an Automations webhook trigger, with a GROQ filter narrowing it to published documents of one type, so the workflow starts the moment an editor publishes rather than on a schedule.
Sanity: Get Document reads the published document straight from the Content Lake, which bypasses the caching layers and is what you want immediately after a write.
The workflow fans the content out: a row in a Mattering database, a message in Slack, a task for whoever owns distribution, and a search index update through another connector, all from one canvas.
On a separate nightly schedule, Sanity: Count Documents counts the documents a retirement rule matches, and a condition stops the run and opens a task if the number is larger than a retirement should ever be.
Sanity: Export Documents takes the dataset snapshot before anything is removed. On Free and Growth plans this is the backup, because Sanity documents its Backups API as enterprise only.
Sanity: Delete Documents by Query runs the retirement, with its dry run option left on for the first execution so the first result is a report rather than a change. Sanity caps a delete by query at 10,000 documents and asks that larger jobs be split and paginated.
Sanity: List Webhook Attempts is read on a schedule and a task opens when a delivery failed, so a webhook that has gone quiet is noticed by somebody rather than discovered weeks later.
Sanity MCP questions, answered
What Sanity operations are supported?
40 nodes: 18 read and 22 action. Content reads cover GROQ queries (raw, plus typed list and count nodes), fetch by id, a document revision, per-document transactions and a full dataset export. Content writes cover all five mutation types (create, create or replace, create if not exists, patch, delete), delete by GROQ query, a raw atomic mutation batch, the publish and unpublish actions, and image and file uploads from a URL. Management covers projects, datasets, CORS origins, API tokens, roles, permissions, project features and webhooks with their delivery attempts. Deliberately not included, each for a stated reason: the GraphQL API, whose schema is generated from your own studio rather than being a fixed vendor surface and which Sanity documents as read-only; the Listen and Live Content APIs, which are long-lived event streams rather than something a node can return from, with webhooks as the automation-shaped equivalent; the Scheduling API, which Sanity documents as both deprecated and plan-gated; and the Backups and dataset Copy APIs, which Sanity documents as enterprise plan features.
Does this work with Claude, ChatGPT, or other AI assistants?
Yes. Mattering exposes these nodes over MCP, an open protocol for connecting AI assistants to tools, so any MCP-capable assistant, including Claude and ChatGPT, can connect to your workspace and use them. Matter, the assistant built into the platform, uses the same nodes natively. The same 40 nodes are also ordinary steps on the automation canvas, which is the part an assistant-only setup does not give you: a workflow that runs at 3am on a schedule, or when Sanity posts a webhook, with no assistant in the loop at all.
Sanity publishes its own MCP server. Why use this connector?
It does, and for some jobs it is the better answer, so it is worth knowing exactly what it is. Sanity's original local server shipped as the @sanity/mcp-server npm package; that repository was archived in July 2026 and its own README points users at the replacement. The current official server is remote and vendor-hosted at mcp.sanity.io, with HTTP transport and OAuth, documented on Sanity's site. If what you want is an assistant that helps you work in Sanity, use Sanity's server. This connector answers a different question: it puts 40 Sanity operations on an automation canvas as well as on MCP, so they run on a schedule or a webhook with nobody present, chain in one workflow with every other connector you have connected, hold the credential once in a shared workspace store rather than per person, and carry destructive flags you can gate on. The two are complements rather than substitutes, and nothing here disparages the vendor server.
Do I need to write GROQ?
Only if you want to. GROQ is genuinely the whole read API in Sanity, because there is no filter-by-field REST surface and the direct document endpoint fetches by _id alone, so a connector without a query node could only read content whose id you already knew. Sanity: Run GROQ Query gives you the full language, and Sanity's query errors are unusually helpful when you are learning it: a syntax error comes back as HTTP 400 naming the character offset in your query. For the common cases you can skip it entirely. Sanity: List Documents by Type and Sanity: Count Documents build the GROQ themselves from a document type picker, an optional filter fragment, a projection, an ordering and a page window.
Can a query node accidentally change my content?
No, and that is a property of Sanity rather than a promise we are making. Sanity's documentation states that mutations are not exposed through queries and go through the Mutation API instead, so a GROQ query cannot write. That is why Sanity: Run GROQ Query carries an honest non-destructive flag rather than a defensive one. Writes are separate nodes with separate flags, and the two widest ones, Sanity: Run Mutation Batch and Sanity: Delete Documents by Query, default their dry run option to on so the first execution reports rather than acts.
Do I need one credential per dataset?
No. One credential per PROJECT. A Sanity robot token can only act on its own project, which is why the project id sits on the credential, but one token reaches every dataset inside that project, so the dataset is a per-node field with a picker sourced from Sanity: List Datasets. Set a default dataset on the credential and a single-dataset project stops retyping it on every node, while a project with production, staging and per-branch sandboxes just picks per node. If you keep separate Sanity projects, connect a credential for each.
Can an AI agent delete content I cannot get back?
The six destructive nodes are flagged so you can gate them: Sanity: Delete Document, Sanity: Delete Documents by Query, Sanity: Run Mutation Batch, Sanity: Delete Dataset, Sanity: Delete API Token and Sanity: Delete Webhook. The recovery position deserves to be stated precisely rather than reassuringly. Sanity has no trash and no undelete. A delete WITHOUT the purge option leaves the document's transaction history behind, so a determined operator can reconstruct it through Sanity: Get Document Revision, but Sanity documents no retention window for that history, so treat it as a chance and not a backup. With purge on, there is nothing to reconstruct from. Deleting a dataset takes the history with it, which is why Sanity: Export Documents is the node to run first on Free and Growth plans, where the Backups API is not available. The practical guardrails: keep agents on the read nodes and the patch nodes, leave dry run on, run a count with the same query first, and put deletes behind a condition or an approval task.
Why did a write return 403 when the same token reads fine?
Almost always the token's role rather than the request. Sanity's roles are a ladder: a viewer reads, a contributor writes drafts only, an editor writes and publishes, and a developer additionally manages datasets, CORS origins, tokens and webhooks. So a viewer token passing the connection test and then failing a mutation is the system working as documented. Run Sanity: List Project Permissions, which exists for exactly this: it reports what the connected token is actually allowed to do, which separates a wrong token from a wrong request instead of leaving you guessing. Two related facts are worth carrying: which roles exist depends on the plan, with Sanity documenting Free as administrator and viewer and editor, developer and contributor arriving on Growth, and each role carries a flag for whether it can be given to a robot token at all. Sanity: List Roles reports which roles are assignable to a robot.
What limits should I design a bulk import around?
Three that Sanity documents, and the first one bites hardest because it works until it does not. A mutation request body is capped at 4 MB, so an import that succeeds at 200 documents can start failing at some larger number with nothing in the workflow having changed: split the batch. Delete by query operates on at most 10,000 documents per query, and Sanity asks that larger jobs be paginated. Mutations and asset uploads are each rate limited at 25 requests per second, with 500 requests per second across the API overall. Execution timeouts are generous but real: one minute for a query, three for a mutation, five for an export. A dataset also has document limits Sanity documents by plan, at 10,000 on Free and 50,000 on Growth.
Put Sanity to work inside your workspace
Connect once, then use every node in visual automations and AI agent workflows across the Mattering platform.
All product names, logos, and brands are property of their respective owners and are used for identification purposes only. Use of these names, logos, and brands does not imply endorsement or affiliation. Sanity is a product of its respective owner; Mattering is an independent platform.