- Status: Approved
- Updated: 2026-11-25
Scope and Asynchronous Patterns
Not every202 Accepted endpoint requires a separate Operation resource. Photon public HTTP APIs distinguish three asynchronous patterns:
- 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 Acceptedwith aLocationheader pointing toGET <scope>/operations/{operationId}, an advisoryRetry-Afterheader when non-terminal, and a canonical flatOperationJSON body. - 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 Acceptedwith aLocationheader pointing to the resource itself rather than introducing a separateOperationresource. - 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 Acceptedwithout aLocationheader.
Normative Rules
1. Canonical flat Operation schema
EveryOperation 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 genericdata,result, orpayloadenvelope. - Every
statusbranch 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).
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
AnOperation schema MUST enforce these invariants per status branch:
- Non-terminal statuses that share identical invariants (such as
pendingandrunning) MAY share a branch. - Branches MUST NOT combine statuses with incompatible invariants (for example combining
pendingandsucceeded,succeededandfailed, orrequires_actionwith 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
statusisrequires_action,nextActionMUST 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 inpendingorrunning, neverrequires_action. - On every other status (
pending,running,succeeded,failed,cancelled),nextActionMUST benull(or omitted entirely by services that never enterrequires_action).
nextAction object follows a layered contract:
- Required base fields:
type(string, required):snake_casestring literal or enum discriminator identifying the caller action (for exampleredirect,confirm_payment, orverify_dns). MUST NOT be namedkindoraction.expiresAt(string | null, optional,format: date-time): Reserved expiration timestamp for the action when time-bounded. MUST NOT be nameddeadlineorvalidUntil.
- Predefined cross-service variant (
redirect):- Services that send the user to an external or hosted URL SHOULD use the standard
redirectvariant:{ "type": "redirect", "url": "<uri>", "expiresAt": "<date-time> | null" }, whereurlis a required string withformat: uriandexpiresAtis optional. Usingredirectlets CLIs, SDKs, dashboards, and agents handle browser handoffs generically.
- Services that send the user to an external or hosted URL SHOULD use the standard
- Domain-specific variants:
- Services MAY extend
nextActionviaoneOfusing the same base shape andADS-0001<resource>Idforeign keys (for exampleconfirm_paymentreferencinginvoiceId, orverify_dnscarrying structured DNSrecords).
- Services MAY extend
- Structured and credential-safe:
nextActionMUST carry structured machine-readable fields and MUST NOT include a free-textmessagefield (static instructions belong in OpenAPI descriptions).- Because
GET <scope>/operations/{operationId}responses are repeatable reads,nextActionMUST NOT expose high-sensitivity credentials such asclientSecret,accessToken,refreshToken,password,apiKey, orsecret.
4. HTTP wire protocol and route conventions
Triggering endpoint
- Starting a long-running operation MUST return
202 Acceptedwith:- A
Locationresponse header pointing to the canonical poll URL (GET <scope>/operations/{operationId}). - An advisory
Retry-Afterresponse header (delay in seconds) when the operation is non-terminal. - The flat
Operationobject in the response body.
- A
- An idempotent replay of a request whose operation has already reached a terminal status MAY return
200 OKwith that terminalOperation.
Polling endpoint (GET <scope>/operations/{operationId})
- The polling endpoint MUST return HTTP
200 OKwith the flatOperationbody (including whenstatusisfailedorcancelled), unless a supported conditional request returns304 Not Modified. - HTTP
4xxand5xxstatuses on the polling endpoint are reserved for failures of the poll request itself (such as404 Not Foundfor an unknown operation or403 Forbidden), never for execution failure of the underlying operation. - Polling responses SHOULD include
Retry-Afterwhile non-terminal and MAY support conditional requests viaETagand304 Not Modified.
Optional list and cancel endpoints
- List:
GET <scope>/operationsMUST return a top-level JSON object collection (for example{ "operations": [ ... ], "nextPageToken": "..." }). - Cancel:
POST <scope>/operations/{operationId}/cancelMUST return200 OKwith the updated flatOperation(or409 Conflictwhen the operation is not cancellable). Cancellation MUST usePOST <scope>/operations/{operationId}/canceland MUST NOT useDELETE.
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):
confirm_payment variant (plan.change) referencing invoiceId per ADS-0001:
Terminal outcomes (200 OK)
Good — succeeded with typed response (plan.change):
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":
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):
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 inphoton-hq/api-design-standards (we do not accept external pull requests).