Content Agent API reference
HTTP reference documentation for the Content Agent API
The Content Agent API allows you to integrate Content Agent into your own applications via HTTP. It uses Server-Sent Events (SSE) for streaming responses, fully compatible with the Vercel AI SDK.
Base API server URL
Production API (preview)
https://api.sanity.io/vX/agentChat
Conversational endpoints with thread management
Send a chat message
/{organizationId}/threads/{threadId}Send a message to the agent and receive a streaming response. This endpoint manages conversation threads and persists message history.
Path parameters
Your Sanity organization ID
Example:abc123Unique identifier for the conversation thread
Example:my-conversation-thread
Request body application/json
Array of message objects
- applicationobject
Target Sanity application configuration
Show child attributes
- keystring
Application key in format "projectId.datasetName"
Example:abc123.production - resourceobject
- intentBaseUrlstring (uri)
Base URL for the Sanity Studio
Example:https://your-studio.sanity.studio - bundleVersionstring
Bundle version
- namestring
Application name
- titlestring
Application title
- schemaDescriptorIdstring
Schema descriptor ID
- configobject
Agent configuration. Controls behavior, capabilities, and document access.
Show child attributes
- instructionstring
Custom instruction string to include in the system prompt
Example:You are a helpful content assistant. - userMessageContextobject
Key-value pairs appended to each user message as XML tags. Each key becomes an XML tag with the value as content. Example: { "slack-channel": "#marketing" } renders as
#marketing Example{"slack-channel":"#marketing","user-role":"editor"} - capabilitiesobject
Agent capabilities that control what operations are allowed. Each capability can be a boolean or an object with a preset.
Example{"read":true,"write":false}Show child attributes
A capability can be:
- true: Full access (standard preset)
- false: No access
- { preset: 'minimal' | 'standard' }: Explicit preset selection
Show child attributes
- boolean
true = standard preset, false = disabled
A capability can be:
- true: Full access (standard preset)
- false: No access
- { preset: 'minimal' | 'standard' }: Explicit preset selection
Show child attributes
- boolean
true = standard preset, false = disabled
- featuresobject
Explicit feature overrides applied on top of capability-derived defaults. When not specified, features use values derived from read/write capability presets.
Show child attributes
- webSearchboolean
Override web search availability. By default, web search is enabled when read capability is 'standard'.
- filterobject
GROQ filter expressions for document access control
Show child attributes
- perspectivesobject
Perspective locking configuration. Controls which document perspectives the agent can read from and write to. Values are Sanity perspective IDs: 'drafts', 'published', 'raw', or release/bundle IDs.
Show child attributes
- readarray
Allowed read perspectives. When set, query tools can only use these perspectives. If the agent tries to use a disallowed perspective, the request is rejected with an error.
Example["drafts","published"]Show child attributes
items
- string
- writestring
The write perspective. When set, new documents are created in this perspective and mutations are restricted to documents whose ID matches it.
Example:drafts
Enable or disable streaming responses
Controls how directives in the response are formatted.
- markdown (default): Directives are resolved server-side into standard markdown (e.g., links with titles).
- directives: Raw directive syntax is preserved (e.g.,
::document{id="doc-id"}), useful for clients that render custom UI components.
application/json{
"messages": [
{
"role": "user",
"content": "What blog posts do I have?"
}
]
}Responses
Streaming response
- string
Server-Sent Events stream following Vercel AI Data Stream Protocol
application/jsonPrompt
Stateless prompt endpoints
Send a one-shot prompt
/promptStateless one-shot prompt endpoint. No thread management or message persistence. Ideal for simple, single-turn interactions.
Request body application/json
Your Sanity organization ID
Example:abc123The prompt message
Example:Summarize my latest blog posts- configobject
Agent configuration. Controls behavior, capabilities, and document access.
Show child attributes
- instructionstring
Custom instruction string to include in the system prompt
Example:You are a helpful content assistant. - userMessageContextobject
Key-value pairs appended to each user message as XML tags. Each key becomes an XML tag with the value as content. Example: { "slack-channel": "#marketing" } renders as
#marketing Example{"slack-channel":"#marketing","user-role":"editor"} - capabilitiesobject
Agent capabilities that control what operations are allowed. Each capability can be a boolean or an object with a preset.
Example{"read":true,"write":false}Show child attributes
A capability can be:
- true: Full access (standard preset)
- false: No access
- { preset: 'minimal' | 'standard' }: Explicit preset selection
Show child attributes
- boolean
true = standard preset, false = disabled
A capability can be:
- true: Full access (standard preset)
- false: No access
- { preset: 'minimal' | 'standard' }: Explicit preset selection
Show child attributes
- boolean
true = standard preset, false = disabled
- featuresobject
Explicit feature overrides applied on top of capability-derived defaults. When not specified, features use values derived from read/write capability presets.
Show child attributes
- webSearchboolean
Override web search availability. By default, web search is enabled when read capability is 'standard'.
- filterobject
GROQ filter expressions for document access control
Show child attributes
- perspectivesobject
Perspective locking configuration. Controls which document perspectives the agent can read from and write to. Values are Sanity perspective IDs: 'drafts', 'published', 'raw', or release/bundle IDs.
Show child attributes
- readarray
Allowed read perspectives. When set, query tools can only use these perspectives. If the agent tries to use a disallowed perspective, the request is rejected with an error.
Example["drafts","published"]Show child attributes
items
- string
- writestring
The write perspective. When set, new documents are created in this perspective and mutations are restricted to documents whose ID matches it.
Example:drafts
- instructionsstring
Custom instructions for the agent
Example:Be concise and use bullet points Controls how directives in the response are formatted.
- markdown (default): Directives are resolved server-side into standard markdown.
- directives: Raw directive syntax is preserved for clients that render custom UI.
application/json{
"organizationId": "abc123",
"message": "Summarize my latest blog posts",
"config": {
"capabilities": {
"read": true,
"write": false
}
}
}Responses
Streaming response
- string
Server-Sent Events stream following Vercel AI Data Stream Protocol