Skip to main content
Sanity is a headless CMS built around a real-time, structured content platform. Content is stored as portable, schema-driven documents in Sanity’s cloud-hosted Content Lake and managed through Sanity Studio — a fully customizable editing environment your team can adapt to any content model. Because Sanity exposes all content through a flexible API, it works equally well as the content backbone for websites, apps, and multi-channel publishing pipelines. Connect Sanity once and Gradial can read and write live content directly — enabling authoring, optimization, and publishing workflows without switching systems. Access: Must be enabled for your organization. Contact your Gradial team to get access. Until it is, the Sanity setup and the Grady Sanity tools are not available.

What You Can Do

Live content access

Read documents, schemas, and assets across your Sanity datasets so Gradial always works with real content rather than static exports.

Content authoring

Create and update documents. Publish and unpublish content. Run bulk update workflows with validation.

Asset management

Upload and manage images and file assets alongside content work.

In-context previews

Preview content before publishing when preview settings are configured under Settings → Integrations.

Prerequisites

Before connecting Sanity to Gradial, make sure you have:
  • Access to the Sanity management console (sanity.io/manage) with permission to create API tokens
  • Your Sanity Project ID (visible in the project overview)
  • The dataset name Gradial should use (commonly production)
  • A Gradial organization Administrator role to complete setup

How to Connect

1

Create a Project API token in Sanity

  1. Sign in to sanity.io/manage and open your project.
  2. Go to Settings → API → Tokens and click Add new token. You need the Developer or Administrator role, or an equivalent custom role, in the project.
  3. Give the token a descriptive name (e.g., Gradial Integration).
  4. Set the Permissions to Editor — this grants read and write access to all datasets, with limited access to project settings. Sanity lists the Editor role for Growth and Enterprise plans. If your plan doesn’t offer it, choose a role that can write to the dataset Gradial uses.
  5. Optionally set an expiration date. Save, then copy the token immediately — it is only shown once.
The API token is shown only once at creation time. If you lose it, you will need to delete it and generate a new one.
2

Locate your Project ID and dataset name

Your Project ID appears on the project overview page in sanity.io/manage. The default dataset is typically named production — confirm the dataset name under Datasets in the same project.
3

Add the integration in Gradial

  1. In Gradial, go to Settings → Integrations.
  2. Find Sanity and click + Add.
  3. Fill in the connection details:
  1. Click Save. Gradial validates the connection and uses the specified dataset in all downstream workflows.
4

Assign to an Environment

  1. Go to Settings → Environments and select the Gradial Environment where Sanity should be available.
  2. Add the Sanity integration to that Environment.
  3. Repeat for any additional Environments.

Using Sanity with Grady

Documents in the Task

When Grady writes a document, it can appear in the Task’s Artifacts with a badge. A new document shows Created. A replaced, patched, or published document shows Edited. A later read of the same document keeps that badge. A read that names a published or release perspective can appear as its own entry, so the same document can show up more than once. A few writes are not recorded as artifacts: dry runs, deletes, unpublishes, release versions, and asset uploads. A write that returns no document, or whose read-back fails, may not be recorded either.

Required fields

Sanity’s write API does not run your Studio validation, so Gradial checks required fields itself. Grady reads your deployed Studio schema and looks at the top-level fields it marks as required.
  • Drafts: the draft saves, and Grady reports the missing fields as a warning. Studio also lets you save an incomplete draft.
  • Published documents: a write that would create or replace a published document, or publish a draft, with a required field missing is refused. Nothing is sent to Sanity. The message names the document type and the missing fields.
The check covers whole-document creates, replaces, and publishes. Patches, release versions, document types it does not recognize, and a schema that is missing, unreadable, or slow to load skip the check, and the write goes through as before. If your Studio has several workspaces, a field counts as required only when every workspace that defines the type requires it.

Large uploads

Grady can upload a file from the Task’s files by file path, up to 100 MiB. This works for video, PDFs, and large images. Small files can still be sent inline.

Studio schema

Grady can read your deployed Studio schema before it drafts content. Grady uses the schema as guidance to ask you for required fields and to stay within character limits. This needs a schema deployed to your dataset. Gradial itself enforces only the required-field check described above.

Preview URLs

Previews use the Preview base URL, Page document types and Preview URL patterns you set under Settings → Integrations. A pattern with a full https:// URL works on its own. Without a matching pattern, a page document can fall back to the base URL. Enter one pattern per line, as documentType = URL. For example:
  • List each document type once.
  • Use only {document._id}, {document._type}, or {document.<field>} placeholders, such as {document.slug.current}.
Settings checks each line when you save. If a line is malformed, an inline message names it and nothing is saved. A pattern that is a path only, such as /articles/{document.slug.current}, needs a Preview base URL.
For draft previews, point the pattern at a page on your website that can render drafts. A Sanity Studio presentation URL can appear blank in the preview if it needs a Sanity login.

Troubleshooting

Token rejected at save Confirm the token was copied in full with no trailing spaces, and that it was created with Editor permissions. Dataset not found Verify the dataset name matches exactly what appears under Datasets in your Sanity project. Dataset names are case-sensitive. Invalid preview URL pattern Check the line the message names. Each line needs a document type, an equals sign, and a URL, and each document type can appear only once. Only {document._id}, {document._type}, and {document.<field>} placeholders are supported. Preview is blank A blank preview has several possible causes. If the pattern points at Sanity Studio, the frame may need a Sanity login. Open the preview in Sanity, or set a page pattern on your website for draft previews. Also check that the page can render drafts and that the pattern resolves to the page you expect. Preview failed to load The preview did not finish loading within 15 seconds. Check that your preview base URL and patterns point to a site that is reachable and allowed for this integration. Then try again. A document write was refused for a missing required field Add the fields the message names, or save the document as a draft. Integration not available in a Workspace Assign the integration to the correct Gradial Environment under Settings → Environments.

Support

Contact your Gradial onboarding lead or email [email protected] for help with setup.