Skip to main content
  • Status: Approved
  • Updated: 2026-11-28
Consistent HTTP methods, read symmetry, status codes, and URL structure let callers, generated SDKs, dashboards, CLIs, and automated agents navigate every Photon resource lifecycle without endpoint-specific special cases. 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

This standard defines the lifecycle contract for resource collections, addressable items, singletons, and custom state-transition actions across Photon public HTTP APIs:
  • Standard HTTP method semantics and prohibited anti-patterns.
  • Read symmetry for mutable resources, custom actions, and addressable collections.
  • Canonical 2xx success status codes and representation consistency.
  • URL path segment casing and noun conventions.
  • Partial-update (PATCH) wire semantics using JSON Merge Patch (RFC 7396).
Related concerns are governed by separate standards:
  • Resource identifier fields (id, <resource>Id) and URL path parameter naming ({<resource>Id}) are defined in ADS-0001.
  • Flat top-level JSON response objects and one-time creation secrets are defined in ADS-0002.
  • Asynchronous long-running operations (202 Accepted, Operation schema, polling, and cancellation) are defined in ADS-0004.
  • Pagination, filtering, and sorting query parameters and write-operation idempotency semantics (Idempotency-Key on mutating methods) are outside the scope of this standard.

Normative Rules

1. Standard HTTP method semantics

Photon public HTTP APIs MUST map standard resource lifecycle operations to standard HTTP methods:
  • Static URL path segments MUST NOT embed CRUD verbs (create, get, list, update, delete, remove, fetch, edit, or add) either as standalone segments (such as /v1/projects/create) or as prefixes (such as /v1/projects/get-project, /v1/getUser, /v1/list-projects, or /v1/api-keys/delete-key). Legitimate state-mutating domain actions such as revoke, cancel, rotate, retry, resend, archive, restore, verify, enable, disable, transfer-ownership, and batch remain allowed on POST, while read-only endpoints such as preview, search, and query MAY use GET or POST.
  • A single endpoint path MUST NOT declare both PUT and PATCH. Choose PATCH for partial updates or PUT for full replacement and idempotent upsert—never both on the same path.
  • GET operations MUST NOT declare a request body (requestBody). Complex queries that exceed query-string limits SHOULD use a dedicated POST search or query endpoint.
  • Collection-level DELETE operations (paths not ending in a resource identifier parameter {<resource>Id}) MUST NOT declare a request body. Single-resource deletes identify the target in the URL path, singleton deletes require no body, and bulk deletions SHOULD use a dedicated POST batch endpoint.

Safe and side-effect-free GET and HEAD semantics

  • GET (and HEAD) operations MUST be safe and idempotent per RFC 9110 Section 9.2.1: they MUST NOT create, modify, or delete resources, overwrite or invalidate in-flight operations or authorization attempts, mint, rotate, or revoke credentials, or trigger external side effects. Only passive observability (such as access logging, metrics, or cache warming) is permitted, except under the narrow protocol-mandated browser callback exception below.
  • External callers depend on this guarantee: browser prefetching, enterprise URL security scanners, link previews, double-clicks, SDK automatic retries, and automated agents treat GET as read-only and safe to replay without confirmation. If a GET handler mutates state or overwrites an active authorization attempt, a single background scan or retried click silently breaks the caller’s live workflow.
  • GET (and HEAD) operations MUST NOT declare an Idempotency-Key header parameter (existing parameters marked deprecated: true are permitted only during migration). Requiring an idempotency key signals a state-changing request that belongs on POST, PUT, PATCH, or DELETE.
  • GET (and HEAD) operations MUST NOT expose unmistakable state-mutating action verbs (such as /revoke, /cancel, /rotate, /retry, /resend, /archive, /restore, /enable, /disable, /transfer-ownership, /pay, /purchase, /approve, /reject, /confirm, /submit, /trigger, /publish, /unpublish, /suspend, /unsuspend, /activate, /deactivate, /refund, /void, /reset, /purge, /invalidate, /disconnect, /unlink, /install, /uninstall, /deploy, /rollback, /pause, /resume, or /verify) as their terminal path segment. State-changing actions belong on POST.
  • Read-only helper and outbound relay routes (such as /redirect, /download, /export, /preview, /search, /query, /count, /status, /pdf, or /receipt) remain allowed on GET, provided their handler obeys the safe, side-effect-free requirement above.

Protocol-mandated browser callbacks (GET .../callback)

External browser-redirect protocols—such as OAuth 2.0 Authorization Code Grant (RFC 6749 Section 4.1.2), OpenID Connect, SSO, and third-party integration install flows—require the external provider to return the user’s browser via an HTTP GET redirect carrying authorization parameters. Because the provider dictates the HTTP method, an inbound browser callback endpoint (including a 302 callback hop chained directly from that provider return before continuing the provider’s browser flow) MAY complete that single bound authorization or installation handoff (such as exchanging an authorization code, establishing a browser session, or binding the authorized installation) only when all of the following invariants hold:
  1. Protocol-mandated browser flow: The route exists solely to receive an external browser redirect that cannot deliver POST. Outbound handoffs initiated by a caller (such as GET .../redirect) and general API operations MUST NOT use this exception.
  2. Short-lived, single-use, initiator-bound correlation: Before performing any state transition, the handler MUST verify a short-lived, single-use, unpredictable opaque correlation token (generated with a cryptographically secure random generator, such as an OAuth state or authorization attempt token) bound to the initiating user’s authenticated session or PKCE/CSRF cookie (see RFC 6749 Sections 10.10 and 10.12), so unauthenticated link scanners, prefetches, or other principals cannot guess, trigger, or hijack it.
  3. Convergent replay and concurrency handling: Replaying or concurrently delivering the same callback (such as from a double-click or browser reload) MUST NOT create, rotate, or overwrite any in-flight attempt or resource; the handler MUST converge to the already-settled redirect outcome or cleanly reject the spent token.
  4. Redirect-only, non-cacheable response: The endpoint MUST respond only with an HTTP redirect (such as 302 Found) carrying Cache-Control: no-store (and SHOULD set Referrer-Policy: no-referrer), and MUST NOT act as a JSON API endpoint returning 200 data payloads.
  5. Callback route naming: The route path MUST use /callback (or /callback/<provider> / /callback/{provider} when segmented by external provider) rather than a state-mutating action verb such as /resume or /complete.

2. Read symmetry for addressable resources

Every addressable resource that can be listed, modified, deleted, or transitioned through a custom action MUST be directly readable via GET.

Mutation-to-read symmetry

  • On any addressable item path ending in {<resource>Id}, if the path declares PATCH, PUT, or DELETE, or exposes a custom action sub-route POST .../{<resource>Id}/<action>, the API MUST also expose a single-resource GET—either directly on the same item path (GET .../{<resource>Id}) or on a hoisted canonical item path (after removing one or more leading /<scope>/{<scopeId>} prefixes) with a compatible resource representation.
  • On any singleton resource path (not ending in {<resource>Id}), if the path declares PATCH, PUT, or DELETE (excluding collection DELETE endpoints with a request body), the exact same path MUST also declare GET.

Collection-to-item read symmetry

  • Whenever a collection GET endpoint returns a collection envelope whose array items declare a canonical ADS-0001 primary identifier field (id), the API MUST expose a corresponding single-resource GET endpoint:
    1. Direct child route: GET <collectionPath>/{<resource>Id} (for example GET /v1/projects/{projectId}/webhooks paired with GET /v1/projects/{projectId}/webhooks/{webhookId}), OR
    2. Hoisted canonical route: GET /v1/<resource>/{<resource>Id} (or a less-nested canonical path obtained by removing one or more leading /<scope>/{<scopeId>} pairs after the version prefix, for example GET /v1/organizations/{organizationId}/projects paired with GET /v1/projects/{projectId}), provided the list item schema and hoisted GET response schema are compatible (either referencing the same schema or forming a compatible summary projection whose required properties and id type match the canonical item schema).
  • Non-resource lookup collections whose items do not carry a primary id (such as supported countries, permission scopes, or recommendations) and multi-field composite summaries are outside this requirement.
  • Rare append-only streams or audit logs whose items carry an id but intentionally have no single-item GET endpoint SHOULD document the reason explicitly.

3. Standard success status codes

Standard resource methods MUST use predictable 2xx HTTP status codes:

4. Representation consistency

  • GET, POST (201 Created), PATCH (200 OK), and PUT (200 OK or 201 Created) for the same resource SHOULD return the same canonical flat JSON representation per ADS-0002.
  • Items returned by a collection GET SHOULD use the same canonical resource schema or a strict summary projection that preserves id and shared field names and types so callers can fetch full details from the corresponding item GET without renaming fields.
  • Only one-time creation secrets (such as secret or signingSecret, returned as flat sibling fields per ADS-0002) MAY be returned exclusively on POST 201 Created and omitted from subsequent GET and PATCH responses.
  • Synchronous 201 Created responses SHOULD include a Location response header pointing to the newly created resource’s canonical GET URL (for example Location: https://api.photon.codes/v1/projects/prj_01h455vb4pex5vsknk084sn02q/webhooks/whk_01h455vb4pex5vsknk084sn02z).

5. URL path naming

  • Every static URL path segment (excluding {param} placeholders, leading version prefixes such as v1, and .well-known) MUST use lowercase kebab-case (for example /v1/projects/{projectId}/api-keys and /v1/projects/{projectId}/agent-profile).
  • Static segments MUST NOT use camelCase (/apiKeys), snake_case (/api_keys), uppercase letters (/Projects), dots, or spaces.
  • Collection path segments SHOULD use plural nouns (for example projects, webhooks, api-keys, members, invoices), and singleton sub-resource path segments SHOULD use singular nouns (for example agent-profile).

6. Partial updates (PATCH)

Every PATCH endpoint MUST use a JSON object merge-patch contract based on JSON Merge Patch (RFC 7396) over Content-Type: application/json, with two explicit Photon profile rules for typed nullable fields and dynamic key-value maps:
  • Media type and payload shape: PATCH requests MUST accept a JSON object over application/json (or a compatible JSON media type). Top-level arrays, scalars, and null are forbidden. Endpoints MUST NOT use JSON Patch (RFC 6902, application/json-patch+json, or a top-level patch-operation array) and MUST NOT accept or require field-mask query parameters or body fields (fieldMask, updateMask, field_mask, update_mask, fieldsMask, fields_mask).
  • Three-state field semantics:
    • Omitted field: Leave the current stored value unchanged.
    • Explicit null (Photon typed-schema rule): Whereas raw RFC 7396 §2 removes an object member on null, Photon’s typed resource schemas represent cleared nullable fields explicitly as null (type: ["<T>", "null"]). Sending null MUST clear a nullable field to null. Explicit null is valid only on fields whose canonical representation allows null; sending null for a non-nullable field MUST be rejected with 422 Unprocessable Content (RFC 9457 Problem Details, VALIDATION_FAILED).
    • Non-null value: Set or replace the field with the supplied value.
  • Nested objects, arrays, and maps:
    • Plain nested objects (fixed-schema sub-objects such as notifications or settings) MUST merge recursively under the same three-state rules per RFC 7396, so omitting a sibling nested field leaves that sibling unchanged.
    • Arrays MUST replace wholesale per RFC 7396—supplying an array replaces the entire stored list rather than appending or element-diffing.
    • Dynamic key-value maps (Photon profile deviation from raw RFC 7396 §2): Unlike raw RFC 7396 (which recursively merges all JSON objects and requires per-key null tombstones to remove entries), arbitrary key-value maps (additionalProperties dictionaries such as labels or metadata) MUST replace wholesale unless an endpoint explicitly documents per-key RFC 7396 null-deletion merge semantics.
  • Atomicity: Every PATCH request MUST execute atomically (all-or-nothing). If any field fails schema validation, authorization, or a domain invariant, the server MUST return an error without committing a partial subset of changes.
  • Wire contract constraints:
    • PATCH request schemas MUST NOT declare top-level required properties, except an explicit discriminator.propertyName on a polymorphic oneOf or anyOf union schema. Every mutable field MUST be optional so callers can update any subset.
    • PATCH request schemas MUST reject unknown properties (additionalProperties: false, or unevaluatedProperties: false on composed schemas) so typos and unsupported fields fail explicitly with 422 Unprocessable Content (RFC 9457 Problem Details, VALIDATION_FAILED) rather than being silently dropped. Intentional open-dictionary maps that declare typed additionalProperties without fixed resource properties are exempt.
    • PATCH request schemas SHOULD reject empty patch payloads ({}) with minProperties: 1 unless the endpoint explicitly documents empty-patch no-op behavior. An empty patch rejected under minProperties: 1 MUST fail with 422 Unprocessable Content (VALIDATION_FAILED).
  • Error status codes: A request body that is not syntactically valid JSON MUST return 400 Bad Request (RFC 9110 §15.5.1). A well-formed JSON body that fails schema or field validation (unknown properties, null on a non-nullable field, wrong types, or an empty patch under minProperties: 1) MUST return 422 Unprocessable Content (RFC 9110 §15.5.21) as RFC 9457 Problem Details with error code VALIDATION_FAILED.

Examples

Standard CRUD resource lifecycle

Good — plural kebab-case collection with GET 200, POST 201 + Location, direct item GET 200, PATCH 200 returning the updated resource, and DELETE 204 with no body:

Scoped collection list with hoisted canonical GET

Good — GET /v1/organizations/{organizationId}/projects lists Project items and pairs with the hoisted canonical item endpoint GET /v1/projects/{projectId}:

Singleton resource and custom item action

Good — singleton agent-profile pairs PATCH with GET on the same path, and custom item action POST .../api-keys/{apiKeyId}/revoke pairs with GET .../api-keys/{apiKeyId}:

Safe browser redirect handoffs and protocol-mandated callbacks

Good — outbound relay (GET .../redirect): create the external authorization attempt during the preceding POST, and have the relay GET read-only reuse the active unconsumed attempt to return 302 Found. Repeated GET requests from browser prefetching, enterprise URL scanners, or double-clicks redirect to the same active attempt without invalidating the in-flight workflow:
The POST response returns 202 Accepted with an Operation whose nextAction.url points to the read-only relay route. Following that link performs no state mutation:
Good — protocol-mandated inbound browser callback (GET .../callback): when the external provider redirects the browser back after OAuth or integration approval, the callback verifies the short-lived, single-use, unpredictable correlation token against the initiating session, converges on concurrent or replayed hits without creating or replacing attempts, and responds only with a non-cacheable 302 Found:
Bad — creating or rotating a fresh authorization attempt and overwriting the operation’s active state on every GET /v1/operations/{operationId}/redirect, exposing state-mutating verbs (such as /revoke or /resume) or Idempotency-Key headers on GET, or using a JSON GET endpoint to complete a state transition:

Partial updates (PATCH)

Good — RFC 7396 JSON Merge Patch over application/json: updating displayName, clearing nullable bio with explicit null, and recursively merging notifications.emailEnabled while leaving omitted fields (such as notifications.smsEnabled) untouched:
Its request schema keeps every mutable field optional, marks clearable fields nullable, forbids unknown properties, and rejects empty patches:
Bad — RFC 6902 application/json-patch+json, updateMask parameters or fields, required top-level PATCH properties, or open schemas that silently accept unknown fields:

Non-conformant patterns

Bad — CRUD verbs in URL segments, camelCase/snake_case paths, both PUT and PATCH on one path, GET with requestBody, collection DELETE with requestBody, collection POST returning only 200, PATCH 204, DELETE 204 with a response body, and an addressable list with no item GET:

Changelog

  • 2026-11-26: Approved and published as ADS-0005.
  • 2026-11-26: Codified RFC 9110 safe, side-effect-free semantics for GET and HEAD in §1, added browser redirect handoff guidance, and prohibited Idempotency-Key header parameters and unmistakable state-mutating terminal action verbs on GET and HEAD.
  • 2026-11-27: Clarified the narrow exception for protocol-mandated inbound browser callbacks (GET .../callback per RFC 6749 OAuth, SSO, and third-party integration redirects) with single-use initiator-bound correlation, convergent replay, and non-cacheable 302 redirect guardrails, while keeping outbound /redirect relays and regular GET operations strictly side-effect-free.
  • 2026-11-28: Codified RFC 7396 JSON Merge Patch semantics for PATCH partial updates in §6 (three-state omitted/null/value rules, recursive plain-object merge vs wholesale array/map replacement, atomicity, prohibition of RFC 6902 JSON Patch and field masks, optional top-level fields, and strict unknown-property rejection), returning 422 Unprocessable Content (VALIDATION_FAILED) for schema-invalid payloads and 400 Bad Request for malformed JSON.

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).