- Status: Approved
- Updated: 2026-11-28
Scope
This standard governs schema consistency across every representation of a resource within Photon public HTTP APIs:- Single canonical resource schemas anchored to single-resource
GET 200responses. - Per-service canonical
Operationresource modeling for long-running operations. - Cross-method response consistency across
GET,POST,PATCH, andPUT. - Strict subset guarantees for collection
GETitem slices. - Field-name, type, and writability symmetry for
POST,PATCH, andPUTrequest bodies. - Declarative schema roles through the
x-photon-resourceOpenAPI extension. - Sub-resources: owned value objects, embedded resources and nested slices, and URL-nested collection and singleton sub-resources.
- Resource identifier fields (
id,<resource>Id) and URL path parameter naming ({<resource>Id}) are defined inADS-0001. - Flat top-level JSON response objects and flat one-time creation secrets are defined in
ADS-0002. - Long-running operation lifecycle, polling, and
Operationenvelope fields are defined inADS-0004. - Standard HTTP methods, read symmetry, canonical status codes, URL naming, and RFC 7396 JSON Merge Patch wire rules are defined in
ADS-0005. - Forward cursor pagination (
pageSize,pageToken,nextPageToken) is defined inADS-0006.
Normative Rules
1. Canonical Resource Model
Every addressable resource and singleton MUST have a single authoritative canonical resource schema (C), defined by its single-resource GET 200 representation.
- Whether a resource is retrieved at a direct child path (for example
GET /v1/projects/{projectId}/api-keys/{apiKeyId}) or at a hoisted canonical path (for exampleGET /v1/projects/{projectId}paired withGET /v1/organizations/{organizationId}/projects), that single-resourceGET 200schema is the source of truth for the resource’s field names, types, nullability, and nested structures. - Single-resource fields MUST appear flat at the root JSON object per
ADS-0002. - Server-managed attributes (such as
id,createdAt,updatedAt, and computed status or audit fields) SHOULD be annotated withreadOnly: trueonCso documentation, SDK generators, and automated validators can distinguish output-only fields from writable attributes. - Every other representation of that resource — collection list items, mutation responses, and mutation request bodies — MUST derive from
Crather than inventing parallel field names or incompatible types.
2. Per-Service Operation Canonical Resource
Long-running operations (defined in ADS-0004) MUST be modeled as a canonical resource scoped to the owning service or domain (for example projects.operation or billing.operation), not as a single shared cross-service union across all domains.
- Each service’s
Operationcanonical schema MUST satisfy the universalADS-0004contract (id,type,status,createdAt,updatedAt,completedAt,response, anderror, plus optionalcancellable,nextAction, andmetadatawith allADS-0004status-specific invariants), while specializingtype,response,nextAction, andmetadatastrictly to the operation types that service owns. - Scoping the canonical
Operationresource per service keeps generated SDK unions small, prevents unrelated services from coupling their release cycles, and gives each service’sGET .../operations/{operationId}endpoint a clean canonical schemaC. - Tracked long-running asynchronous mutations returning
202 AcceptedperADS-0004return the owning service’s canonicalOperationresource rather than the target domain resource. Lifecycle-bearing resources returning202 AcceptedwithLocationpointing to the resource itself and fire-and-forget202 Acceptedendpoints remain governed byADS-0004andADS-0005.
3. Cross-Method Response Consistency
Every synchronous2xx JSON response returning a single resource — GET 200, PATCH 200, PUT 200/201, and synchronous collection POST 200/201 — MUST be structurally consistent with the resource’s canonical GET 200 representation C:
- Every field returned in the response MUST exist on
Cwith the same name and a compatible (equal or narrower) JSON type, checked recursively through nested objects and arrays. - Responses MUST NOT omit required properties declared on
C, rename canonical fields, or attach ad-hoc fields absent fromC. - The following narrow exceptions apply:
- One-time creation secrets (
ADS-0002§3): A synchronous creation response (POST 200/201orPUT 201) MAY return a one-time sensitive credential (such assecret,signingSecret,clientSecret,token, oraccessToken) as a flat sibling top-level field alongside all canonical fields ofC. SubsequentGET,PATCH, andDELETEresponses omit the one-time secret while keeping every canonical field identical. Creation responses MUST NOT wrap the resource and secret in a split two-key envelope ({ "apiKey": { ... }, "secret": "..." }), perADS-0002§3. - Asynchronous operations (
ADS-0004): Tracked long-running202 Acceptedresponses (and synchronous idempotent replays on endpoints declaring202that return anADS-0004Operationresource) return the owning service’sOperationschema rather thanC. - Bodyless responses:
204 No Contentresponses (such asDELETE 204) return no body.
- One-time creation secrets (
- Custom action endpoints (
POST .../{resourceId}/<action>) and query/utility endpoints (such as/search,/query,/preview,/validate,/batch,/count, or/status) are governed by their own action or query contracts and are not required to returnCunless the action updates and returns the resource itself.
4. Collection Slices
CollectionGET 200 endpoints MAY return either the full canonical schema C for each item in the collection array or a slice (strict projection) of C that omits expensive, bulky, or nested fields.
- Every property declared on a collection list item MUST exist on
Cwith the exact same name and a compatible (equal or narrower) type, checked recursively through nested objects and arrays. - Collection items MUST NOT introduce list-only fields absent from
C, rename canonical fields, or widen a field’s type relative toC. - If a computed summary or metadata attribute is useful on collection responses, expose it on
Cas well so single-resourceGETremains a strict superset of collection list items. - For hoisted canonical resources (where
GET /v1/organizations/{organizationId}/projectslists items whose canonical single-resource read lives atGET /v1/projects/{projectId}), the list items MUST remain a strict slice of the hoisted canonicalGET 200schema.
5. Mutation Input Symmetry
Request bodies forPATCH, PUT, and collection POST MUST stay symmetric with canonical C:
- Type and name symmetry: Every request body property whose name matches a property on
CMUST use a compatible (equal or narrower) type, checked recursively through nested objects and arrays. Fields MUST NOT silently change type between write and read (for example accepting an integer onPATCHwhile returning a string onGET). - No server-managed or
readOnlyinputs:PATCHandPUTrequest bodies MUST NOT acceptid,createdAt,updatedAt, or any canonical property markedreadOnly: true.- Collection
POSTrequest bodies MUST NOT acceptcreatedAt,updatedAt, or any canonical property markedreadOnly: true. Client-suppliedidon creation is permitted only whenidis writable (not markedreadOnly: true) onC. - Request bodies MUST NOT accept embedded canonical resources or slices as writable inputs (see §7).
- Merge Patch compliance on
PATCH: EveryPATCHrequest body MUST additionally satisfy RFC 7396 JSON Merge Patch rules inADS-0005§6 (no required top-level fields outside an explicit union discriminator, andadditionalProperties: falseorunevaluatedProperties: false). - Non-resource creation inputs: Collection
POSTrequest bodies MAY accept creation-only input fields that are consumed during resource creation and not stored directly onC(for exampletemplateId,initialPlanId, orsendInviteEmail). When the schema carriesx-photon-resource, declare those inputs explicitly innonResourceInputs(see §6).
6. The x-photon-resource OpenAPI Extension
Schemas MAY declare the x-photon-resource OpenAPI vendor extension to make canonical ownership and derived schema roles machine-readable for SDK generation, documentation, and strict static checks.
Canonical form
Attach the canonical form to the authoritative component schemaC:
typeMUST match^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$— lowercasekebab-casedomain and entity separated by a single dot (for exampleprojects.project,projects.api-key,billing.operation).- Every canonical
typeMUST be globally unique within an OpenAPI document. - The canonical object MUST NOT include derived keys (
role,canonical, ornonResourceInputs).
Derived form
Attach the derived form to any slice or mutation schema derived fromC:
roleMUST be one of"slice","create","patch", or"replace".canonicalMUST be a local JSON Pointer (#/components/schemas/<Name>) referring to an existing schema undercomponents.schemasthat declares canonicalx-photon-resource: { type }. Dangling pointers, self-references, and derived-to-derived chains are forbidden.nonResourceInputsis allowed ONLY whenroleis"create". When present, it MUST be a non-empty array of unique property names, each of which MUST exist on the derived schema and MUST NOT exist on the canonical schemaC.
Derived role contract
Each derivedrole enforces a strict contract against its canonical schema C:
7. Sub-Resources: Owned Value Objects, Embedded Resources, and Nested Routes
A resource can relate to a smaller resource or object in one of three ways. Choose the pattern by whether the sub-object has an identity and a lifecycle of its own:7.1 Owned value objects
An owned value object is a 1:1 sub-object owned exclusively by the parent, with no independent identity, endpoint, orx-photon-resource annotation (for example notifications or scheduledPlanChange).
- It MUST be declared inline in
C(directly or through a$refto an unannotated component schema). - When mutable, it MUST be writable in
create,patch, andreplaceinputs with the same shape as onC. - In
PATCHrequest bodies, its fields MUST be recursively optional, it MUST declareadditionalProperties: false(orunevaluatedProperties: false), and it merges recursively perADS-0005§6.
7.2 Embedded canonical resources and slices
A parent MAY embed another resource (for exampleSubscription.plan embedding Plan) or a projection of one (for example PaymentAction.operation embedding OperationSummary) for read convenience. The embedded property:
- MUST reuse the embedded resource’s canonical schema (
x-photon-resource: { type }) or a strictsliceof it (x-photon-resource: { role: "slice", canonical }), never an ad-hoc third shape. - SHOULD sit beside a flat
<resource>Idfield (for exampleplanId) that carries the identifier perADS-0001. - MUST NOT embed unbounded child collections; expose a separate paginated collection endpoint per
ADS-0006instead. - MUST NOT use polymorphic expand unions that return either an identifier string or the object (
string | Plan,string | Plan | null,(string | Plan)[], orstring[] | Plan[]). Always return the embedded object in the same shape and pair it with the flat<resource>Idfield. - MUST remain read-only on parent mutations. Collection
POST,PATCH, andPUTrequest bodies, andcreate,patch, andreplaceschemas, MUST NOT accept an embedded canonical resource orsliceas a writable input, even when the embedded property onCdoes not carryreadOnly: true. This also applies to an embedded resource nested inside an owned value object. - MUST NOT embed a
create,patch, orreplaceinput schema inside a read representation.
$ref, an allOf member, an anyOf or oneOf branch (including a nullable branch), or array items, resolves to a schema that declares canonical x-photon-resource: { type } or x-photon-resource: { role: "slice" }. A sub-object whose schema carries no x-photon-resource annotation is treated as an owned value object, so the embedded-resource rules in this section apply only to annotated targets.
Nested slicing: A parent slice (such as a collection list item) MAY omit an embedded resource or narrow it to a slice whose x-photon-resource.canonical points to the same canonical resource that C embeds. A nested slice MUST NOT substitute a slice of a different canonical resource, even when that slice is structurally a subset (for example narrowing Subscription.plan to an InvoiceSummary that declares only id). When C embeds a polymorphic union of canonical resources (for example Cat | Dog), a nested slice MAY narrow it to slices of any of those members.
7.3 URL-nested independent sub-resources
An independent canonical resource (x-photon-resource: { type }) MAY be mounted under a parent path instead of being embedded in the parent’s representation:
- Collection sub-resources (for example
/v1/projects/{projectId}/api-keyswith a nested or hoisted single-resource/{apiKeyId}route) stay decoupled from the parent’s JSON representation. The parent MUST NOT embed the full collection; clients list it through the paginated collection endpoint. - Singleton sub-resources (for example
/v1/projects/{projectId}/subscription,/v1/subscriptions/{subscriptionId}/usage, or/v1/projects/{projectId}/settings) model a 0..1 or 1:1 sub-resource that warrants its own endpoint because it is heavy or computed, needs independent authorization, or has an independent mutation lifecycle. A singleton’sGETdefines its canonical schemaC, andPATCHorPUTon the same path follow §3 and §5 like any other resource.
x-photon-resource stays URL-agnostic. It declares only type, role, canonical, and nonResourceInputs, with no parent or singleton metadata. Route hierarchy is inferred from the OpenAPI paths and the canonical schemas those routes return.
Examples
Canonical resource with derived slice, create, and patch schemas
Good — one canonicalProject schema anchored to hoisted GET /v1/projects/{projectId}, paired with an explicit slice, a create input declaring nonResourceInputs, an RFC 7396 patch input, and a flat POST 201 one-time secret on CreatedApiKey (ADS-0002 §3):
Per-service Operation canonical resource
Good — each service declares its own canonical Operation schema (billing.operation) on its operations route while preserving the ADS-0004 status invariants and field names (id, type, status, createdAt, updatedAt, completedAt, response, error):
Sub-resources: owned value objects, embedded resources, and nested slices
Good —Subscription embeds the canonical Plan beside a flat planId and owns an inline notifications value object. The list slice narrows plan to PlanSummary, a slice of the same canonical Plan. The patch input changes the plan only through planId, and notifications stays recursively optional:
GET and PATCH share one path and one canonical schema:
patch input that accepts the embedded Plan as a writable object instead of planId:
Subscription.plan to a slice of a different canonical resource. It fails even though InvoiceSummary declares only id, because Subscription.plan embeds Plan:
Non-conformant patterns
Bad — list item with extra list-only property and type drift,PATCH accepting readOnly createdAt and missing additionalProperties: false, PATCH 200 returning a mismatched shape, and invalid x-photon-resource pointers:
Changelog
- 2026-11-28: Approved and published as
ADS-0007, defining the canonical resource model, per-serviceOperationcanonical resources, cross-method response consistency, collection slices, mutation input symmetry, thex-photon-resourceOpenAPI extension, and sub-resource rules for owned value objects, embedded resources and nested slices, and URL-nested collection and singleton sub-resources.
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).