PAUSED, RUNNING, …); the why lives on the waitpoint.
Schema
Types
DELAY: resumes atresumeDateTime. The server schedules a one-time job for that timestamp. The delay is bounded by a configurable server-side maximum.WEBHOOK: resumes on any HTTP call to the waitpoint’s resume URL. IfresponseToSendis set, it is replied immediately to the original trigger so a single webhook can respond-then-pause.BARRIER: resumes once every awaited thing has reported back. See below.
Barriers
A barrier pauses a run until N things report back - the batches aProcess in Batches step dispatched,
or the approvers on one approval. It is a waitpoint plus one signal row per awaited thing, created up
front:
Release is an unconditional floor rule: a sealed barrier releases once no signal is still
PENDING. No
configuration can produce a hang. policy only ever releases sooner - requiredSuccesses covers 2-of-3
approvals, releaseOnFirstFailure covers a veto. Signals left pending at an early release are reported
truthfully as stillRunning.
The step resumes with one shape, so an expression never breaks on fan-out width:
signals array is present only when total <= 100; above that only the counts travel and
signalsTruncated is set. AP_MAX_BARRIER_SIGNALS (default 10 000) caps how many things one barrier may
wait on. The cap is stored per platform, created from the env var the first time that platform’s
configuration is read. 10 000 is also the ceiling: the env var cannot raise it higher. A barrier’s deadline is set when it is created, from AP_PAUSED_FLOW_TIMEOUT_DAYS, and never moves.
Lifecycle
- Create. The piece calls
ctx.run.createWaitpoint({ type, ... })+ctx.run.waitForWaitpoint(id). The engine marks the step aspausedand asks the server to insert aPENDINGrow. The insert is idempotent on the(flow run, step)pair. - Checkpoint. The engine serializes the execution context and transitions the flow run to
PAUSED. - Resume signal. Either an HTTP call on the resume URL or the scheduled job firing. Both carry
{ body, headers, queryParams }. - Re-run. A worker rebuilds the context and re-invokes the same action with
ctx.executionType === ExecutionType.RESUMEandctx.resumePayloadpopulated.
Resume-before-pause race
A callback can arrive before the flow run has finished writingPAUSED to disk. The protocol absorbs the race:
- Completing a waitpoint takes a write lock on the
PENDINGrow. If it exists, it flips toCOMPLETEDand stores theresumePayload. If it does not, a pre-completed row is inserted instead. - When the flow run transitions to
PAUSED, the server checks for aCOMPLETEDwaitpoint on the run and enqueues the resume job immediately - but only once no waitpoint for that run is stillPENDING. A run holding a pause per loop iteration can carry a completed leftover and an open pause at the same time, and resuming off the leftover would skip the open one.
Endpoints
Piece API
Piece authors create waitpoints withctx.run.createWaitpoint / ctx.run.waitForWaitpoint. Patterns for WEBHOOK, DELAY, and responseToSend are in Flow Control.
Known limitation
findPendingByVersion - the lookup behind the deprecated V0 /:id/requests/:requestId resume routes .
returns an arbitrary pending V0 waitpoint for a run. That is exact today because nothing gives one run two
pending V0 waitpoints at once. Parallel branches would, and must fix this lookup first.