Runs and steps
A run is one execution of a workflow, on the version that was current when it arrived. Each step runs once and keeps its result, so a run can sleep, wait and resume.
What starts a run
Each run records its origin. Filter by it with GET /v1/runs?origin=, or by Started by on the Runs screen.
triggerA delivery to a trigger URL, or a replay or test event on the trigger. See Deploy and triggers.
GET /v1/runs/:idgives the trigger's name astrigger_name,nulluntil it has one.api·dashboard·mcpPOST /v1/workflows/:workflow/runswith an API key orshiftlabs run, Run now in the dashboard, or MCP'srun_workflow.scheduleA schedule's tick.
workflowstep.startorstep.callin another run.agentrerunA re-run of an earlier run, with its version and payload, or on its workflow's current version, or with another payload. A payload is kept 14 days, so an older run's re-run gets
410. That holds for a Pro run still running after 14 days too: its code still has the payload, but a re-run and its/payloadget410. A run still waiting to start keeps its payload until it starts.resumeA failed run resumed from one of its steps, with its payload, on its version or its workflow's current one: the steps before that one return what they returned in the failed run.
continueA keyed run's next run, which the run before it started as it continued as new, with the state it handed on as its payload, on its workflow's current version.
origin_ref says who: an email or API key id, the parent run, the schedule's name, the agent and its conversation, or the run that continued as new. A run stays on the version that was current when it arrived, even after a redeploy or a release.
Statuses
A run is queued, then running, sleeping or waiting, until it ends completed, failed, cancelled or terminated. Someone can pause it in between.
queuedNot started yet.
queued_reasonisconcurrencywhile it waits for its workflow's concurrency, orpausedwhile its workflow is paused.runningIts code is running.
sleepingIn a
step.sleep, or waiting for an agent or another run.sleeping_untilgives a sleep's end.waitingWaiting for an approval or an event.
waiting_fornames it:{ kind, name, since, until }, wherekindisapprovaloreventanduntilis when it times out.GET /v1/runs?status=waitinglists these runs.pausedSomeone paused it, and it holds where it is until they unpause it.
paused_bysays who.completedThe function returned.
GET /v1/runs/:idshows what it returned asinstance.output, as soon as the run readscompleted, for as long as the run is kept, 35 days after it ended. See Output.failedA step ran out of retries, a
FatalErrorwas thrown, code outside a step threw, or the run reached a limit.errorsays why. Where it readserrored,error_messageinGET /v1/runsgives the message the code threw, its first 1 KiB, andinstance.error.messageinGET /v1/runs/:idall of it.failed_stepinGET /v1/runs/:idnames the step it threw from,{step, occurrence, kind}, while its step results are kept for resume; it'snullwhen code outside a step threw. When the function threw, its completed steps with an undo are undone first.cancelled·terminatedSomeone stopped it. See Stop a run. A started run that is cancelled first runs its workflow's
onCancel, and withundoits undo handlers. Until that cleanup ends, the cancel answerscancelling,stop_requestediscancel, andcleanup_atsays when the cleanup began,nullwhen none ran.
Output
What a completed run returned is instance.output in GET /v1/runs/:id, the run's page in the dashboard, runs.get in the clients and MCP's get_run. q finds a run by text in it.
- Workflows holds a run's output for 7 days after the run ends. shiftlabs also keeps a copy with the run, 35 days after the end, so
qcan search it and the run reads back with its output after Workflows has let it go. - That copy is the output's JSON with readable secrets replaced by
[redacted], up to 64 KiB. Of a longer output it keeps the first 64 KiB, cut at a character. Once only that copy is left, or for a moment as the run ends, the run readsinstance.outputTruncated,{bytes, text}, in place ofinstance.output: the whole output's size as JSON, and the start of its JSON. The dashboard shows it marked as cut. Return what you'll need later in full under 64 KiB, or store it yourself. - A workspace keeps up to 16 MiB of these copies, counting 64 bytes a run on top of each copy: about 60,000 runs that return a couple of hundred bytes. Past that the oldest go first, and such a run is no longer found by its output and reads back with it only while Workflows still has it.
Steps
A step is a named unit of work. step.run runs its function once and stores the result. Each time the run resumes, after a sleep, a wait or a retry, your function starts again from the top: each step returns its stored result, and code outside steps runs again. In the refund-check example, the charge is fetched once, and after the 10-minute sleep the run gets it from storage.
Rules that keep runs correct
- Put side effects inside steps: requests that change something, and anything that reads the clock or a random number.
- A resumed run answers each step from storage by its name and how often the run has called that name. Code that calls other steps on a resume runs them again. Test a workflow catches it.
stateworks only insidestep.run. See State.step.idempotencyKey(name)is the same on every retry and resume of the run. See Idempotency keys.
Retries and timeouts
A step that throws is tried again, on the same version. Without retries, it gets 5 more tries, 10 seconds apart and doubling. When the tries run out, step.run throws the last error, and uncaught, it fails the run.
FatalErrorFails the step and the run at once, with no more tries.
timeoutAn attempt that runs past it fails. Default 10 minutes.
- Counting
Each try counts toward the run's steps, so a retry is one more step; the wait before it isn't one. In a run started before 3 November 2026, a
step.runcounts once however often it is retried. The guide Rate limits and retries retries another API's429. - Retry now
While a step waits to try again, Retry now on the run's page, or
POST /v1/runs/:id/retry, starts its next try at once.
Limits on a run
The limits below are the same on Free and Pro unless they say otherwise. See Limits for every value.
- A run must end within 168 hours (7 days) of arriving on Free, and 720 hours (30 days) on Pro. Past that, it fails, also while it sleeps, with an error that starts
limit runLifetimeHours=168on Free. A Pro run that arrived before Pro's lifetime went to 30 days keeps 168 hours. A run's page shows when its lifetime ends while it runs, andGET /v1/runs/:idreturns it aslifetime_ends_at. - A run executes at most 100 steps on Free and 1,000 on Pro. A step answered from storage, a retry, a sleep or a wait doesn't count.
- The engine dispatches a run at most 50 times: to start it, and each time it resumes.
- Each dispatch gets 2,000 ms of CPU time, and a run 10 seconds in all on Free, 60 on Pro.
Find runs
Narrow the list by when runs were queued, find one by its id or by text, and filter on tags: the business keys your workflow gives each run, such as a customer or an order.
- Status
GET /v1/runs?status=failed&status=terminatedlists the runs in any of the statuses given: repeatstatusfor each. A run that ended any other way than completed, cancelled or terminated lists asfailed. An unknown status answers400. - Time range
GET /v1/runs?since=&until=takes runs queued at or aftersinceand beforeuntil, each in milliseconds or ISO 8601. Bulk cancel and re-run, the export andshiftlabs runs --since 24htake them too. - Search keys
workflow({ search: { customer: "customer.id" } })tags every run with the value at that path of its payload when it arrives: a string, a number ortrue/false; anything else gives no tag. Up to 10 keys a version, checked when you deploy. A re-run keeps the original's version, so its tags too. See Tags. step.tagawait step.tag({ stage: "shipped" })adds tags as the run goes, outsidestep.run; a newer value replaces an older one. A resumed run's repeated calls write nothing. Not a step, so it doesn't count toward a run's steps.- Tag filters
GET /v1/runs?tag.customer=cus_42lists the runs carrying every tag given, up to 10. Bulk cancel and re-run take"tags": {"customer": "cus_42"}. Each run lists itstags. - Keys
GET /v1/runs?workflow=&key=lists a keyed workflow's runs of one key, as doshiftlabs runs --workflow <name> --key <key>and MCP'slist_runs. Each run lists itskey,nullfor a run without one. - Search
qfinds a run whose id starts with it, at any age once it has 8 characters of the id, or text in its error, such as the message its code threw, its output as JSON (the first 64 KiB, while it's kept), its tags and, for a developer or admin, its payload, when that is at most 96 KiB as JSON. Case is ignored. - Search pages
A page searches the runs after its cursor, newest first, in windows: 5,000 runs for text, fewer once their outputs and payloads add up to 8 MiB, or 1,000 runs carrying the first tag.
- Short pages
A filtered page fills from up to 4 windows, then stops. When it stops short of
limit, even empty, it answers"partial": truewithnextBeforeset: the next page carries on from the last run looked at.nextBeforeisnullonly when no more runs match."scoped": truesays your API key sees only some workflows, whose runs alone it lists.
- A run holds at most 20 tags, its search keys included: a call that would give it a 21st throws
a run has at most 20 tags: <name> would be its 21st. Names are 1 to 64 letters, digits,-and_; values are 1 to 256 bytes. - Tags are kept with their run, 35 days after it ends, so a search key's value outlasts the payload's 14 days, and anyone who can see runs sees it, viewers too, who can't read payloads. Keep secrets and personal data out of tags:
step.tagreplaces readable secrets with[redacted], and a search key keeps the payload's value as it is.
Follow a run
- Dashboard
The Runs screen filters by status, workflow, Started by, time range and tags, searches by id and text, and keeps the filters you use as saved views in your browser. A failed run shows the message its code threw, and a waiting run what it waits for. A run's page shows its tags, its timeline with each step's attempts and waits, outbound requests, logs and payload, with Re-run, Cancel run and Terminate run, Pause run while it runs, Retry now while a step waits to retry, and Resume from the step a failed run failed at. While a run goes on, its page shows each log line as it reaches the logs. A run waiting for an approval shows the request, which approvers answer there with Approve or Deny and a note. Anyone else who can see the run sees the request and how many approvals it has, but not who may answer, who answered or their note.
- API
GET /v1/runsandGET /v1/runs/:id, and each run's/timeline,/logs,/logs/streamand/egress./payloadneeds a developer key. See API reference. - CLI
shiftlabs runslists runs,shiftlabs logs <run-id>prints a run's logs, andshiftlabs run <workflow>starts one. See Commands. - Kept
A run is kept 35 days after it ends.
Timeline
A run's timeline lists its dispatches, its lifecycle events and each attempt of each step, in time order. The run's page draws the steps as a waterfall: a lane per step call and a bar per attempt or wait, with the delay before each retry to scale and long idle stretches cut short.
- Steps
GET /v1/runs/:id/timelinegives each attempt of a step, and each sleep or wait, as a row withkindstep:name,step_kind(the call:run,sleep,waitForEvent,execand the others, orundo),seq(which call of that name, from 1),attempt,outcome(ok,failed,waitingortimed out),timestamp(when it began) andwall_ms(how long it took). A failed attempt has its message aserror, the first 300 characters with readable secrets as[redacted], anddelay_ms, the wait planned before the next attempt. - Waits
A sleep ends at its deadline. An event or approval that came while the run slept ends its wait when the run started again.
- Limits
A run's first 200 step calls are listed. Of a step's failed attempts that were retried, the first three are; its last attempt and the one that succeeded always are. Steps and events are kept 35 days after they happen, dispatches 14. A run's
completedorfailedevent can arrive a minute or two after the run ended, when Cloudflare reports its last dispatch late.
Logs
GET /v1/runs/:id/logs gives what a run's code printed, oldest first: each line's timestamp, invocation_id (which dispatch or command printed it), seq (its place there), level, message, step and arrived_ms (when it reached the logs).
- Pages
500 lines a page, and
limittakes up to 2,000. TheNext-Afterheader names the page's last line: send it back as?after=for the lines after it. A page shorter thanlimitholds every line so far. While the run goes on, ask again later with the same cursor for the lines that came since. - Late lines
A dispatch's lines arrive once it ends, and a command's output as the command prints it, so a line can arrive behind a cursor you already have. Once a run has ended and its lines are in, paging from the first page gives every line once, in order.
- New lines
arrived_msis when the line reached the logs, in milliseconds since the Unix epoch, or0for a line from before shiftlabs kept it. A page without?after=also has aLog-Watermarkheader: the latestarrived_msin the run's logs when that page was read, or0for a run with no lines yet. A line whosearrived_msis above it reached the logs after that read, wherever it sorts, and a line at or below it had reached them before. Pages with?after=have noLog-Watermark. Rarely, a line that reached the logs just before the read isn't readable until just after it. - Step
stepis the name of the step whose function printed the line, withlog,consoleor Python'sprint: in a step started inside another step's function the inner one, andundo <name>in an undo. A command's output has the name of thestep.execthat ran it, and an activity's the label of itsstep.activity: shiftlabs sets those, not your code. It'snulloutside every step, while two steps run at once, since the logs can't tell which of them printed the line, for exceptions, for lines of a version deployed before 7 November 2026: deploy it again forstep, and for a command's or activity's output from before 7 November 2026. Your code can print what marks a step, so treat thestepof a line your code printed as a label, not as proof of where it came from.
Stream a run's logs
GET /v1/runs/:id/logs/stream sends a run's logs as Server-Sent Events, oldest first. Each event is one data: line with a JSON array of the lines that came since the last event, each as GET /v1/runs/:id/logs gives it, and its id is the cursor of the furthest line sent so far, the same cursor as Next-After.
# -N prints each event as it arrives; the stream ends once the run has ended and its lines are in.
curl -N https://api.shiftlabs.org/v1/runs/<run>/logs/stream \
-H "authorization: Bearer $SHIFTLABS_API_KEY"
- Lines come as they reach the logs: a dispatch's once the dispatch ends, a command's output as the command prints it. The stream reads every 2 seconds. While no new lines come, the same read is answered from the 10-second cache
GET /v1/runs/:id/logsuses, so a line that reaches the logs after a quiet spell can take up to 12 seconds to come. - After a dropped connection, reconnect with
Last-Event-IDset to the last event'sid, as a browser'sEventSourcedoes: the stream goes on after that line, so each line comes once. ANext-Afterworks too, to stream on from a page you read. ALast-Event-IDthat isn't a log cursor gets400 {"error": "invalid cursor"}. - A line can reach the logs behind lines already sent, such as one your code printed outside a step, which arrives once its dispatch ends. The stream sends it in a later event, unless it's behind the last 500 lines this connection sent, or behind the
Last-Event-IDthe connection started from. Sort bytimestamp,invocation_idandseqto show lines in order. A line the stream left out is inGET /v1/runs/:id/logs. - Once the run has ended, the stream waits 90 seconds for its last lines, which can arrive a minute after the run ends. Its last event then has the id
end, and the stream closes. Reconnecting withLast-Event-ID: endgets204, which stops a browser'sEventSource. A line that arrives after that is only inGET /v1/runs/:id/logs. - A stream also ends after 5 minutes: reconnect to go on. While nothing comes, a comment line comes every 20 seconds.
- A log stream counts toward the 60 streams a workspace opens a minute, with status streams: the next gets
429withRetry-After. Each of its reads the cache doesn't answer counts toward the workspace's 120 reads a minute of run logs, timelines, egress and metrics: about 30 a minute while lines keep coming, and about 6 while none do, so four busy streams use them all. A read past them sends an eventlimitedwith{"retryAfter": 60}and noid, and the stream closes:EventSourcewaits 60 seconds, then goes on after the last line it got. - A browser's
EventSourcecan't send theauthorizationheader. Read the stream withfetch, or an SSE client that sends headers.
Reference
- Durable steps
Every step, with
retries,timeoutandundo. - Run context
What your function receives.
- Stop a run · Pause a run · Pause a workflow
Cancel, terminate, hold one run, and hold new runs.
- Clean up when a run is cancelled
onCancel, a step'ssignal, and a cancel that also undoes. - Retry now · Resume a failed run
Start a step's next attempt at once, and go on from a failed run's step without running the ones before it.
- Cancel or re-run many runs
Up to 1,000 runs that match a filter.