- Status: Approved
- Updated: 2026-11-28
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
2xxsuccess status codes and representation consistency. - URL path segment casing and noun conventions.
- Partial-update (
PATCH) wire semantics using JSON Merge Patch (RFC 7396).
- Resource identifier fields (
id,<resource>Id) and URL path parameter naming ({<resource>Id}) are defined inADS-0001. - Flat top-level JSON response objects and one-time creation secrets are defined in
ADS-0002. - Asynchronous long-running operations (
202 Accepted,Operationschema, polling, and cancellation) are defined inADS-0004. - Pagination, filtering, and sorting query parameters and write-operation idempotency semantics (
Idempotency-Keyon 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, oradd) 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 asrevoke,cancel,rotate,retry,resend,archive,restore,verify,enable,disable,transfer-ownership, andbatchremain allowed onPOST, while read-only endpoints such aspreview,search, andqueryMAY useGETorPOST. - A single endpoint path MUST NOT declare both
PUTandPATCH. ChoosePATCHfor partial updates orPUTfor full replacement and idempotent upsert—never both on the same path. GEToperations MUST NOT declare a request body (requestBody). Complex queries that exceed query-string limits SHOULD use a dedicatedPOSTsearch or query endpoint.- Collection-level
DELETEoperations (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 dedicatedPOSTbatch endpoint.
Safe and side-effect-free GET and HEAD semantics
GET(andHEAD) 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
GETas read-only and safe to replay without confirmation. If aGEThandler mutates state or overwrites an active authorization attempt, a single background scan or retried click silently breaks the caller’s live workflow. GET(andHEAD) operations MUST NOT declare anIdempotency-Keyheader parameter (existing parameters markeddeprecated: trueare permitted only during migration). Requiring an idempotency key signals a state-changing request that belongs onPOST,PUT,PATCH, orDELETE.GET(andHEAD) 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 onPOST.- Read-only helper and outbound relay routes (such as
/redirect,/download,/export,/preview,/search,/query,/count,/status,/pdf, or/receipt) remain allowed onGET, 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:
- 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 asGET .../redirect) and general API operations MUST NOT use this exception. - 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
stateor authorizationattempttoken) 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. - 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.
- Redirect-only, non-cacheable response: The endpoint MUST respond only with an HTTP redirect (such as
302 Found) carryingCache-Control: no-store(and SHOULD setReferrer-Policy: no-referrer), and MUST NOT act as a JSON API endpoint returning200data payloads. - 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/resumeor/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 viaGET.
Mutation-to-read symmetry
- On any addressable item path ending in
{<resource>Id}, if the path declaresPATCH,PUT, orDELETE, or exposes a custom action sub-routePOST .../{<resource>Id}/<action>, the API MUST also expose a single-resourceGET—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 declaresPATCH,PUT, orDELETE(excluding collectionDELETEendpoints with a request body), the exact same path MUST also declareGET.
Collection-to-item read symmetry
- Whenever a collection
GETendpoint returns a collection envelope whose array items declare a canonicalADS-0001primary identifier field (id), the API MUST expose a corresponding single-resourceGETendpoint:- Direct child route:
GET <collectionPath>/{<resource>Id}(for exampleGET /v1/projects/{projectId}/webhookspaired withGET /v1/projects/{projectId}/webhooks/{webhookId}), OR - 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 exampleGET /v1/organizations/{organizationId}/projectspaired withGET /v1/projects/{projectId}), provided the list item schema and hoistedGETresponse schema are compatible (either referencing the same schema or forming a compatible summary projection whose required properties andidtype match the canonical item schema).
- Direct child route:
- 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
idbut intentionally have no single-itemGETendpoint SHOULD document the reason explicitly.
3. Standard success status codes
Standard resource methods MUST use predictable2xx HTTP status codes:
4. Representation consistency
GET,POST(201 Created),PATCH(200 OK), andPUT(200 OKor201 Created) for the same resource SHOULD return the same canonical flat JSON representation perADS-0002.- Items returned by a collection
GETSHOULD use the same canonical resource schema or a strict summary projection that preservesidand shared field names and types so callers can fetch full details from the corresponding itemGETwithout renaming fields. - Only one-time creation secrets (such as
secretorsigningSecret, returned as flat sibling fields perADS-0002) MAY be returned exclusively onPOST201 Createdand omitted from subsequentGETandPATCHresponses. - Synchronous
201 Createdresponses SHOULD include aLocationresponse header pointing to the newly created resource’s canonicalGETURL (for exampleLocation: 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 asv1, and.well-known) MUST use lowercasekebab-case(for example/v1/projects/{projectId}/api-keysand/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 exampleagent-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:
PATCHrequests MUST accept a JSON object overapplication/json(or a compatible JSON media type). Top-level arrays, scalars, andnullare 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 onnull, Photon’s typed resource schemas represent cleared nullable fields explicitly asnull(type: ["<T>", "null"]). SendingnullMUST clear a nullable field tonull. Explicitnullis valid only on fields whose canonical representation allowsnull; sendingnullfor a non-nullable field MUST be rejected with422 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
notificationsorsettings) 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
nulltombstones to remove entries), arbitrary key-value maps (additionalPropertiesdictionaries such aslabelsormetadata) MUST replace wholesale unless an endpoint explicitly documents per-key RFC 7396null-deletion merge semantics.
- Plain nested objects (fixed-schema sub-objects such as
- Atomicity: Every
PATCHrequest 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:
PATCHrequest schemas MUST NOT declare top-levelrequiredproperties, except an explicitdiscriminator.propertyNameon a polymorphiconeOforanyOfunion schema. Every mutable field MUST be optional so callers can update any subset.PATCHrequest schemas MUST reject unknown properties (additionalProperties: false, orunevaluatedProperties: falseon composed schemas) so typos and unsupported fields fail explicitly with422 Unprocessable Content(RFC 9457 Problem Details,VALIDATION_FAILED) rather than being silently dropped. Intentional open-dictionary maps that declare typedadditionalPropertieswithout fixed resourcepropertiesare exempt.PATCHrequest schemas SHOULD reject empty patch payloads ({}) withminProperties: 1unless the endpoint explicitly documents empty-patch no-op behavior. An empty patch rejected underminProperties: 1MUST fail with422 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,nullon a non-nullable field, wrong types, or an empty patch underminProperties: 1) MUST return422 Unprocessable Content(RFC 9110 §15.5.21) as RFC 9457 Problem Details with error codeVALIDATION_FAILED.
Examples
Standard CRUD resource lifecycle
Good — plural kebab-case collection withGET 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 — singletonagent-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:
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:
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:
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:
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
GETandHEADin §1, added browser redirect handoff guidance, and prohibitedIdempotency-Keyheader parameters and unmistakable state-mutating terminal action verbs onGETandHEAD. - 2026-11-27: Clarified the narrow exception for protocol-mandated inbound browser callbacks (
GET .../callbackper RFC 6749 OAuth, SSO, and third-party integration redirects) with single-use initiator-bound correlation, convergent replay, and non-cacheable302redirect guardrails, while keeping outbound/redirectrelays and regularGEToperations strictly side-effect-free. - 2026-11-28: Codified RFC 7396 JSON Merge Patch semantics for
PATCHpartial 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), returning422 Unprocessable Content(VALIDATION_FAILED) for schema-invalid payloads and400 Bad Requestfor malformed JSON.
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).