APIs and SDKs

Content releases and versions with @sanity/client

Learn how to create releases, manage document versions, and schedule publishing using the Sanity JavaScript client.

Content releases let you group document changes and publish them together. The @sanity/client library provides helper methods on the client.releases namespace for managing releases, along with top-level methods for working with document versions.

These methods require an authenticated client with a write token. See Getting started with @sanity/client for setup instructions.

Create a release

Use client.releases.create() to create a new release. The method returns an object containing the releaseId, which you use to add document versions to the release.

The releaseType can be scheduled, asap, or undecided.

Add document versions to a release

Use client.createVersion() to add a new or modified document to a release. You provide the releaseId, the published document's ID, and the document content.

This creates a versioned document with the ID versions.<releaseId>.product-123 in your dataset. The published document remains unchanged until the release is published.

Mark a document for unpublishing

Use client.unpublishVersion() to mark a document for removal when the release runs. The document stays published until the release is executed.

Get a release and its documents

Retrieve a release's metadata with client.releases.get(), and list its documents with client.releases.getDocuments().

Schedule a release

Schedule a release to publish at a specific time with client.releases.schedule(). Pass an ISO 8601 date string as the publishAt value.

Delete a release after publishing

After a release has been published, you can clean it up with client.releases.delete(). Check the release state first to confirm it has completed successfully.

Full example: create and schedule a release

Here's a complete workflow that creates a release, adds document versions, and schedules it to publish:

Release actions with the Actions API

The helper methods shown above use the client.action() method under the hood. If you need more control, you can dispatch release actions directly. This lets you archive, unarchive, and unschedule releases, as well as create, discard, and replace individual document versions.

For example, to archive and then unarchive a release:

You can also manage individual document versions through actions:

For the full list of available action types and their options, see Mutate documents with actions.

Next steps

Was this page helpful?