queue global. Jobs are stored in Redis and processed by a background worker. This is useful for sending follow-up emails, scheduling reminders, or any task that should happen later without blocking the current request.
queue.push(scriptCode, payload, opts?)
Enqueue a backend script for deferred execution.
Options
Returns:
{ ok: true, jobId: '...' } on success, or { ok: false, error: '...' } on failure.
How the target script is called
The queued script’s exported function receives thepayload object as its only argument:
opts.fn, a named export is called instead of the default export:
queue.cancel(tag)
Cancel all pending jobs with the given tag for the current brand.
Returns:
{ ok: true, cancelled: N } where N is the number of jobs removed.
Example: Multi-step abandon email sequence
Queue 3–4 emails spaced over a few days. Cancel the whole sequence on purchase using the shared tag prefix.Limits per brand:
- 25,000 pending jobs maximum per brand
- 64 KB maximum payload size
- 7-day maximum delay (604,800 seconds)
- 60-second minimum delay when a non-zero delay is set
- 5 pushes per script execution
- 5 cancel calls per script execution
- 3 retries with exponential backoff on failure
- Jobs expire after 8 days if not processed