Skip to main content
After connecting your Sanity account, the following actions become available as Agent steps. Each step requires you to select a connected Sanity Project from a dropdown.

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)
Optional inputs
  • 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
By default, new documents are created as drafts. Profound automatically generates a draft ID prefixed with 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:
TypeExample Use
postBlog articles
pageStatic pages
productE-commerce products
authorContent creators
categoryTaxonomy/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)
When you create a resource without enabling Publish Resource, Profound automatically creates it as a draft. You can later publish it using the Publish Resource step, or publish directly from Sanity Studio.

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:

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 a post type with these fields:
// In your Sanity Studio schema
defineType({
  name: 'post',
  title: 'Post',
  type: 'document',
  fields: [
    defineField({ name: 'title', type: 'string' }),
    defineField({ name: 'slug', type: 'slug' }),
    defineField({ name: 'author', type: 'reference', to: [{ type: 'author' }] }),
    defineField({ name: 'body', type: 'blockContent' }),
    defineField({ name: 'publishedAt', type: 'datetime' }),
    defineField({ name: 'categories', type: 'array', of: [{ type: 'reference', to: [{ type: 'category' }] }] }),
  ],
})

Step-by-Step Setup

  1. Add a Create Resource step to your Agent and select your connected Sanity project from the Sanity Project dropdown.
  2. Select the Dataset from the dropdown (e.g., production).
  3. Fill in Document Details with your document fields as JSON. This is where you provide simple values like titles, slugs, references, and categories:
    {
      "_type": "post",
      "title": "My Post Title",
      "slug": {
        "_type": "slug",
        "current": "my-post-title"
      },
      "author": {
        "_type": "reference",
        "_ref": "author-id-123"
      },
      "publishedAt": "2025-01-15T10:30:00Z",
      "categories": [
        {
          "_type": "reference",
          "_ref": "category-id-456"
        }
      ]
    }
    
    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.
  4. 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:
    {
      "body": "<h1>Welcome</h1><p>This is my post content.</p>"
    }
    
    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.
  5. 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 TypeJSON Format in Data
string"value"
text"multi-line value"
number42
booleantrue / 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" } }
blockContentUse 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

  1. LLM Step — Generate a title, slug, and HTML body from a prompt
  2. Create Resource — Create a Sanity post document using the generated content
  3. Publish Resource — Publish the draft (or set publish_resource: true in step 2)

Update Existing Content

  1. Get Resource — Fetch the current document by ID
  2. LLM Step — Generate updated content based on the existing document
  3. Update Resource — Patch only the fields that changed

Content Migration

  1. List Resources — Fetch documents from one dataset
  2. Loop — Iterate over the list
  3. Create Resource — Create each document in a different dataset

Draft Review Pipeline

  1. Create Resource — Create content as a draft (default behavior)
  2. Human Review — Manual review step in Sanity Studio
  3. 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:
RoleCan CreateCan UpdateCan PublishCan Read
AdministratorYesYesYesYes
EditorYesYesYesYes
DeveloperYesYesYesYes
ViewerNoNoNoYes
Minimum required role: Editor. Tokens with Viewer-only access will fail when attempting to create, update, or publish documents.

Troubleshooting

Your API token is invalid or has expired. Generate a new token in your Sanity management console under API → Tokens and reconnect.
Your API token doesn’t have Editor-level access. Create a new token with Editor permissions and reconnect.
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.
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" }.
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.
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: