# Sanity

```json
{
  "name": "Sanity",
  "slug": "sanity",
  "url": "https://composio.dev/toolkits/sanity",
  "markdown_url": "https://composio.dev/toolkits/sanity.md",
  "logo_url": "https://logos.composio.dev/api/sanity",
  "categories": [
    "document & file management"
  ],
  "is_composio_managed": false,
  "updated_at": "2026-06-18T10:07:33.985Z"
}
```

![Sanity logo](https://logos.composio.dev/api/sanity)

## Description

Securely connect your AI agents and chatbots (Claude, ChatGPT, Cursor, etc) with Sanity MCP or direct API to query content, create drafts, update documents, and manage structured CMS data through natural language.

## Summary

Sanity is a headless CMS for structured content, custom schemas, and APIs.
Use it to power flexible content workflows across websites, apps, and teams.

## Categories

- document & file management

## Toolkit Details

- Tools: 21

## Images

- Logo: https://logos.composio.dev/api/sanity

## Authentication

- **Api Key**
  - Type: `api_key`
  - Description: Api Key authentication for Sanity.
  - Setup:
    - Configure Api Key credentials for Sanity.
    - Use the credentials when creating an auth config in Composio.

## Suggested Prompts

- List recent Sanity posts needing review
- Create draft product page in Sanity
- Update author bio across Sanity articles

## Supported Tools

| Tool slug | Name | Description |
|---|---|---|
| `SANITY_ADD_DEFAULT_ROLE_TO_USERS` | Add Default Role to Users | Apply organization default role to all users. Use when you need to assign the organization's default role to all existing users in the organization. Requires the resource ID of the organization. |
| `SANITY_CREATE_ATTR_DEFINITION` | Create Attribute Definition | Tool to create a new user attribute definition in Sanity. Use when you need to define a custom attribute (like 'customer-tier' or 'subscription-level') that can be attached to resources. The key must be unique within the resource. The attribute can have a type of 'string', 'number', or 'boolean' and can optionally be a list of values or read-only. |
| `SANITY_CREATE_PROMPT_POST` | Create Prompt Post | Send a one-shot prompt to the Sanity Content Agent. Stateless one-shot prompt endpoint. No thread management or message persistence. Ideal for simple, single-turn interactions. Use when you need to send a single prompt and receive a response without maintaining conversation context. |
| `SANITY_DELETE_ATTR_DEFINITION` | Delete User Attribute Definition | Delete a user attribute definition. Use when you need to remove a custom attribute definition from an organization or project in Sanity. The attribute definition controls how user attributes are structured and validated for a given resource. Deleting a definition does not delete existing user attribute values, but users will no longer be able to set values for that attribute. |
| `SANITY_DELETE_DOCUMENT` | Delete Document | Delete a document from Sanity by ID or query. This action is irreversible when purge is true — the document cannot be recovered once permanently deleted. Use when you need to remove a specific document by ID or bulk delete documents matching a GROQ query (limited to 10,000 documents per operation). For large deletions, paginate by document ID. Set dry_run to true to test the operation without modifying data. |
| `SANITY_DELETE_USER_ATTRIBUTES` | Delete User Attributes | Delete custom attributes from a Sanity user within an organization. Use this tool when you need to remove specific custom attributes from a user account. The action deletes the attributes specified in the request and returns the updated attribute list for the user. Example use case: Removing outdated metadata like 'location' or 'year_started' from a user profile. |
| `SANITY_GET_DOCUMENT` | Get Document by ID | Fetch a single document by its ID from Sanity. Use this action when you need to retrieve a specific document using its unique identifier rather than running a GROQ query. Returns the complete document with all system fields including _id, _type, _rev, _createdAt, and _updatedAt. |
| `SANITY_GET_INVITE_BY_TOKEN` | Get Invite By Token | Retrieve an invite by its public token. Use this action when you need to fetch details about an invite using the invite token that was shared with the invitee. Returns invite information including status, role, and inviter details. |
| `SANITY_GET_ORG_ROLE` | Get Organization Role | Retrieve a specific organization role by its ID. Use this action when you need to fetch details about an organization role including its permissions, title, description, and whether it applies to users or robots. The role must exist for the specified organization. |
| `SANITY_GET_PERMISSION` | Get Permission | Get a permission for a specific resource. Use when you need to retrieve details about a particular permission including its actions, parameters, and scope. The action retrieves permission information based on the resource type, resource ID, and permission name provided in the path parameters. |
| `SANITY_GET_PROJECT` | Get Project | Retrieve full details for a specific Sanity project by its ID. Returns comprehensive project information including display name, organization, studio host, and timestamps. Use this action when you need to fetch complete project details or verify project configuration. Optional parameters allow including member lists and feature flags in the response. |
| `SANITY_GET_ROBOTS` | Get Robots | Tool to get robots with access to a resource. Use when you need to retrieve a list of robots (service accounts) that have been granted access to a specific resource along with their assigned roles. This action supports pagination through the next_cursor parameter. |
| `SANITY_GET_ROLE` | Get Role | Retrieve a specific role for a given resource type and resource ID. Use this action when you need to fetch details about a role including its permissions, title, description, and whether it applies to users or robots. The role must exist for the specified resource. |
| `SANITY_GET_USERS` | List Resource Users | List all users of a resource and their assigned roles. Use when you need to retrieve user information and role assignments for a specific project or organization. Supports pagination via cursor. |
| `SANITY_LIST_ORG_ROLES` | List Organization Roles | List all roles available for an organization. Use this action to retrieve all available roles that can be assigned to users within a specific Sanity organization. The organization_id is required to identify which organization's roles to list. |
| `SANITY_LIST_USER_ATTRIBUTES` | List User Attributes | Tool to retrieve user attributes from a Sanity organization. Use when you need to get the attributes (such as roles, permissions, or custom properties) associated with a specific user in a Sanity organization. Supports pagination via the cursor parameter. |
| `SANITY_QUERY_ALL_SCREENING` | Query All Screening | Execute a GROQ query to fetch all screening documents from Sanity. Uses the Sanity HTTP query API endpoint. Default query retrieves all documents of type 'screening'. Supports optional query parameters for dynamic queries. |
| `SANITY_QUERY_DOCUMENTS` | Query Documents | Execute an arbitrary GROQ query against a Sanity dataset. GROQ is Sanity's query language for fetching and transforming content. This is a general-purpose query action distinct from any screening-specific tools. Use this action when you need to query documents from a Sanity dataset using custom GROQ queries. Supports optional parameters, perspective control, and CDN optimization. |
| `SANITY_UPDATE_ORG_ACL` | Update Organization ACL | Tool to assign a role to a member in a Sanity organization. Use when adding or modifying user roles within an organization. |
| `SANITY_UPDATE_USER_ATTRIBUTES_VALUES` | Update User Attributes Values | Update user attribute values for a resource. Use this action to set or update custom attributes for a user within an organization or project. When setting a value for an attribute key that also exists in SAML, the Sanity value will take precedence and shadow the SAML value. |
| `SANITY_VALIDATE_CREDENTIAL` | Validate Credential | Validate Sanity API credentials by fetching the authenticated user's information. Use this action when you need to verify that an API token is valid and has proper authentication. This action returns user information and accessible projects if the token is valid. |

## Supported Triggers

None listed.

## Installation and MCP Setup

### Path 1: SDK Installation

#### Path 1, Step 1: Install Composio

Install the Composio SDK
```python
pip install composio_openai
```

```typescript
npm install @composio/openai
```

#### Path 1, Step 2: Initialize Composio and Create Tool Router Session

Import and initialize Composio client, then create a Tool Router session
```python
from openai import OpenAI
from composio import Composio
from composio_openai import OpenAIResponsesProvider

composio = Composio(provider=OpenAIResponsesProvider())
openai = OpenAI()
session = composio.create(user_id='your-user-id')
```

```typescript
import OpenAI from 'openai';
import { Composio } from '@composio/core';
import { OpenAIResponsesProvider } from '@composio/openai';

const composio = new Composio({
  provider: new OpenAIResponsesProvider(),
});
const openai = new OpenAI({});
const session = await composio.create('your-user-id');
```

#### Path 1, Step 3: Execute Sanity Tools via Tool Router with Your Agent

Get tools from Tool Router session and execute Sanity actions with your Agent
```python
tools = session.tools
response = openai.responses.create(
  model='gpt-4.1',
  tools=tools,
  input=[{
    'role': 'user',
    'content': 'List the latest published posts from my Sanity project'
  }]
)
result = composio.provider.handle_tool_calls(
  response=response,
  user_id='your-user-id'
)
print(result)
```

```typescript
const tools = session.tools;
const response = await openai.responses.create({
  model: 'gpt-4.1',
  tools: tools,
  input: [{
    role: 'user',
    content: 'List the latest published posts from my Sanity project'
  }],
});
const result = await composio.provider.handleToolCalls(
  'your-user-id',
  response.output
);
console.log(result);
```

### Path 2: MCP Server Setup

#### Path 2, Step 1: Install Composio

Install the Composio SDK for Python or TypeScript
```python
pip install composio claude-agent-sdk
```

```typescript
npm install @composio/core ai @ai-sdk/openai @ai-sdk/mcp
```

#### Path 2, Step 2: Initialize Client and Create Tool Router Session

Import and initialize the Composio client, then create a Tool Router session for Sanity
```python
from composio import Composio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions

composio = Composio(api_key='your-composio-api-key')
session = composio.create(user_id='your-user-id')
url = session.mcp.url
```

```typescript
import { Composio } from '@composio/core';

const composio = new Composio({ apiKey: 'your-api-key' });
const session = await composio.create('your-user-id');
console.log(`Tool Router session created: ${session.mcp.url}`);
```

#### Path 2, Step 3: Connect to AI Agent

Use the MCP server with your AI agent (Anthropic Claude or Mastra)
```python
import asyncio

options = ClaudeAgentOptions(
    permission_mode='bypassPermissions',
    mcp_servers={
        'tool_router': {
            'type': 'http',
            'url': url,
            'headers': {
                'x-api-key': 'your-composio-api-key'
            }
        }
    },
    system_prompt='You are a helpful assistant with access to Sanity tools.',
    max_turns=10
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        await client.query('Create a draft blog post in Sanity about our spring product launch')
        async for message in client.receive_response():
            if hasattr(message, 'content'):
                for block in message.content:
                    if hasattr(block, 'text'):
                        print(block.text)

asyncio.run(main())
```

```typescript
import { openai } from '@ai-sdk/openai';
import { experimental_createMCPClient as createMCPClient } from '@ai-sdk/mcp';
import { generateText } from 'ai';

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: session.mcp.url,
    headers: {
      'x-api-key': 'your-composio-api-key',
    },
  },
});

const tools = await client.tools();
const { text } = await generateText({
  model: openai('gpt-4o'),
  tools,
  messages: [{
    role: 'user',
    content: 'Create a draft blog post in Sanity about our spring product launch'
  }],
  maxSteps: 5,
});

console.log(`Agent: ${text}`);
```

## Why Use Composio?

### 1. AI Native Sanity Integration

- Supports both Sanity MCP and direct API based integrations
- Structured, LLM-friendly schemas for reliable content operations
- Rich coverage for querying, creating, and updating Sanity CMS data

### 2. Managed Auth

- Store Sanity API keys securely instead of hard-coding them in agent code
- Central place to manage, scope, and revoke Sanity access
- Per user and per environment credentials for cleaner content workflows

### 3. Agent Optimized Design

- Tools are designed so agents can understand Sanity content tasks clearly
- Comprehensive execution logs so you always know what content action ran, when, and on whose behalf
- Reliable tool routing for practical CMS workflows like drafting, querying, and updates

### 4. Enterprise Grade Security

- Fine-grained RBAC so you control which agents and users can access Sanity
- Scoped, least privilege access to Sanity projects and datasets
- Full audit trail of agent actions to support content review and compliance

## Use Sanity with any AI Agent Framework

Choose a framework you want to connect Sanity with:

- [Claude Cowork](https://composio.dev/toolkits/sanity/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/sanity/framework/codex)

## Related Toolkits

- [Google Drive](https://composio.dev/toolkits/googledrive) - Google Drive is a cloud storage platform for uploading, sharing, and collaborating on files. It's perfect for keeping your documents accessible and organized across devices.
- [Google Docs](https://composio.dev/toolkits/googledocs) - Google Docs is a cloud-based word processor that enables document creation and real-time collaboration. Its seamless sharing and version history make team editing and content management a breeze.
- [Google Super](https://composio.dev/toolkits/googlesuper) - Google Super is an all-in-one suite combining Gmail, Drive, Calendar, Sheets, Analytics, and more. It gives you a unified platform to manage your digital life, boosting productivity and organization.
- [Affinda](https://composio.dev/toolkits/affinda) - Affinda is an AI-powered document processing platform that automates data extraction from resumes, invoices, and more. It streamlines document-heavy workflows by turning files into structured, actionable data.
- [Agility cms](https://composio.dev/toolkits/agility_cms) - Agility CMS is a headless content management system for building and managing digital experiences across platforms. It lets teams update content quickly and deliver omnichannel experiences with ease.
- [Algodocs](https://composio.dev/toolkits/algodocs) - Algodocs is an AI-powered platform that automates data extraction from business documents. It delivers fast, secure, and accurate processing without templates or manual training.
- [Api2pdf](https://composio.dev/toolkits/api2pdf) - Api2Pdf is a REST API for generating PDFs from HTML, URLs, and documents using powerful engines like wkhtmltopdf and Headless Chrome. It streamlines document conversion and automation for developers and businesses.
- [Aryn](https://composio.dev/toolkits/aryn) - Aryn is an AI-powered platform for parsing, extracting, and analyzing data from unstructured documents. Use it to automate document processing and unlock actionable insights from your files.
- [Boldsign](https://composio.dev/toolkits/boldsign) - Boldsign is a digital eSignature platform for sending, signing, and tracking documents online. Organizations use it to automate agreements and manage legally binding workflows efficiently.
- [Boloforms](https://composio.dev/toolkits/boloforms) - BoloForms is an eSignature platform built for small businesses, offering unlimited signatures, templates, and forms. It simplifies digital document signing and team collaboration at a predictable, fixed price.
- [Box](https://composio.dev/toolkits/box) - Box is a cloud content management and file sharing platform for businesses. It helps teams securely store, organize, and collaborate on files from anywhere.
- [Carbone](https://composio.dev/toolkits/carbone) - Carbone is a blazing-fast report generator that turns JSON data into PDFs, Word docs, spreadsheets, and more using flexible templates. It lets you automate document creation at scale with minimal code.
- [Castingwords](https://composio.dev/toolkits/castingwords) - CastingWords is a transcription service specializing in human-powered, accurate transcripts via a simple API. Get seamless audio-to-text conversion for interviews, meetings, podcasts, and more.
- [Cloudconvert](https://composio.dev/toolkits/cloudconvert) - CloudConvert is a powerful file conversion service supporting over 200 file formats. It streamlines converting, compressing, and managing documents, media, and more, all in one place.
- [Cloudlayer](https://composio.dev/toolkits/cloudlayer) - Cloudlayer is a document and asset generation service for creating PDFs and images via API or SDKs. It lets you automate high-quality doc creation, saving dev time and reducing manual work.
- [Cloudpress](https://composio.dev/toolkits/cloudpress) - Cloudpress is a content export tool for Google Docs and Notion. It automates publishing to your favorite Content Management Systems.
- [Contentful graphql](https://composio.dev/toolkits/contentful_graphql) - Contentful graphql is a content delivery API that lets you access Contentful data using GraphQL queries. It gives you efficient, flexible ways to fetch and manage structured content for any digital project.
- [Conversion tools](https://composio.dev/toolkits/conversion_tools) - Conversion Tools is an online service for converting documents between formats such as PDF, Word, Excel, XML, and CSV. It lets you automate complex document workflows with just a few clicks.
- [Convertapi](https://composio.dev/toolkits/convertapi) - ConvertAPI is a robust file conversion service for documents, images, and spreadsheets. It streamlines programmatic format changes and lets developers automate complex workflows with a single API.
- [Craftmypdf](https://composio.dev/toolkits/craftmypdf) - CraftMyPDF is a web-based service for designing and generating PDFs with templates and live data. It streamlines document creation by automating personalized PDFs at scale.

## Frequently Asked Questions

### Do I need my own developer credentials to use Sanity with Composio?

Yes, Sanity requires you to configure your own API key. Once set up, Composio handles secure credential storage and API request handling for you.

### Can I use multiple toolkits together?

Yes! Composio's Tool Router enables agents to use multiple toolkits. [Learn more](https://docs.composio.dev/tool-router/overview).

### Is Composio secure?

Composio is SOC 2 and ISO 27001 compliant with all data encrypted in transit and at rest. [Learn more](https://trust.composio.dev).

### What if the API changes?

Composio maintains and updates all toolkit integrations automatically, so your agents always work with the latest API versions.

---
[See all toolkits](https://composio.dev/toolkits) · [Composio docs](https://docs.composio.dev/llms.txt)
