- Status: Approved
- Updated: 2026-11-28
Scope
This standard defines the request parameters, response shape, bounds validation, token opacity, error contract, and ordering guarantees for paginatedGET collection endpoints across Photon public HTTP APIs.
Related concerns are governed by separate standards:
- Resource identifier fields (
id,<resource>Id) and URL path parameter naming ({<resource>Id}) are defined inADS-0001. - Top-level JSON object collection responses (prohibiting bare top-level arrays) are defined in
ADS-0002. - Standard collection
GETsemantics and collection-to-item read symmetry are defined inADS-0005.
Normative Rules
1. Forward opaque token pagination (AIP-158)
PaginatedGET collection endpoints MUST use forward opaque token pagination modeled on Google AIP-158:
- Request query parameters:
pageSize(optionalinteger): maximum number of items to return in the current page.pageToken(optionalstring,minLength: 1): opaque continuation token received asnextPageTokenfrom a previous page response.
- Response field:
nextPageToken(optionalstring,minLength: 1): direct top-level property alongside the collection array (perADS-0002), omitted on the final page.
nextPageTokenMUST be placed directly at the top level of the200 OKJSON response object and MUST NOT be nested inside a wrapper object such aspage,pagination,pageInfo,listMetadata, ormeta.- Pagination contracts MUST be symmetric on
GEToperations: anyGETendpoint declaringpageSize,pageToken, or top-levelnextPageTokenMUST declare all three. - New endpoints MUST NOT use non-standard pagination query parameters (
cursor,limit,offset,page,perPage,per_page,page_size,page_token,pageNumber,page_number,after,before,startingAfter,endingBefore,starting_after,ending_before,nextToken,next_token,continuationToken, orcontinuation_token) or non-standard pagination response fields (nextCursor,prevCursor,previousCursor,prevPageToken,previousPageToken,nextPage,hasMore,hasNextPage,hasPreviousPage,pageInfo,pagination,listMetadata, or theirsnake_caseequivalents). - Ordering direction and sort criteria MUST be expressed through explicit sort query parameters (such as
orderororderBy), not bidirectional cursors (after/before,startingAfter/endingBefore, orprevPageToken).
2. End-of-list termination and partial or empty pages
- When there are no more items to return, the server MUST omit
nextPageTokenfrom the response JSON object. - Responses MUST NOT serialize
"nextPageToken": nullor"nextPageToken": ""to indicate the final page. - In OpenAPI,
nextPageTokenMUST be optional (absent fromrequired), non-nullabletype: string, and declareminLength: 1. - A response MAY return fewer than
pageSizeitems—or0items—while still returning a non-emptynextPageToken(for example, when server-side authorization or filtering removes entries from an internal storage slice). - Clients MUST continue paginating strictly until
nextPageTokenis absent from the response, and MUST NOT terminate early becauseitems.length < pageSizeor because a page array is empty.
3. pageSize bounds, strict validation, and cross-page resizing
pageSizeMUST be an optional, non-nullableintegerquery parameter declaring an explicitminimumof at least1and an explicit reasonablemaximum:100is recommended for standard resource collections.- Up to
200is recommended for high-throughput event or message streams. - OpenAPI schemas MUST NOT omit
minimumormaximum, accept0or negative values, or use unbounded pseudo-maxima (such asMAX_SAFE_INTEGERor values above1000).
- Servers MUST document their default page size (for example
20or50) in thepageSizeparameter description. - Servers MUST reject out-of-range values (
0, negative integers, or integers abovemaximum) and non-integer values with422 Unprocessable Content(RFC 9110 §15.5.21; RFC 9457 Problem Details,VALIDATION_FAILED) rather than silently clamping values or treating0as the default. - Callers MAY change
pageSizeon subsequent requests while passing apageToken; the updatedpageSizeapplies to that request’s page only. Servers MUST NOT bindpageSizeintopageTokenvalidation or reject a validpageTokensolely becausepageSizechanged between pages.
4. Opaque tokens and 400 INVALID_PAGE_TOKEN error contract
pageTokenandnextPageTokenare opaque strings (type: string,minLength: 1, optional, non-nullable). Clients MUST NOT parse, decode, construct, modify, or persist tokens long-term across sessions.- Servers SHOULD bind page tokens to the active filter parameters, sort parameters, and resource scope, and SHOULD protect both token integrity and confidentiality—for example using authenticated encryption or opaque server-side handles—so internal storage keys and query cursors are neither exposed nor forgeable (an HMAC signature alone protects integrity, not confidentiality).
- Malformed, expired, tampered, or filter/sort-mismatched
pageTokenvalues MUST return400 Bad RequestwithContent-Type: application/problem+json(RFC 9457 Problem Details) and error codeINVALID_PAGE_TOKEN.
5. Deterministic ordering, consistency, and exact counts
- Paginated collections MUST define a deterministic total order—such as a primary sort field paired with a unique
idtie-breaker—so items with identical primary sort keys do not shift unpredictably between pages. - Pagination provides best-effort snapshot consistency across concurrent writes; callers that require strict uniqueness across pages SHOULD deduplicate items by their canonical
id(ADS-0001). - Paginated collection responses MUST NOT include expensive inline total-count fields such as
totalortotalCount. When callers need an exact count, expose a dedicated count endpoint such asGET /v1/.../<collection>/countreturning{ "count": 42 }(perADS-0002).
6. Exemptions and deprecation transitions
- Unpaginated collections: Bounded static reference catalogs (such as supported countries, permission scopes, event types, or plan catalogs) and small fixed-cap sub-resources are NOT required to paginate. Unpaginated endpoints simply omit
pageSize,pageToken, andnextPageToken. - Unbounded collections: Collections that grow per tenant, project, organization, or time period MUST implement pagination under this standard.
- Migration transitions: When migrating an existing endpoint from a legacy pagination scheme, legacy query parameters and response properties explicitly marked
deprecated: truein OpenAPI MAY coexist temporarily alongside canonicalpageSize,pageToken, andnextPageTokenuntil removed in a versioned release.
Examples
Canonical paginated collection OpenAPI contract
Good — optionalpageSize (1..100, documented default), optional pageToken (minLength: 1), optional non-nullable top-level nextPageToken (minLength: 1), 400 RFC 9457 Problem Details for INVALID_PAGE_TOKEN, and 422 RFC 9457 Problem Details for invalid query parameters such as an out-of-range pageSize:
Multi-page traversal, cross-page resizing, and final page
Good — first page (pageSize=2), second page resizing pageSize to 50 and returning an empty filtered page that still carries nextPageToken, followed by the final page omitting nextPageToken:
Invalid, expired, or mismatched pageToken (400 INVALID_PAGE_TOKEN)
Good — malformed, expired, tampered, or filter-mismatched pageToken returns 400 Bad Request as RFC 9457 Problem Details:
Dedicated count endpoint and unpaginated static catalog
Good — exact counts use a dedicated/count endpoint instead of inline totalCount, and bounded static reference catalogs omit pagination fields completely:
Backward-compatible migration with deprecated: true
Good — legacy cursor / nextCursor fields marked deprecated: true alongside canonical pageSize, pageToken, and nextPageToken during a migration window:
Non-conformant patterns
Bad — legacy query parameters (limit, offset, cursor, startingAfter), required or unbounded pageSize, minimum: 0, nullable or required nextPageToken, hasMore, inline totalCount, and nested pagination / pageInfo wrappers:
"nextPageToken": null, "nextPageToken": "", hasMore, totalCount, or a nested pageInfo object on the wire:
Changelog
- 2026-11-26: Approved and published as
ADS-0006. - 2026-11-28: Aligned
pageSizevalidation errors in §3 with422 Unprocessable Content(VALIDATION_FAILED) while keeping400 Bad Request(INVALID_PAGE_TOKEN) for invalid page tokens in §4.
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).