- Status: Approved
- Updated: 2026-11-22
Normative Rules
1. Top-level JSON responses MUST be JSON objects
Every2xx JSON response (application/json or application/*+json) MUST have a JSON object at the root.
- Responses MUST NOT return a bare JSON array (
[...]) at the top level, because top-level arrays cannot be extended with pagination cursors or collection metadata without a breaking change. - Responses MUST NOT return a top-level JSON primitive (
"ok",true,42, ornull). 204 No Contentresponses and non-JSON media types (such as binary downloads or plain text) are unaffected by this rule.
2. Single-resource responses MUST be returned directly at the top level
GET, POST, PATCH, PUT, and DELETE responses returning a single resource MUST place the resource’s fields directly at the root object ({ "id": "...", ... }).
- Responses MUST NOT wrap a single resource in a single-key resource envelope (such as
{ "apiKey": { ... } },{ "project": { ... } }, or{ "organization": { ... } }). - Responses MUST NOT wrap a single resource under a generic envelope key (
data,result, orpayload), whether alone or paired with metadata keys such asmeta.
3. Creation responses with one-time secrets MUST remain flat
When aPOST endpoint creates a resource and returns a one-time sensitive value (such as secret, signingSecret, clientSecret, token, or accessToken), the response MUST return the resource directly at the top level with the one-time value as a sibling top-level property.
- Subsequent
GET,PATCH, andDELETEresponses for the same resource omit the one-time secret while keeping every other top-level resource field in the exact same position. - Creation responses MUST NOT split the resource and one-time secret into a two-key wrapper envelope such as
{ "apiKey": { ... }, "secret": "..." }or{ "destination": { ... }, "signingSecret": "..." }.
4. Allowed multi-field and non-resource top-level objects
Top-level JSON objects are NOT restricted to single resources. The following shapes are explicitly allowed:- Collections: Top-level objects wrapping a list array, with or without pagination fields (for example
{ "items": [ ... ], "nextCursor": null }). - Free-form key-value maps: Open dictionary objects with dynamic keys (for example label or attribute maps).
- Scalar utility responses: Objects returning scalar summaries, counts, or links (for example
{ "count": 42 }or{ "url": "https://example.com/..." }). - Multi-entity composite responses: Objects returning two or more peer entities (for example
{ "operation": { ... }, "resource": { ... } }). - Nullable sub-objects with or without sibling metadata: Objects whose sub-object property may be
null(for example{ "subscription": null, "timeZone": "UTC" }).
Examples
Single-resource responses (GET, PATCH)
Good — resource fields returned directly at the top level (GET /v1/projects/{projectId}/api-keys/{apiKeyId}):
data envelope (alone or alongside meta):
Creation responses with one-time secrets (POST)
Good — flat resource at the root with the one-time secret as a sibling top-level field (POST /v1/projects/{projectId}/api-keys):
signingSecret as a sibling field (POST /v1/projects/{projectId}/destinations):
Collections vs. bare arrays
Good — collection wrapped in a top-level JSON object (GET /v1/projects/{projectId}/api-keys):
Allowed composite, nullable-subobject, and utility responses
Good — scalar utility response (GET /v1/organizations/{organizationId}/projects/count):
GET /v1/projects/{projectId}/subscription):
POST /v1/projects/{projectId}/exports):
Changelog
- 2026-11-22: Approved and published as
ADS-0002.
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).