Skip to content

An asynchronous launch answers 202 with the run it started

A launch is no use to a client that cannot find the run it started. The answer names the run by the identifier every later read uses, and goes out only once that read can succeed.

The rule

Normative: this is the rule
  1. An asynchronous launch over the API (ORC-12) MUST be answered with 202.
  2. The answer MUST NOT be sent before the run is persisted, so that a read of the run made as soon as the answer arrives finds it.
  3. The body MUST be {success: true, data: {execution_id, status}}.
  4. execution_id MUST be a string: the persisted run's identifier, the value PIPE-1 publishes as id and a poll reports as pipeline_id.
  5. status MUST be queued, whatever status the run has been persisted with by the time the answer is sent.
  6. This is the answer OCX-7 gives an external invocation of a queued run, so a client reads both alike.
  7. The answer SHOULD carry a Location header whose value is the run's pipeline route (API-9), expanded with that identifier.
  8. A synchronous launch is not answered by this rule: its answer is implementation-defined until a rule defines it.

What it means

ORC-12 says an asynchronous launch hands back queued and runs nothing in the request. This rule says what that looks like over the API: a 202, and a body that names the run in the one identifier every later read uses. A client polls the run's status document with it, matches it against pipeline_id in a poll, and expands the pipeline route with it. The names are OCX-7's, so a launch over the API and an external invocation that queues a run read the same.

Two details make the answer usable straight away.

It goes out after the run is stored. A client that polls the moment it has the answer must not get a 404 for a run that is still being written. So the run is persisted first and the answer second.

The status is always queued. By the time the answer leaves, a fast worker may already have picked the run up, and its persisted status may be running, or even finished. The answer does not report that race; it reports what the launch did, which is to queue the run. The run's own documents say where it has got to since.

The Location header is a convenience for a client that follows it: it points at the run's full document. A client that does not read it loses nothing, since the identifier in the body is enough to build the same URL from discovery (API-9).

A synchronous launch, one that waits for the run, is not answered this way; and a synchronous wait against a workflow declared asynchronous is refused before anything is created (MAN-19). How a launch asks to wait, and what a synchronous launch answers, no rule says yet: both are each implementation's own until one does.

Example

Launching a workflow that runs asynchronously, and its answer202 — queued
POST /api/flowdrop/workflow/{workflow_id}/run

{"success": true, "data": {"execution_id": "4711", "status": "queued"}}

The answer carries Location: /api/flowdrop/pipeline/4711. A GET on the pipeline_status route for 4711, sent the moment this answer arrives, finds the run, whatever status it reports by then. The paths are examples of the routes API-9 names workflow_run and pipeline.

Why

Recorded under OPEN-52.

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · API-10 · changed in spec 1.1