focusreactive

payload plugin scheduling

by focusreactive
payload-plugins
Publishing workflow
v3
^3.90.0
MIT

Overview

Summary generated from the README

Enables Payload's built-in schedulePublish drafts feature on selected collections and globals, routes the resulting jobs into an isolated queue, and adds a Bearer-token-protected endpoint that a cron calls to run due jobs. Each scheduled publish runs with the rights of the user who scheduled it, rechecked at run time. Requires Payload 3.90 or later, the companion guard plugin, and a config wrapped in withAccessPolicy.

Features

  • Adds the Schedule Publish date picker to chosen collections and globals
  • Isolated job queue named scheduled-publish by default
  • Cron endpoint protected by a constant-time Bearer secret check
  • Rechecks the scheduling user's admin and update rights when the job runs
  • Merges with existing versions and drafts settings such as autosave
  • Configurable queue name and date picker options like time intervals

Use cases

  • Publish marketing pages automatically at a planned launch time
  • Let editors queue drafts for release without giving them manual publish timing duties
  • Run scheduled publishing from Vercel cron or an external scheduler

From the author

Schedule publication plugin for Payload CMS

Installation

npm i @focus-reactive/payload-plugin-scheduling

37

Stars

5

Forks

33

Open Issues

Today

Last Updated

385

Weekly Downloads

v2.0.1

npm Version

39.8 KB

Unpacked Size

1

Dependencies

Repository stars

37+22 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202637
Dec 5, 202637
Dec 4, 202637
Dec 3, 202637
Dec 2, 202637
Dec 1, 202636
Nov 30, 202635
Nov 29, 202635
Nov 28, 202634
Nov 27, 202634
Nov 26, 202634
Nov 25, 202634
Nov 24, 202634
Nov 23, 202634
Nov 22, 202634
Nov 21, 202634
Nov 20, 202633
Nov 19, 202632
Nov 18, 202632
Nov 17, 202632
Nov 16, 202632
Nov 15, 202632
Nov 14, 202632
Nov 13, 202632
Nov 12, 202632
Nov 11, 202632
Nov 10, 202632
Nov 9, 202631
Nov 8, 202631
Nov 7, 202631
Nov 6, 202631
Nov 5, 202631
Nov 4, 202630
Nov 3, 202630
Nov 2, 202630
Nov 1, 202630
Oct 31, 202630
Oct 30, 202630
Oct 29, 202630
Oct 28, 202630
Oct 27, 202630
Oct 26, 202630
Oct 25, 202630
Oct 24, 202629
Oct 23, 202629
Oct 22, 202629
Oct 21, 202629
Oct 20, 202629
Oct 19, 202629
Oct 18, 202629
Oct 17, 202627
Oct 16, 202626
Oct 15, 202626
Oct 14, 202626
Oct 13, 202625
Oct 12, 202625
Oct 11, 202625
Oct 10, 202625
Oct 9, 202625
Oct 8, 202625
Oct 7, 202625
Oct 6, 202624
Oct 5, 202624
Oct 4, 202624
Oct 3, 202623
Oct 2, 202622
Oct 1, 202622
Sep 30, 202620
Sep 29, 202620
Sep 28, 202620
Sep 27, 202620
Sep 26, 202619
Sep 25, 202618
Sep 24, 202618
Sep 23, 202618
Sep 22, 202618
Sep 21, 202618
Sep 20, 202618
Sep 19, 202618
Sep 18, 202618
Sep 17, 202618
Sep 16, 202618
Sep 15, 202618
Sep 14, 202618
Sep 13, 202617
Sep 12, 202617
Sep 11, 202617
Sep 10, 202616
Sep 9, 202616
Sep 8, 202616
Sep 7, 202615

Shared by 15 plugins in focusreactive/payload-plugins.

npm weekly downloads

385+210 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026385
Dec 5, 2026388
Dec 4, 2026361
Dec 3, 2026377
Dec 2, 2026349
Dec 1, 2026327
Nov 30, 2026336
Nov 29, 2026322
Nov 28, 2026321
Nov 27, 2026439
Nov 26, 2026522
Nov 25, 2026588
Nov 24, 2026613
Nov 23, 2026677
Nov 22, 2026754
Nov 21, 2026733
Nov 20, 2026665
Nov 19, 2026621
Nov 18, 2026695
Nov 17, 2026687
Nov 16, 2026626
Nov 15, 2026659
Nov 14, 2026766
Nov 13, 2026801
Nov 12, 2026814
Nov 11, 2026887
Nov 10, 2026902
Nov 9, 2026994
Nov 8, 2026933
Nov 7, 2026901
Nov 6, 2026847
Nov 5, 2026864
Nov 4, 2026659
Nov 3, 2026635
Nov 2, 2026673
Nov 1, 2026681
Oct 31, 2026605
Oct 30, 2026612
Oct 29, 2026475
Oct 28, 2026416
Oct 27, 2026424
Oct 26, 2026287
Oct 25, 2026218
Oct 24, 2026208
Oct 23, 2026125
Oct 22, 2026168
Oct 21, 2026251
Oct 20, 2026241
Oct 19, 2026244
Oct 18, 2026280
Oct 17, 2026283
Oct 16, 2026405
Oct 15, 2026427
Oct 14, 2026416
Oct 13, 2026415
Oct 12, 2026404
Oct 11, 2026467
Oct 10, 2026470
Oct 9, 2026369
Oct 8, 2026348
Oct 7, 2026372
Oct 6, 2026391
Oct 5, 2026709
Oct 4, 2026660
Oct 3, 2026723
Oct 2, 2026734
Oct 1, 2026760
Sep 30, 2026728
Sep 29, 2026732
Sep 28, 2026418
Sep 27, 2026371
Sep 26, 2026262
Sep 25, 2026245
Sep 24, 2026192
Sep 23, 2026142
Sep 22, 2026153
Sep 21, 2026154
Sep 20, 2026148
Sep 19, 2026243
Sep 18, 2026265
Sep 17, 2026359
Sep 16, 2026462
Sep 15, 2026516
Sep 14, 2026578
Sep 13, 2026579
Sep 12, 2026507
Sep 11, 2026503
Sep 10, 2026420
Sep 9, 2026339
Sep 8, 2026245
Sep 7, 2026175

Each point is npm's rolling 7-day download count.

Health Score

76/100Excellent

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1177993877-payload-plugin-scheduling.svg)](https://payloaddirectory.dev/plugins/1177993877-payload-plugin-scheduling)
HTML
<a href="https://payloaddirectory.dev/plugins/1177993877-payload-plugin-scheduling"><img src="https://payloaddirectory.dev/badge/1177993877-payload-plugin-scheduling.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Mar 10, 2026Published Dec 4, 2026

README

@focus-reactive/payload-plugin-scheduling

Scheduled publication plugin for Payload CMS v3. Set a future publish date on any draft document and it goes live automatically, with no manual publishing.

The plugin enables Payload's built-in schedulePublish drafts feature on selected collections and globals, routes the resulting jobs through an isolated queue, and exposes a Bearer-token-protected endpoint that your cron calls to run the queue. A scheduled publish runs with the rights of the user who scheduled it, checked again when it runs.

The plugin is built on @focus-reactive/payload-plugin-guard.

Requirements: Payload ^3.90.0, @focus-reactive/payload-plugin-guard, and a config wrapped in withAccessPolicy.


AI Integration Prompt

Copy and paste this prompt into your AI assistant (Cursor, Claude, etc.) to integrate the plugin into an existing Payload project.

I want to add scheduled publication to my Payload CMS v3 project using
@focus-reactive/payload-plugin-scheduling. Follow these steps in order, and stop to ask me where a step says so.

## Rules you must follow

- Never write an access rule that admits every logged-in user: no `Boolean(req.user)`, no `() => true`,
  no `({ req }) => !!req.user`. A rule names a role, or it is `nobody`.
- Do not invent roles. Ask me which roles may publish each collection and global.
- Write every policy entry by hand in `src/access.policy.ts`, and grant each capability and each
  collection right explicitly to the roles I name. Nothing is open by default.
- When the boot or a request fails, fix the cause or ask me. Never use `anyone`, a looser gate,
  `overrideAccess` or a removed or disabled check to make an error go away.
- Do not add `overrideAccess: true` anywhere.
- The cron secret goes only into the server's environment, never into a `NEXT_PUBLIC_` variable.

## How it works

The plugin turns on Payload's "Schedule Publish" date picker on the collections and globals I list.
Scheduling creates a job that remembers the user who scheduled it. The job only runs if that user still
may use the admin and still may update the document; otherwise it fails and the document stays a draft.
Only users who may update a document can cancel its pending schedules.
A cron calls `GET /api/scheduled-publish/run` with `Authorization: Bearer <secret>` to run due jobs.
The plugin declares no capabilities: who may publish comes from the `update` rule of each collection or
global in the access policy.

## Step 1: install

pnpm add @focus-reactive/payload-plugin-scheduling @focus-reactive/payload-plugin-guard

Check that `payload` is 3.90 or later; if it is not, upgrade it first.

## Step 2: ask me about roles

Ask me which collections and globals should get scheduled publishing.
For each of them, look at its `update` rule in the access policy; if it has none, ask me which roles may
publish it. Ask me which roles may run Payload's job queue by hand (`jobs.run`); the safe answer is
admins only.

## Step 3: the access policy file

Open `src/access.policy.ts`, or create it if the project has none, following the guard README
(`defineAccessPolicy`, `gate`, `filter`, `nobody`, checked with `satisfies AccessPolicy<Config>`).
If you create it, every collection and global of the config needs an entry: move each existing
`access` of the project into the file, and ask me for every rule you cannot read from the code.
Make sure it has these entries:

collections: {
  "payload-jobs": "payload-default",
},
jobs: { run: <gate from step 2>, queue: <gate from step 2>, cancel: <gate from step 2> },
plugins: {
  "scheduled-publish": {},
},

## Step 4: register the plugin and wrap the config

// payload.config.ts
import { buildConfig } from 'payload'
import { withAccessPolicy } from '@focus-reactive/payload-plugin-guard'
import { schedulePublicationPlugin } from '@focus-reactive/payload-plugin-scheduling'
import { accessPolicy } from './access.policy'

export default withAccessPolicy(
  accessPolicy,
  buildConfig({
    // ...the existing config
    plugins: [
      schedulePublicationPlugin({
        collections: ['pages'],
        globals: [],
        secret: process.env.CRON_SECRET,
        access: accessPolicy.plugins['scheduled-publish'],
      }),
    ],
  })
)

Add `CRON_SECRET` to `.env` with a long random placeholder and tell me to replace it.
Add a cron that calls `GET /api/scheduled-publish/run` with `Authorization: Bearer <CRON_SECRET>`
(on Vercel, a `crons` entry in `vercel.json`; Vercel sends `CRON_SECRET` itself).
Start the app. A missing or wrong policy entry stops the boot with a list of what to fix.
Fix each item; never loosen a rule to make an error go away.

## Step 5: verify, and show me the output

With the app running, send each request and show me the status code.
Every one of them must be refused. If one succeeds, the setup is wrong: stop and tell me.

1. No secret, expect 401:
   curl -i http://localhost:3000/api/scheduled-publish/run
2. A wrong secret, expect 401:
   curl -i http://localhost:3000/api/scheduled-publish/run -H 'Authorization: Bearer wrong'
3. An admin session without the secret, expect 401:
   curl -i http://localhost:3000/api/scheduled-publish/run -H 'Cookie: <admin cookie>'
4. Creating a job over REST as an admin, expect 403:
   curl -i -X POST http://localhost:3000/api/payload-jobs -H 'Content-Type: application/json' -H 'Cookie: <admin cookie>' -d '{}'

Then, as a user who may update a page, schedule a publish one minute ahead, call the endpoint with the
secret after that minute, and check that the page is published.

How it works

Editor sets "Schedule Publish" date in Payload Admin
              ↓
Payload creates a schedulePublish job that names the editor
              ↓
The plugin checks the editor may update the document, and routes the job to the "scheduled-publish" queue
              ↓
Cron calls GET /api/scheduled-publish/run with the secret
              ↓
For each due job, the plugin checks again that the editor may use the admin and update the document
              ↓
Payload publishes the document as the editor

The plugin hooks into Payload's own schedulePublish task; it does not implement its own publish logic. It leaves jobs.runHooks as your config sets it. Keep it off on Payload 3.90: with it on, Payload fails every job of the app after its handler has run, because the job's log entry does not pass validation.


Setup

1. Install

pnpm add @focus-reactive/payload-plugin-scheduling @focus-reactive/payload-plugin-guard

Peer dependencies: payload ^3.90.0

2. Add the policy entries

The plugin declares no capabilities, but the guard needs an entry for it. Who may publish a document is the update rule of its collection or global.

// src/access.policy.ts
export const accessPolicy = defineAccessPolicy({
  collections: {
    // ...your collections
    "payload-jobs": "payload-default",
  },
  globals: {
    // ...your globals
  },
  jobs: { run: isAdmin, queue: isAdmin, cancel: isAdmin },
  plugins: {
    "scheduled-publish": {},
  },
}) satisfies AccessPolicy<Config>;

jobs.run decides who may run Payload's own /api/payload-jobs/run; keep it to admins. Every scheduled publish is checked against its scheduler whichever way the queue runs.

3. Register the plugin and wrap the config

// payload.config.ts
import { buildConfig } from "payload";
import { withAccessPolicy } from "@focus-reactive/payload-plugin-guard";
import { schedulePublicationPlugin } from "@focus-reactive/payload-plugin-scheduling";

import { accessPolicy } from "./access.policy";

export default withAccessPolicy(
  accessPolicy,
  buildConfig({
    plugins: [
      schedulePublicationPlugin({
        collections: ["pages"],
        secret: process.env.CRON_SECRET,
        access: accessPolicy.plugins["scheduled-publish"],
      }),
    ],
  })
);

The plugin injects into every configured collection and global versions.drafts.schedulePublish: true, which enables the "Schedule Publish" date picker in the admin sidebar.

4. Set up a cron

The endpoint GET /api/scheduled-publish/run must be called at least as often as your finest scheduling granularity. It runs all due jobs in the queue and returns { "ok": true }.

Vercel
{
  "crons": [
    {
      "path": "/api/scheduled-publish/run",
      "schedule": "* * * * *"
    }
  ]
}

Vercel sends CRON_SECRET as Authorization: Bearer $CRON_SECRET when it triggers a cron. Set CRON_SECRET in the Vercel project settings and pass it to the plugin's secret option.

External cron / curl
curl -X GET https://your-cms.com/api/scheduled-publish/run \
  -H "Authorization: Bearer YOUR_SECRET"

Options

OptionTypeRequiredDefaultDescription
accessaccessPolicy.plugins["scheduled-publish"]YesnoneThe plugin's entry from your access policy
secretstring | undefinedYesnoneBearer token for the run endpoint; when empty the endpoint is not added
collectionsstring[]No[]Collection slugs to enable scheduled publishing on
globalsstring[]No[]Global slugs to enable scheduled publishing on
queuestringNo"scheduled-publish"Queue name for scheduled publish jobs
schedulePublishSchedulePublishNotrueOptions for the date picker, such as timeIntervals to match your cron

Access

  • GET /api/scheduled-publish/run needs Authorization: Bearer <secret>; the secret is compared in constant time. A session cookie is not enough, whatever the user's role. Without a secret the endpoint is not registered and the server logs a warning.
  • A scheduled publish is created only for a user of the admin collection who may update the document or global. A job without a user, or with a user of another auth collection, is refused.
  • When the job runs, the plugin loads that user again and checks that they may still use the admin and still may update the document. If the user was deleted, lost admin access or lost the update right, the job fails and the document stays as it was.
  • Cancelling a pending scheduled publish needs the update right on its document.
  • Creating jobs over REST stays closed, as Payload's default jobs access has it.

The endpoint answers:

StatusWhen
200{ "ok": true }, due jobs were run
401missing or wrong secret
500the jobs runner threw

Versioning & Drafts Behaviour

  • If the collection has no versions config, the plugin adds { drafts: { schedulePublish: true } }.
  • If versions is true or has drafts: true, the plugin replaces drafts with { schedulePublish: true }.
  • If versions.drafts is an object, the plugin merges schedulePublish: true into it and keeps other draft options such as autosave.

Migrating from 1.x

2.0 moves the plugin onto @focus-reactive/payload-plugin-guard; Upgrading to the guard explains the model all the plugins share, with a complete example. Every access rule is now written by hand in your project's src/access.policy.ts, and nothing is open by default: an entry you leave out stops the boot, and a capability you do not grant is refused for everyone.

What changes

  • Payload and every @payloadcms/* package 3.90 or later, with the React and Next versions Payload 3.90 requires, Node 22.22 or later, and @focus-reactive/payload-plugin-guard installed next to the plugin.
  • access is a required option; the plugin declares no capabilities, so it is the empty scheduled-publish entry of the policy.
  • A scheduled publish runs with the rights of the user who scheduled it, checked when it is created and again when it runs. Jobs created by code without a user are refused; schedule from the admin, or queue the job with a user who may update the document.
  • Cancelling a pending schedule needs the update right on its document.
  • The plugin no longer turns on jobs.runHooks, which made every job of the app fail after it ran. Hooks your project added to the jobs collection now run when a job is queued or run only if you set jobs.runHooks yourself.
  • secret may be empty: the run endpoint is then not registered, instead of answering every request with 401.

Steps

  1. Upgrade payload and every @payloadcms/* package to 3.90 or later, run the server on Node 22.22 or later, and install the guard: pnpm add @focus-reactive/payload-plugin-guard @focus-reactive/payload-plugin-scheduling.

  2. Add the plugin's entries to src/access.policy.ts, with gates for your own roles; if the project has no policy file yet, write it first as the guide describes.

    // src/access.policy.ts, inside defineAccessPolicy({ ... })
    collections: {
      "payload-jobs": "payload-default",
    },
    jobs: { run: isAdmin, queue: isAdmin, cancel: isAdmin },
    plugins: {
      "scheduled-publish": {},
    },
    
    • Who may schedule a publish is the update rule of the document's collection or global; there is no capability of its own.
    • jobs.run decides who may call Payload's own /api/payload-jobs/run; keep it to admins.
  3. Pass access: accessPolicy.plugins["scheduled-publish"] to schedulePublicationPlugin, and export the config wrapped: export default withAccessPolicy(accessPolicy, buildConfig({ ... })).

  4. Database: no migration; the plugin adds no fields.

  5. Re-test: GET /api/scheduled-publish/run without the bearer secret answers 401, also with an admin's session cookie; schedule a publish as an editor and check that it runs; remove that editor's update right and check that the next due job fails and leaves the document as it was.


Exports Reference

Import pathExports
@focus-reactive/payload-plugin-schedulingschedulePublicationPlugin, SchedulePublicationPluginConfig

Similar plugins