Skip to main content
  • Status: Approved
  • Updated: 2026-11-25
Consistent asynchronous contracts let callers, generated SDKs, dashboards, CLIs, and AI agents start, poll, resume, and cancel long-running workflows with one shared state machine instead of per-endpoint conventions. This standard is part of Photon API Design Standards and uses the keywords MUST, MUST NOT, SHOULD, and MAY as described in RFC 2119.

Scope and Asynchronous Patterns

Not every 202 Accepted endpoint requires a separate Operation resource. Photon public HTTP APIs distinguish three asynchronous patterns:
  1. Long-Running Operations: Multi-step provisioning, billing mutations, external provider handshakes, or batch workflows whose asynchronous execution is tracked independently of a single domain entity. These endpoints MUST return 202 Accepted with a Location header pointing to GET <scope>/operations/{operationId}, an advisory Retry-After header when non-terminal, and a canonical flat Operation JSON body.
  2. Lifecycle-Bearing Resources: Domain resources whose own canonical representation carries a durable lifecycle state (for example a resource awaiting provisioning, verification, or review). Creating or mutating such a resource MAY return 202 Accepted with a Location header pointing to the resource itself rather than introducing a separate Operation resource.
  3. Fire-and-Forget Requests: Ephemeral or queued signals that have no pollable status resource (for example typing indicators or best-effort queued notifications). These endpoints MAY return 202 Accepted without a Location header.
The normative rules below apply to Long-Running Operations.

Normative Rules

1. Canonical flat Operation schema

Every Operation resource MUST be a flat top-level JSON object consistent with ADS-0002, modeled as a discriminated union keyed on status.
  • Responses MUST NOT wrap the operation under a single-key envelope such as { "operation": { ... } } or under a generic data, result, or payload envelope.
  • Every status branch MUST declare and require all eight universal fields below using their exact names:

Canonical status vocabulary

status MUST use values strictly from this six-state vocabulary:
  • Non-terminal: pending, running, requires_action (optional capability).
  • Terminal: succeeded, failed, cancelled (optional capability).
Services MAY declare a strict subset (for example omitting running, requires_action, or cancelled when unsupported), and MUST NOT invent synonyms such as queued, in_progress, processing, done, completed, or canceled. Terminal statuses (succeeded, failed, cancelled) are immutable. Once an operation reaches a terminal status, it MUST NOT transition back to a non-terminal status or to another terminal status.

Standardized optional capability fields

Services include optional capability fields only when applicable, and MUST use these reserved names when doing so:

2. Status-specific invariants

An Operation schema MUST enforce these invariants per status branch:
  • Non-terminal statuses that share identical invariants (such as pending and running) MAY share a branch.
  • Branches MUST NOT combine statuses with incompatible invariants (for example combining pending and succeeded, succeeded and failed, or requires_action with any other status in a single un-discriminated object).

3. Layered nextAction schema and requires_action invariant

The relationship between status: "requires_action" and nextAction is a strict biconditional:
  • When status is requires_action, nextAction MUST be a required, non-null structured object. If an operation is waiting on an internal job or upstream provider without requiring caller action, it MUST remain in pending or running, never requires_action.
  • On every other status (pending, running, succeeded, failed, cancelled), nextAction MUST be null (or omitted entirely by services that never enter requires_action).
Every nextAction object follows a layered contract:
  1. Required base fields:
    • type (string, required): snake_case string literal or enum discriminator identifying the caller action (for example redirect, confirm_payment, or verify_dns). MUST NOT be named kind or action.
    • expiresAt (string | null, optional, format: date-time): Reserved expiration timestamp for the action when time-bounded. MUST NOT be named deadline or validUntil.
  2. Predefined cross-service variant (redirect):
    • Services that send the user to an external or hosted URL SHOULD use the standard redirect variant: { "type": "redirect", "url": "<uri>", "expiresAt": "<date-time> | null" }, where url is a required string with format: uri and expiresAt is optional. Using redirect lets CLIs, SDKs, dashboards, and agents handle browser handoffs generically.
  3. Domain-specific variants:
    • Services MAY extend nextAction via oneOf using the same base shape and ADS-0001 <resource>Id foreign keys (for example confirm_payment referencing invoiceId, or verify_dns carrying structured DNS records).
  4. Structured and credential-safe:
    • nextAction MUST carry structured machine-readable fields and MUST NOT include a free-text message field (static instructions belong in OpenAPI descriptions).
    • Because GET <scope>/operations/{operationId} responses are repeatable reads, nextAction MUST NOT expose high-sensitivity credentials such as clientSecret, accessToken, refreshToken, password, apiKey, or secret.

4. HTTP wire protocol and route conventions

Triggering endpoint

  • Starting a long-running operation MUST return 202 Accepted with:
    • A Location response header pointing to the canonical poll URL (GET <scope>/operations/{operationId}).
    • An advisory Retry-After response header (delay in seconds) when the operation is non-terminal.
    • The flat Operation object in the response body.
  • An idempotent replay of a request whose operation has already reached a terminal status MAY return 200 OK with that terminal Operation.

Polling endpoint (GET <scope>/operations/{operationId})

  • The polling endpoint MUST return HTTP 200 OK with the flat Operation body (including when status is failed or cancelled), unless a supported conditional request returns 304 Not Modified.
  • HTTP 4xx and 5xx statuses on the polling endpoint are reserved for failures of the poll request itself (such as 404 Not Found for an unknown operation or 403 Forbidden), never for execution failure of the underlying operation.
  • Polling responses SHOULD include Retry-After while non-terminal and MAY support conditional requests via ETag and 304 Not Modified.

Optional list and cancel endpoints

  • List: GET <scope>/operations MUST return a top-level JSON object collection (for example { "operations": [ ... ], "nextPageToken": "..." }).
  • Cancel: POST <scope>/operations/{operationId}/cancel MUST return 200 OK with the updated flat Operation (or 409 Conflict when the operation is not cancellable). Cancellation MUST use POST <scope>/operations/{operationId}/cancel and MUST NOT use DELETE.

Scope symmetry

  • An operation initiated under a project route MUST be polled under /v1/projects/{projectId}/.../operations/{operationId}.
  • An operation initiated under an organization route MUST be polled under /v1/organizations/{organizationId}/.../operations/{operationId}.
  • An API MUST NOT return an operation identifier without exposing a matching pollable route under the same scope.

Examples

Triggering an operation (202 Accepted)

Good — POST /v1/projects/{projectId}/plan-changes returns 202 Accepted with Location, Retry-After, and a flat pending Operation:

Polling requires_action variants (200 OK)

Good — predefined cross-service redirect variant (connection.authorize):
Good — domain-specific confirm_payment variant (plan.change) referencing invoiceId per ADS-0001:

Terminal outcomes (200 OK)

Good — succeeded with typed response (plan.change):
Good — failed with RFC 9457 Problem Details in error (returned with HTTP 200 OK from GET .../operations/{operationId}):

Non-conformant patterns

Bad — wrapped under { "operation": ... }, non-canonical field names (operationId, kind, state, submittedAt, resolvedAt, result, failure), and non-canonical status "in_progress":
Bad — leaking a high-sensitivity credential (clientSecret) and free-text message inside nextAction, or using DELETE to cancel:

Non-operation 202 Accepted endpoints (unaffected)

Good — lifecycle-bearing resource returning 202 Accepted with Location pointing to the domain resource itself (POST /v1/projects/{projectId}/domains):
Good — fire-and-forget 202 Accepted with no Location header (POST /v1/projects/{projectId}/typing):

Changelog

  • 2026-11-25: Approved and published as ADS-0004.

Feedback

Found a Photon API that does not follow this standard, or have a suggestion to improve it? Open an issue in photon-hq/api-design-standards (we do not accept external pull requests).