Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Scheduled publishing

Schedule your content for future publication and organize upcoming releases – no custom tasks or serverless functions required!

Scheduled Publishing is now part of Sanity Studio

Scheduled Publishing used to be a plugin, but is now part of the core Sanity Studio package. It still requires use of the Sanity Scheduling API which is available on Growth plans and above.

Features

Create and edit schedules directly from the document editor

  • Create and edit schedules for the document you're working on
  • See current schedule status and potential validation issues

View all your schedules with our dedicated tool

  • Filter all schedules by status or use the calendar to browse by date
  • Edit, delete, and immediately publish schedules
  • Automatically validate upcoming schedules, and identify issues before they're published
  • Easily identify who created a schedule

View schedule dates in any remote time zone

  • Change the time zone you want to preview schedules in by clicking the 🌎 Time Zone button when visible. Great when you need to co-ordinate with a global team or want to time publication to specific regions.
  • Easily select time zones by city, time zone abbreviation or name search.
    • Selected time zones are automatically stored in your local storage for future use.

Getting started

If you are starting from scratch, skip the following section on uninstalling the plugin and cleaning up old configuration and jump directly to the next section on how to configure or disable Scheduled Publishing.

Uninstall the plugin

If you are already using Scheduled Publishing plugin, the first step is to get rid of it and update your studio to the latest release. If you already updated your studio you might have gotten an alert about this.

Run the following command in your project root to uninstall the plugin:

npm uninstall @sanity/scheduled-publishing

Next, remove the plugin from your studio configuration. Typically you'll find this in ./sanity.config.ts|js. Find and delete the following lines from your configuration:

// ./sanity.config.ts|js

import {scheduledPublishing} from '@sanity/scheduled-publishing'
export default defineConfig({ // ... plugins: [
scheduledPublishing()
], })

Your plugin declaration might be a bit more expansive if you've defined a custom time format for the plugin. Delete it all!

// ./sanity.config.ts|js

import {scheduledPublishing} from '@sanity/scheduled-publishing'
export default defineConfig({ // ... plugins: [
scheduledPublishing({
inputDateTimeFormat: 'MM/dd/yyyy h:mm a',
}),
], })

Protip

You might also have defined some custom document actions and badges to support Scheduled Publishing. You can keep these around, and they'll continue to work after migrating to the core studio functionality. Refer to the section on document actions and badges further on in this article.

Add new configuration for Scheduled Publishing

Note that while very similar to the plugin config this goes into the top-level of your studio configuration. Setting enabled to false will opt you out of using scheduled publishing for the project.

// ./sanity.config.ts|js
import {defineConfig} from 'sanity'

defineConfig({ 
  // ....
  scheduledPublishing: {
    enabled: true, 
    inputDateTimeFormat: 'MM/dd/yyyy h:mm a',
  }
)

As before, you can add a custom time format if you so wish. If left unspecified, the format will default to dd/MM/yyyy HH:mm.

Document actions and badges

You can further enhance your Scheduled Publishing experience with custom document actions and badges.

Configure the document action

This example assumes you've customized your document actions and would like to only show the Schedule button on movie documents only.

The Schedule document action allows users to both create and edit existing schedules directly from the form editor. It is added to all document types by the plugin, so you should remove it from types that should NOT have it.

// ./sanity.config.ts|js

import {defineConfig, ScheduleAction} from 'sanity'
export default defineConfig({ // ... document: { actions: (previousActions, {schemaType}) => { /* * Please note that this will only alter the visibility of the button in the studio. * Users with document publish permissions will be able to create schedules directly * via the Scheduled Publishing API. */ if (schemaType.name !== 'movie') { // Remove the schedule action from any documents that is not 'movie'. return previousActions.filter((action) => action !== ScheduleAction) } return previousActions }, }, })

Note that ScheduleAction is now imported from the core sanity package.

Configure the document badge

This example assumes you've customised your own document badges and would like to only show the Scheduled badge on movie documents only.

The Scheduled document badge displays whether the current document is scheduled and when it will be published if so. It is added to all document types by the plugin, so you should remove it from types that should NOT have it.

// ./sanity.config.ts|js

import {defineConfig, ScheduledBadge} from 'sanity'
export default defineConfig({ // ... document: { actions: (previousBadges, {schemaType}) => { if (schemaType.name !== 'movie') { // Remove the schedule badge from any documents that is not 'movie'. return previousBadges.filter((badge) => badge !== ScheduledBadge) } return previousBadges }, }, })

Note that ScheduleBadge is now imported from the core sanity package.

Frequently Asked Questions

What's the relationship between Schedules and my dataset?

Schedules sit adjacent to your dataset and can be managed using the Scheduling API (which this plugin does for you).

Schedules are a unique resource and are linked to, but do not exist within your Sanity project and dataset. It's important to understand the following behavior:

  • As schedules are not contained within a project’s dataset, you cannot query them via GROQ or GraphQL.
  • Deleting a dataset will immediately delete all schedules.
  • Deleting a project will immediately delete all schedules.
  • sanity dataset export will not include schedules and sanity dataset import does not support importing schedules.
  • Server-side copying of datasets does not include schedules.
  • When a project is disabled or blocked, all scheduled publishes will invariably fail as mutations will not be allowed on the dataset.

More information can be found in the Scheduling API article.

Will scheduled documents with validation errors publish?

Yes. Documents scheduled to publish in future will do so, even if they contain validation errors. This also applies to scheduled documents that you manually opt to publish immediately via the tool.

Was this article helpful?