Payload CMS jobs queue: tasks, workflows and cron schedules

Idea Labz · Nov 20, 2026 · 15 min read

A hook that sends an email or calls an outside API makes every save wait for it, and when that API is down, the save fails too. Payload’s hooks run inside the request, so slow work in them slows the admin panel and your API for everyone.

As of 19 November 2026, in Payload 3.94.0, the jobs queue moves that work out of the request. Each piece of work becomes a job stored in your own database, and a runner you choose picks it up later, retries it if it fails, and records what happened.

This guide follows one example, an online pet supplies store in Dubai that sends order emails, builds invoices, reminds shoppers about full baskets and syncs stock from its warehouse every night.

  • What is the Payload jobs queue?
  • How do you define a task?
  • How do you queue a job from a hook?
  • Workflows: tasks in order that resume after a failure
  • Four ways to run the queue
  • Running jobs on Vercel and other serverless hosts
  • Running a task on a cron schedule
  • Queues, processing order and concurrency
  • What happens to completed and failed jobs?
  • Why aren’t my Payload jobs running?
  • How we run jobs on our builds
  • What changes in Payload 4
  • Frequently asked questions
  • What to do next

What is the Payload jobs queue?

The jobs queue has four pieces, which you configure under jobs in your Payload config.

PieceWhat it isWhere you define it
TaskOne function with a typed input and output, and optional retriesjobs.tasks
WorkflowSeveral tasks run in order, which resume from the failed step on a retryjobs.workflows
JobOne queued run of a task or a workflow, with its input and statusCreated by payload.jobs.queue() or a schedule
QueueA name that groups jobs, so different runners can pick up different workThe queue option, default if you leave it out

Jobs are documents in a collection called payload-jobs, in the same database as the rest of your content, so the queue needs no extra service. The collection is hidden in the admin panel, and since Payload 3.89.0 it refuses all reads and writes through the REST, GraphQL and admin routes.

Queuing a job and running it are separate steps. For example, when a customer places an order, the store’s hook adds a job to the queue and the save returns. Nothing sends the email until a runner picks the job up.

How do you define a task?

A task is an object in jobs.tasks with a slug, a handler and, usually, an inputSchema. The handler receives the input and Payload’s req, does the work, and returns { output }. Payload generates TypeScript types from the input and output schemas, so the call that queues the task is checked against them.

For example, the store’s order email is a task. It assumes an orders collection with email and number fields and a renderOrderEmail function of your own:

import type { TaskConfig } from 'payload'

export const sendOrderConfirmation: TaskConfig<'sendOrderConfirmation'> = {
  slug: 'sendOrderConfirmation',
  inputSchema: [{ name: 'orderId', type: 'text', required: true }],
  outputSchema: [{ name: 'emailedTo', type: 'email', required: true }],
  retries: { attempts: 3, backoff: { type: 'exponential', delay: 30_000 } },
  handler: async ({ input, req }) => {
    const order = await req.payload.findByID({ collection: 'orders', id: input.orderId, req })
    await req.payload.sendEmail({
      to: order.email,
      subject: `Order ${order.number} confirmed`,
      html: renderOrderEmail(order),
    })
    return { output: { emailedTo: order.email } }
  },
}

Then register it with jobs: { tasks: [sendOrderConfirmation] } in buildConfig.

Retries are off unless you set them. In 3.94.0, a task with no retries, inside a workflow with none either, fails its job on the first error. retries takes the number of retries after the first run, or an object with attempts and a backoff that is fixed or exponential, with a delay in milliseconds. A retry doesn’t run straight away. Payload marks the job to wait until the backoff has passed, and the next run picks it up.

A handler fails by throwing an error. Returning { state: 'failed' } still works in 3.94.0, but it’s deprecated and gone in Payload 4. onSuccess and onFail callbacks run after it. Because a retry runs the handler again, write each task so a second run does no harm. For example, look up whether the email went out before sending it again.

How do you queue a job from a hook?

Call payload.jobs.queue() with the task’s slug, or a workflow slug, and its input. In a hook, use req.payload and pass req. On a database with transactions, the job is then written in the same transaction as the document that triggered it.

For example, the store queues the confirmation email when an order is created:

import type { CollectionAfterChangeHook } from 'payload'

export const queueOrderEmail: CollectionAfterChangeHook = async ({ doc, operation, req }) => {
  if (operation === 'create') {
    await req.payload.jobs.queue({
      task: 'sendOrderConfirmation',
      input: { orderId: String(doc.id) },
      req,
    })
  }
  return doc
}

The save now returns as soon as the job is written, and an email provider that is down no longer fails the order. Our ecommerce guide covers the order emails themselves.

To run a job later, pass waitUntil with a Date. The store reminds shoppers about a full basket 24 hours after they leave it:

await req.payload.jobs.queue({
  task: 'sendBasketReminder',
  input: { cartId: String(cart.id) },
  waitUntil: new Date(Date.now() + 24 * 60 * 60 * 1000),
  req,
})

Payload’s scheduled publishing is a job like this one, waiting until the publish time, which our guide to drafts and scheduled publishing covers.

Jobs can also be queued from a custom endpoint or the Local API, from a Next.js server action, or from another job. On a multi-tenant build, the job also has to carry its tenant, which our multi-tenancy guide explains.

Workflows: tasks in order that resume after a failure

A workflow runs several tasks in order and saves each one’s output as it finishes. When a later task fails and the job is retried, Payload runs the workflow’s handler again, and every task that already succeeded returns its saved output without running.

For example, every new order at the store needs an invoice PDF, the confirmation email and loyalty points, in that order:

import type { WorkflowConfig } from 'payload'

export const processOrder: WorkflowConfig<'processOrder'> = {
  slug: 'processOrder',
  inputSchema: [{ name: 'orderId', type: 'text', required: true }],
  retries: 3,
  handler: async ({ job, tasks }) => {
    const { orderId } = job.input
    await tasks.createInvoicePdf('create-invoice', { input: { orderId } })
    await tasks.sendOrderConfirmation('send-email', { input: { orderId } })
    await tasks.addLoyaltyPoints('add-points', { input: { orderId }, retries: 0 })
  },
}

If the email provider is down, the first run creates the invoice and fails at the email. The retry skips the invoice, because its output is saved under the ID create-invoice, and carries on from the email. That is why each task call needs an ID that stays the same between runs.

Each call resolves to the task’s output object itself. The store keeps the invoice PDFs in an upload collection.

A task without its own retries takes the workflow’s, and a retries value passed in the call wins over both. Loyalty points get retries: 0 here because adding points twice would give the customer double. For a step you don’t want to register as its own task, inlineTask('id', { task }) runs a function in the same way. To stop a job for good from inside a handler, throw JobCancelledError, and it won’t be retried.

Four ways to run the queue

A runner finds jobs that are due, marks them as processing, runs them and records the result. Payload gives you four ways to start one, and which fits depends on whether your host keeps a process running.

RunnerHow it runsFits
jobs.autoRunA cron inside your Payload appA server or container that stays running
payload jobs:runA separate process from the command line, once or on its own --cronA worker beside your app on a VPS or in Docker
GET /api/payload-jobs/runAn HTTP call from a platform’s schedulerServerless hosts such as Vercel
payload.jobs.run() or runByID()Your own codeTests, scripts, and running a job right after queuing it

On a VPS, the store can let Payload run its own queue with autoRun:

jobs: {
  tasks: [sendOrderConfirmation, sendBasketReminder],
  workflows: [processOrder],
  autoRun: [
    { cron: '*/5 * * * *', queue: 'default', limit: 20 },
    { cron: '* * * * *', queue: 'nightly' },
  ],
},

Each entry takes a cron (every minute by default), a queue (default), a limit (10 jobs a run) or allQueues: true, and a new run doesn’t start while the last one is still going.

To keep job work off the server that answers requests, run a worker instead, for example in its own container:

pnpm payload jobs:run --cron "*/5 * * * *" --queue default --limit 20

The CLI also takes --all-queues and --handle-schedules, and without --cron it runs once and exits.

The jobs a runner picks up in one go run at the same time. If they have to run one after another, call payload.jobs.run({ sequential: true }) from your own code. Our guide to where to host Payload compares which hosts keep a process running.

Running jobs on Vercel and other serverless hosts

On serverless hosts, autoRun doesn’t work, because no process stays up between requests to run its cron. Instead, the platform’s scheduler calls Payload’s run endpoint, GET /api/payload-jobs/run, which runs up to 10 due jobs from the default queue. The query parameters limit, queue and allQueues=true change that, and disableScheduling=true skips queuing scheduled tasks first.

By default, any signed-in user may call the endpoint, and a scheduler isn’t signed in. Give it a rule in jobs.access.run that accepts the secret your platform sends. On Vercel, a CRON_SECRET environment variable arrives as a Bearer token. This rule lets the scheduler in, along with admins, and assumes a roles field on your users:

jobs: {
  access: {
    run: ({ req }) => {
      const secret = process.env.CRON_SECRET
      const fromScheduler = Boolean(secret) && req.headers.get('authorization') === `Bearer ${secret}`
      return fromScheduler || Boolean(req.user?.roles?.includes('admin'))
    },
  },
},

Then add the schedule to vercel.json. The store calls the endpoint every five minutes:

{
  "crons": [{ "path": "/api/payload-jobs/run", "schedule": "*/5 * * * *" }]
}

A plain call like this checks the schedules of, and runs, only the default queue.

As of 19 November 2026, Vercel’s cron limits shape how often that runs. On the Hobby plan a cron runs once a day at most, within the hour you set, and a schedule like this one fails the deploy. Pro and Enterprise allow one a minute. Vercel calls only your production deployment and doesn’t retry a call that fails. Each run must also finish within the function’s maximum duration, 300 seconds by default and up to 800 seconds on Pro, so keep limit low enough for the slowest jobs.

Where a few minutes’ wait is too long, run the job as soon as it’s queued with payload.jobs.runByID({ id: job.id }) inside Next.js’s after(), which runs once the response has gone and within the route’s maximum duration. Keep the scheduled run for retries and anything missed.

Running a task on a cron schedule

To run a task every night or every hour, give it a schedule with a cron expression and a queue. The schedule only queues the job, and a runner still has to run that queue, so both must use the same queue name.

For example, the store syncs stock from its warehouse system at 06:00 Dubai time:

import type { TaskConfig } from 'payload'

export const syncStock: TaskConfig<'syncStock'> = {
  slug: 'syncStock',
  schedule: [{ cron: '0 2 * * *', queue: 'nightly' }],
  retries: 2,
  handler: async ({ req }) => {
    const changed = await pullStockFromWarehouse(req)
    return { output: { changed } }
  },
}

The cron reads 0 2 * * *, 02:00 UTC, because Payload works out the next run in the server’s own time zone and the store’s server runs on UTC, four hours behind Dubai. Check your host’s time zone before you write a schedule. On Vercel, TZ is a reserved variable you can’t set, and Vercel’s own crons always run in UTC. A sixth field at the front adds seconds.

The run endpoint and autoRun check the schedules before every run unless you turn it off, the CLI does it with --handle-schedules, and GET /api/payload-jobs/handle-schedules or payload.jobs.handleSchedules() does only that. If a plain call to the run endpoint is your only runner, as on Vercel, put the schedule on default. Each check queues the next run ahead of time, set to wait until it’s due, and it doesn’t queue another while the last scheduled job for the same task is still waiting or running.

With several servers running autoRun, each one checks the schedules. Set disableScheduling: true on every server but one. A shouldAutoRun that returns false stops a server running jobs, but in 3.94.0 autoRun still checks the schedules on that server first.

Queues, processing order and concurrency

A queue is a name you give jobs so that different runners handle them on different timings. On its VPS, the store puts everyday work on default, run every five minutes, and the stock sync on nightly. A workflow can set its own queue, and payload.jobs.queue() takes one per job.

Within a queue, jobs run oldest first. processingOrder in the jobs config or in payload.jobs.run() changes that, for example to -createdAt for newest first.

Concurrency controls stop two jobs for the same thing from running at once. Turn them on with jobs.enableConcurrencyControl: true, then give the task or workflow a concurrency key built from its input:

concurrency: {
  key: ({ input }) => `stock:${input.productId}`,
  supersedes: true,
},

With this key, a runner won’t start a sync for a product while another one for it is running, and supersedes deletes older pending syncs for that product when a newer one is queued. Turning concurrency on adds an indexed field to the jobs collection, which may need a database migration on SQL databases.

What happens to completed and failed jobs?

A job moves through a few states, and its fields show where it is:

StateWhat the job showsWhat happens next
WaitingwaitUntil in the future, or not yet picked upA runner picks it up once it’s due
Processingprocessing: trueThe runner records success or failure
Waiting to retryAn entry in log, waitUntil set by the backoffThe next run tries again
FailedhasError: true, with error and totalTriedIt stays until you re-queue or delete it
CompletedcompletedAt setDeleted at the end of the run, unless you keep completed jobs

To keep a history of completed jobs, set deleteJobOnComplete to false and clear old jobs yourself.

To read failed jobs, query payload-jobs from trusted server code with the Local API, which skips access checks there by default in Payload 3:

const failed = await payload.find({
  collection: 'payload-jobs',
  where: { hasError: { equals: true } },
  sort: '-updatedAt',
})

To show jobs in the admin panel, jobsCollectionOverrides can unhide the collection and give admins read access. Keep write access closed, because a job holds its inputs, outputs and errors. payload.jobs.cancel() and cancelByID() stop queued jobs. A running job finishes its current task first.

Why aren’t my Payload jobs running?

Check these first:

  • Nothing queues the job. A runner only runs jobs already in the queue.
  • The queue names don’t match. A job on nightly waits forever for a runner reading default.
  • autoRun on a serverless host. No process stays up to run it; use the run endpoint.
  • A schedule with no runner. schedule queues the job, and nothing runs it.
  • waitUntil is in the future, including a retry waiting out its backoff.
  • The run endpoint returns 401. The scheduler doesn’t pass your jobs.access.run rule.
  • autoRun hasn’t started. Its cron starts on the first admin or API request, so after a restart nothing runs until one arrives.
  • Code changes in development. Restart the dev server after changing the jobs config.

On serverless hosts, jobs can also get stuck mid-run. In Payload 3.94.0, a runner marks a job processing: true before it starts and only ever picks jobs that aren’t marked. If the process dies mid-job, or a serverless function hits its time limit, nothing clears the mark, so that job never runs again. A stuck scheduled job also stops its schedule, because Payload won’t queue the next one while it looks active.

For example, if the store’s stock sync times out one night on a slow warehouse response, the sync never runs again until someone clears the job. On Payload 3, keep each run well inside your host’s time limit with a small limit, and check for jobs that have been processing too long. A runner sets a job’s updatedAt when it claims it, so a job still processing long after that has stopped. This function frees such jobs so the next run picks them up, and you can call it from a protected endpoint or a script:

import type { Payload } from 'payload'

export const releaseStuckJobs = async (payload: Payload, olderThanMinutes = 30) => {
  const cutoff = new Date(Date.now() - olderThanMinutes * 60 * 1000).toISOString()
  return payload.update({
    collection: 'payload-jobs',
    where: {
      and: [{ processing: { equals: true } }, { updatedAt: { less_than: cutoff } }],
    },
    data: { processing: false },
  })
}

Pick a cutoff longer than any run can last on your host, because freeing a job that is still running lets a second runner start it. Freeing a job doesn’t count as a retry, so a job that always outruns the limit keeps coming back. Find out why it runs long. In Payload 4, a lease on each job replaces the flag, so a stuck job recovers on its own.

How we run jobs on our builds

Our project template (v2.13.1, November 2026, on Payload 3.93.0) uses the jobs queue for the work our own plugins do. Our WhatsApp plugin queues outgoing messages, our Intercom integration keeps contacts in sync, our own workflows plugin runs the automations users build, and another of our plugins recalculates computed fields.

autoRun is off, because our apps run serverless. On Vercel, a job runs in the same request that queued it, after the response has gone back to the user. A job with a later start time waits for the next sweep. A platform cron calls a sweep once a day in the default config, which frees jobs left stuck mid-run and runs anything still waiting, such as retries. That fits Vercel’s Hobby plan, and a project on Pro can run the sweep more often. Only admins and the platform’s own scheduled call can trigger a run.

Retries are set per task. Tasks that are safe to repeat, such as emails, webhooks and messages, retry two or three times, and tasks that a repeat would apply twice don’t retry. Long workflows save their progress and carry on in a later run rather than hitting the time limit. Completed jobs are removed, which is Payload’s default. The jobs collection is shown in the admin panel for monitoring, and on multi-tenant projects each tenant sees only its own jobs. Our guide to Payload plugins covers how plugins add work like this.

If you’d like background work shaped around your project and your host, see our Payload CMS development service.

What changes in Payload 4

As of 4.0.0-beta.10 (17 November 2026), Payload 4 changes these parts of the jobs queue, according to Payload’s 4.0 migration guide and the beta package:

  1. Jobs calls enforce access by default. payload.jobs.queue, run, runByID, cancel and cancelByID default overrideAccess to false, and so do Local API calls like the query that reads failed jobs. The codemod adds overrideAccess: true to existing calls.
  2. Stuck jobs recover on their own. A runner takes a lease on each job, 20 minutes by default and renewed while the job runs, in place of the processing flag. When a runner dies, the lease runs out and the next run picks the job up (pull request #17220).
  3. jobs.depth and jobs.runHooks are removed, and the BaseJob type is replaced by Job.
  4. Concurrency controls and parent task logging are always on, their two options are removed, and the jobs collection gains the concurrency field on upgrade.

For example, a guest checking out at the store sets off the hook that queues the order email. In 4.0.0-beta.10, the default jobs.access.queue rule passes only a signed-in user from the admin user collection, so that call fails for a guest, and for a customer signed in from a separate customers collection. The hook needs overrideAccess: true, or a queue rule of its own.

The jobs queue arrived in Payload 3.0. Betas change between releases, so check the guide again before you upgrade.

Frequently asked questions

Does Payload have built-in cron jobs?

Yes. A schedule on a task or workflow queues it on a cron expression, read in the server’s time zone. A runner still has to run that queue, through autoRun, the CLI or the run endpoint.

How do I run Payload jobs on Vercel?

Add a cron to vercel.json that calls /api/payload-jobs/run, and a jobs.access.run rule that accepts the CRON_SECRET Vercel sends. On the Hobby plan that cron runs once a day at most, and a more frequent one fails the deploy.

Why are my Payload jobs not running?

Usually nothing runs the queue, the queue names don’t match, or autoRun is set on a serverless host. On Payload 3, also look for jobs stuck at processing: true after a crash or a timeout.

Can a Payload job run as soon as it’s queued?

Yes. Call payload.jobs.runByID() with the queued job’s ID, inside Next.js’s after() if you’re in a request, so the response doesn’t wait. Keep a scheduled run as well, to pick up retries and anything that was missed.

Where are Payload jobs stored?

In the payload-jobs collection in your own database. It’s hidden in the admin panel, and completed jobs are deleted by default, while failed ones stay.

How do I retry a failed Payload job?

Set retries on the task or workflow, with an optional fixed or exponential backoff, and Payload retries on later runs. A job that has used up its retries stays failed, so queue it again once you’ve fixed the cause.

What’s the difference between a task and a workflow in Payload?

A task is one function with a typed input and output. A workflow runs several tasks in order and, on a retry, skips the ones that already succeeded.

Do I need Redis or a separate worker for Payload jobs?

No. Jobs live in your Payload database, and autoRun or the run endpoint can run them inside your app. A separate worker with payload jobs:run is an option on servers you control.

What to do next

Move the slowest work in your hooks into a task first, and set retries on anything that calls an outside service. Choose the runner for your host before your first deploy, and on serverless hosts, check for stuck jobs until you’re on Payload 4.

If you’re still choosing a host, read where to deploy Payload, and for posts that publish on a timer, see how scheduled publishing works.

References

All links checked and active as of 19 November 2026.

READY TO MAKE A REAL CHANGE?

Let's build it together