Async REST
Architecture-version applicability
| Architecture version | Status | Notes |
|---|---|---|
| V2 | Adopted | Recorded by ADR-0020 as the asynchronous HTTP pattern. |
| V3 | Adopted | Used for long-running operations through BFF/APIM boundaries. |
| V4 | Not reviewed | A V4 baseline has not been incorporated into this documentation set. |
Problem
REST clients expect timely responses; typical HTTP timeouts are 30–60 seconds. Many ION operations legitimately take longer — a playbook run, a bulk enrichment, an incident export. Blocking the HTTP thread until the operation completes is wrong for three reasons:
- It ties up connection resources upstream (client, Front Door, App Gateway, APIM, BFF) for the duration.
- Timeouts across the layered edge chain make long calls fragile — any layer can drop the connection.
- It couples the request lifetime to the compute lifetime; a pod restart mid-request means the client sees a 5xx and has no easy way to resume.
The Async REST pattern separates request acceptance from operation completion.
Solution
Return 202 Accepted immediately; expose the operation as a status resource the client polls.
Flow:
-
Client
POST /resourcewith an operation-triggering command. -
BFF validates, publishes a Service Bus command or starts a Temporal workflow (ADR-0019), persists an operation record.
-
BFF responds:
HTTP/1.1 202 Accepted Location: /operations/<operationId> Retry-After: 5 -
Client polls
GET /operations/<operationId>, receiving:{ "status": "pending | running | succeeded | failed", "startedAt": "...", "updatedAt": "...", "result": { ... }?, "error": { ... }? } -
On success, either return the final resource inline or
303 See Other→Location: /resource/<id>.
Companion patterns:
- Idempotent on client-supplied
Idempotency-Key— repeatedPOSTreturns the same operation ID. - Emit domain events on state transitions so callers can subscribe instead of poll where appropriate.
When to use
- Any operation exceeding a request-response budget (typ. > 5 seconds).
- Any operation that could survive a restart via workflow durability (Temporal-hosted).
- Any bulk / batch operation.
Not for:
- Simple synchronous CRUD.
- Trivial reads.
Consequences
Positive
- Client and server decoupled from operation duration.
- Restarts don’t break the client’s view of the operation.
- Works cleanly through the layered edge — no long-held connections.
- Enables cancellation, progress reporting, retries.
Negative
- Two round-trips (submit + poll) vs. one.
- Requires an operation record store (usually the domain event store or a lightweight ops projection).
- Clients must implement polling / subscription.
Failure modes
- Operation store not durable — restart loses in-flight status.
- Missing
Retry-After— clients hammer poll endpoints. - Poll endpoint expensive — pushes cost into read side.
References
references/Design Pattern- ASYNC Rest API.md- ADRs: 0019, 0020.
- Related patterns: Idempotent Write, Dual Writes.
Applied in
- Playbook run triggers (Cogs)
- Bulk incident export (Watchtower)
- Long-running admin operations across the platform
- Any Temporal-backed workflow trigger through a BFF