Skip to navigation

Sanity

Connect your AI agents to Sanity.
Ready to connect

Connects with credentials the end user enters, such as an API key, so you don’t need to register an OAuth app.

Authentication: API token with your project ID and dataset. See Magic Link for the runtime auth flow.

Sample use cases

  • List documents in the blog.post schema published in the last 30 days.
  • Update the homepage document to use the new Q2 hero image.
  • Find draft documents older than 60 days for cleanup.

Available Tools

list_cors_origins

List CORS origins allowed to call the project’s API from a browser.

create_cors_origin

Whitelist an origin (e.g., https://example.com) to call the API from a browser.

delete_cors_origin

Remove a CORS origin by its numeric ID. Use list_cors_origins to find IDs.

list_datasets

List all datasets in a project with their ACL mode and creation time.

create_dataset

Create a new dataset in a project. Name must be lowercase alphanumeric with ’_’ or ’-’.

update_dataset

Update a dataset’s ACL mode to ‘public’ or ‘private’.

delete_dataset

Delete a dataset permanently. All documents inside are removed. This cannot be undone.

query_documents

Run a GROQ query over a dataset. Use bound $params for user input. Supports pagination via GROQ slicing like [0…100].

get_document

Fetch one or more documents by ID, bypassing any CDN cache. Use query_documents to discover IDs.

create_document

Create a new document. The document must include a ‘_type’ field. If ‘_id’ is omitted, Sanity assigns one.

create_or_replace_document

Create a document, or fully replace an existing document with the same _id. Use get_document first to check existence.

patch_document

Apply a partial update (set / unset / inc / dec / setIfMissing) to an existing document.

delete_document

Delete a document by ID. For drafts, prefix the ID with ‘drafts.’. This cannot be undone.

get_document_history

Retrieve a document’s state at a specific revision or point in time. Provide either ‘revision’ or ‘time’.

list_projects

List all Sanity projects the authenticated user is a member of.

get_project

Get details for a specific Sanity project. Uses project_id from credentials if not provided.

update_project

Update a project’s display name, studio host, or metadata. Use list_projects to find valid IDs.

list_project_features

List feature flags enabled for a project, such as private datasets or scheduled publishing.

list_webhooks

List all webhooks configured for a project.

get_webhook

Get a webhook’s full configuration including filter, projection, and headers.

create_webhook

Create a webhook that fires on document create/update/delete events matching a GROQ filter.

update_webhook

Update a webhook’s configuration. Only provided fields are changed.

delete_webhook

Delete a webhook permanently. Use list_webhooks to find IDs.

list_webhook_attempts

List delivery attempts for a webhook including HTTP status codes. Use offset from page_info for the next page.