- Create resource
- Update resource
- Get resource
- List resources
- Publish resource
Create Resource
Create a new document in your Sanity dataset.Required inputs- Sanity Project — Select the Sanity project you connected in Profound
- Dataset — Select the dataset (e.g.,
production) - Document Details — A JSON object with your document fields (must include
_type)
- Rich Text Content — A JSON object mapping field names to HTML strings. Profound automatically converts HTML to Sanity’s Portable Text format
- Publish Resource — Check this to publish immediately, or leave unchecked to create a draft
drafts. for you. Enable Publish Resource to make the document live immediately.Tip: Leave Publish Resource unchecked to create drafts for review in Sanity Studio before publishing.
Key Concepts
Documents and Types
Every document in Sanity has a_type field that determines its schema. Sanity types are the equivalent of “content models” or “templates” — they define the structure and fields a document can have.
When creating a document with the Create Resource step, the _type field in your data determines which schema the document follows. The type must already exist in your Sanity project’s schema.
Common examples of document types:
| Type | Example Use |
|---|---|
post | Blog articles |
page | Static pages |
product | E-commerce products |
author | Content creators |
category | Taxonomy/classification |
Tip: To see which types exist in your project, use the List Resources step without a type filter — the returned documents will show the available
_type values.Datasets
Sanity projects can have multiple datasets (e.g.,production, staging, development). Each dataset is an independent content store. Always specify the correct dataset when configuring your Agent steps.
Drafts vs. Published
Sanity uses a dual-ID system for content versioning:- Published documents have a plain ID (e.g.,
abc123) - Draft documents have the same ID prefixed with
drafts.(e.g.,drafts.abc123)
Working with Portable Text (Rich Text)
Sanity uses Portable Text as its native rich text format. Portable Text is a JSON-based specification that represents structured content as an array of blocks.Providing Rich Text Content
You have two options for providing rich text content to Sanity fields:- HTML input (recommended)
- Native Portable Text JSON
Use the Rich Text Content field to pass HTML strings. Profound automatically converts them to Portable Text blocks.Map field names to HTML strings:Supported HTML elements:
| Element | Portable Text equivalent |
|---|---|
<h1> through <h6> | Heading styles |
<p> | Normal paragraph |
<strong>, <b> | Bold mark |
<em>, <i> | Italic mark |
<u> | Underline mark |
<code> | Code mark |
<a href="..."> | Link annotation |
<ul>, <ol>, <li> | Bullet and numbered lists |
<blockquote> | Blockquote style |
<br> | Line break |
Tip: This is the easiest way to get rich text into Sanity. Generate HTML from an LLM step and pass it directly to Rich Text Content — Profound handles the conversion.
Mapping Sanity Schemas to Agent Steps
If you have an existing Sanity schema (document type), here’s how to map it to a Create Resource step in your Agent.Example: Blog Post Schema
Suppose your Sanity Studio has apost type with these fields:
Step-by-Step Setup
- Add a Create Resource step to your Agent and select your connected Sanity project from the Sanity Project dropdown.
-
Select the Dataset from the dropdown (e.g.,
production). -
Fill in Document Details with your document fields as JSON. This is where you provide simple values like titles, slugs, references, and categories:
To use dynamic values from upstream steps, type
/inside the field to open the variable menu and select a variable. It will appear as a pill badge inline with your JSON — for example, you could replace"My Post Title"with a variable from a previous LLM step. -
Fill in Rich Text Content for any Portable Text fields (like a blog body). Map the field name to an HTML string — Profound converts it to Sanity’s format automatically:
You can also insert a variable here to pass in HTML generated by a previous step. Type
/to open the variable menu and select the output from an LLM or other upstream step as the value. - Check or uncheck Publish Resource — check it to publish immediately, or leave it unchecked to create a draft for review in Sanity Studio.
Tip: Any text field in the node settings supports variables — type
/ to open the variable menu and insert outputs from upstream steps. Variables appear as interactive pill badges and are resolved at runtime.Field Type Reference
| Sanity Field Type | JSON Format in Data |
|---|---|
string | "value" |
text | "multi-line value" |
number | 42 |
boolean | true / false |
datetime | "2025-01-15T10:30:00Z" |
date | "2025-01-15" |
url | "https://example.com" |
slug | { "_type": "slug", "current": "my-slug" } |
reference | { "_type": "reference", "_ref": "document-id" } |
image | { "_type": "image", "asset": { "_type": "reference", "_ref": "image-asset-id" } } |
blockContent | Use Rich Text Content field for automatic conversion, or pass Portable Text JSON directly |
array of references | [{ "_type": "reference", "_ref": "id" }] |
object | { "fieldA": "value", "fieldB": 42 } |
Common Workflows
Generate and Publish a Blog Post
- LLM Step — Generate a title, slug, and HTML body from a prompt
- Create Resource — Create a Sanity
postdocument using the generated content - Publish Resource — Publish the draft (or set
publish_resource: truein step 2)
Update Existing Content
- Get Resource — Fetch the current document by ID
- LLM Step — Generate updated content based on the existing document
- Update Resource — Patch only the fields that changed
Content Migration
- List Resources — Fetch documents from one dataset
- Loop — Iterate over the list
- Create Resource — Create each document in a different dataset
Draft Review Pipeline
- Create Resource — Create content as a draft (default behavior)
- Human Review — Manual review step in Sanity Studio
- Publish Resource — Publish approved drafts via the Agent
Permissions and Roles
Profound validates that your API token has sufficient permissions on connection. The following Sanity roles are supported:| Role | Can Create | Can Update | Can Publish | Can Read |
|---|---|---|---|---|
| Administrator | Yes | Yes | Yes | Yes |
| Editor | Yes | Yes | Yes | Yes |
| Developer | Yes | Yes | Yes | Yes |
| Viewer | No | No | No | Yes |
Minimum required role: Editor. Tokens with Viewer-only access will fail when attempting to create, update, or publish documents.
Troubleshooting
Error: Invalid Sanity API key or token has expired
Error: Invalid Sanity API key or token has expired
Your API token is invalid or has expired. Generate a new token in your Sanity management console under API → Tokens and reconnect.
Error: Insufficient permissions
Error: Insufficient permissions
Your API token doesn’t have Editor-level access. Create a new token with Editor permissions and reconnect.
Error: Sanity project not found
Error: Sanity project not found
The Project ID in your integration settings is incorrect. Verify the Project ID in your Sanity management console — it’s displayed at the top of your project page and in the URL.
Error: Document type (_type) must be provided
Error: Document type (_type) must be provided
When using Create Resource, your Data field must include a
_type property that matches a document type defined in your Sanity schema. For example: { "_type": "post", "title": "Hello" }.Error: Resource ID is not a draft
Error: Resource ID is not a draft
The Publish Resource step requires a draft document ID that starts with
drafts.. If the document is already published, it doesn’t need to be published again. Check that you’re passing the draft ID, not the published ID.HTML not converting to rich text correctly
HTML not converting to rich text correctly
Make sure you’re using the Rich Text Content field (not the Document Details field) for HTML-to-Portable-Text conversion. The Rich Text Content field expects a JSON object mapping field names to HTML strings:
{ "body": "<p>Hello</p>" }.Additional Resources
Learn more about Sanity’s content model and API:- Sanity Content Lake — Understanding datasets and documents
- Portable Text — Sanity’s rich text format specification
- GROQ Query Language — Querying content in Sanity
- HTTP API Reference — Full Sanity API documentation
- Mutations API — Creating, updating, and deleting documents