Restep 1 · specification
1. Status and scope
Draft 6, 20 November 2026 (draft 5: 20 November 2026; draft 4, draft 3 and draft 2: 19 November 2026; draft 1: 12 November 2026). It may change without notice until version 1.0 is published. A server that implements it declares "restep": "1.0-draft.6" (1.1).
URI of this version: https://w3id.org/restep/1/, a permanent identifier that redirects to this text at restep.wubytes.com.
Published in English and in Spanish. Where the two differ, the English text prevails; profile and error URIs point to it.
Also as a single Markdown file, for agents and for diffing: spec.md.
Restep is a profile for HTTP APIs that exchange JSON and are organised around resources: level 2 of the Richardson Maturity Model. It settles what that level leaves open (the shape of collections and errors, querying, safe writes, relationships and sync) and splits it into six profiles that are adopted one at a time, plus optional extensions.
Out of scope: authentication and authorization (OAuth 2.0 is recommended, with OpenID Connect where the API needs the user’s identity; the oauth extension says where a client gets a token), each API’s domain design, and anything below HTTP. Restep requires no schema and no code generator: a core server can be written by hand.
1.1 Restep versions
- Restep has a major and a minor version. The major one is in all its URIs (
/1/); the discovery document declares the full one:"restep": "1.0". - A minor version only adds: profiles; extensions; discovery members; values and forms that this text reserves for minor versions; meanings for requests and declarations that this text forbids or reserves; and error codes for new cases (never a new code for a case that already had one). It adds no requirement on what 1.0 defines, so whatever conforms to 1.0 still conforms to 1.1, except in the experimental profiles and extensions (1.2). Adding error codes is safe because clients handle unknown ones by the class of the status (5.4), and adding the rest because clients ignore what they do not know (3, 4.2).
- The value of
restepMUST match this grammar (ABNF, RFC 5234), so numbers carry no leading zeros:
Without a suffix (restep-version = major "." minor [ "-" pre-release ] pre-release = ( "draft" / "rc" ) "." number major = number minor = number number = "0" / ( %x31-39 *DIGIT )"1.0","1.1") it names a published version. With one it names a draft ("1.0-draft.6","1.1-draft.2") or a release candidate ("1.0-rc.1") of the version before the hyphen. A server that implements a draft or a candidate SHOULD declare it this way rather than as the published version. A client of Restep 1 MUST NOT treat as a Restep 1 discovery document one whoserestepdoes not match this grammar or whose major version is not 1, and for one of another major version it MUST NOT fall back to assumingcoreonly either, as 4.2 asks of a client that finds no discovery document: that API is not one it can use as Restep 1. - A draft or a candidate may differ incompatibly from the published version of the same number and from every other draft. A client MUST NOT assume, for a version with a suffix, the guarantees of this section: that it conforms to any published version or to any other draft. A client that does not know that exact draft MAY work with it under the rules of the version without the suffix, except in its experimental parts (1.2), and handles what differs as it handles any error. The examples in this text say
"1.0". - A minor version MUST NOT reserve parameter names beyond those listed in 5.3, except names starting with
$, which are kept for future versions of Restep. - An incompatible change will be Restep 2, with new URIs (
/2/core…). The/1/URIs, underhttps://w3id.org/restep/1/, will never change; if the text moves to another site, only where they redirect changes. - Until 1.0 is published, drafts may change incompatibly.
1.2 Profiles and dependencies
Each profile only adds requirements; none changes the type or meaning of what an earlier one defines, so announcing a new profile never breaks an existing client. Some profiles need others:
| Profile or extension | Requires | Status |
|---|---|---|
core | Nothing; every Restep API implements it | Stable |
query, writes, cache, relations | core | Stable |
sync | core and query (to fetch changed items by id) | Experimental |
actions, oauth | core | Stable |
batch, inherit | core | Experimental |
filter-expr, query-method | query | Experimental |
A server MUST NOT announce a profile or extension without the ones it requires.
Each profile and extension is stable or experimental, as the table says and the heading of its section repeats.
- A stable one follows 1.1: later minor versions only add to it.
- An experimental one MAY change incompatibly in a minor version, until a version declares it stable. This is the only exception to “whatever conforms to 1.0 still conforms to 1.1”. Moving from experimental to stable is itself such a change only if the text changes.
- It is announced like any other, with its name in
profilesorextensions; there is no separate name for its experimental form. A server MUST implement, for everything it announces, experimental parts included, the text of the version it declares inrestep. - A client MUST NOT use an experimental profile or extension unless
restepdeclares a version whose text of it the client implements; for a draft or a candidate, that exact one. So a client written for the experimentalsyncof 1.0 stops using it against a server that declares 1.1, until it learns the text of 1.1, instead of following rules that no longer apply. A client uses an experimental profile or extension when it sends a request that only that part defines, or relies on a rule of it to interpret a response; ignoring its members is not using it.
1.3 Licence and process
- The text of this specification, its JSON Schemas and the Restep tools are published under the MIT licence. The specification’s repository, github.com/restep-spec/spec, holds it in English and Spanish with its JSON Schemas and the reference server. The text is read at
restep.wubytes.com; its identifiers (the URIs of the version, profiles, errors and schemas) live underhttps://w3id.org/restep/, which redirects there. - The licence allows anyone to copy and modify the text; the name is a separate matter. Only what meets section 12, for the profiles and extensions it claims, may be presented as “Restep 1” or as conforming to Restep 1. A modified text must not be presented as Restep or as this specification, though it may say that it is based on Restep 1.
- Questions, proposals and errata are opened as issues in that repository: a requirement that is unclear, two that contradict each other, a case the text does not cover. Pull requests there are welcome as proposals; they are applied at the source, the Restep site, where the specification is written alongside its tools.
- Until 1.0 is published, each change goes into a new draft, and Appendix C lists it. After that, a correction that changes no requirement (a typo, a broken link, an example that contradicts the text it illustrates) is published as an erratum in Appendix C without changing the version; any other change waits for a minor version (1.1).
- Sections 1 to 12 are normative, except their examples and the sentences without the key words of section 2. Section 13 explains risks and cites the requirements that address them; the appendices are not normative.
2. Terms
The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are to be interpreted as described in RFC 2119 and RFC 8174 when, and only when, they appear in all capitals. Every requirement of this specification carries one of them; sentences without them explain or give examples.
- API root: the base URL a client is configured with, such as
https://api.example.com/orhttps://example.com/api/. Paths in this specification, in thepathmembers of discovery and batch and inevents(10), such as/books, are relative to it: underhttps://example.com/api/,/booksmeanshttps://example.com/api/books. Links in bodies and headers are not: they are URI references (RFC 3986) resolved against the request URL. - Collection: a resource grouping items of the same type, such as
/books. - Item: a resource in a collection, such as
/books/7. - Singleton: a resource that is neither a collection nor an item of one, declared on its own in discovery, such as
/me(5.9). - Profile: a named set of requirements (
core,query…) with its own URI, announced inprofiles. A profile changes what a generic client can assume of the whole API: withwrites, every non-idempotentPOSTtakesIdempotency-Key. - Extension: an optional mechanism with a syntax of its own (a method, a path, a parameter form, a header exchange), with its own URI, announced in
extensions. It changes nothing for a client that does not use it. - Reserved parameter: a query parameter whose meaning Restep defines (section 5.3).
- Principal: who a request acts for, as the server authenticates it (in OAuth 2.0, the client and, if there is one, the user). It is not the credential: a request with a renewed token comes from the same principal.
- Capability: something a resource declares in discovery within a profile or extension (a filter, an operator, a sort key, a relationship, an action, a language map, a client-chosen
id). A profile or extension says what a capability means; whether a collection has it is said only by its declaration. - Equal as JSON values: of the same type and, for objects, with the same member names and equal values, whatever their order and whitespace; for arrays, with equal elements in the same order; for numbers, the same decimal number (
1and1.0); for strings, the same sequence of code points once unescaped, without Unicode normalization.
So a new rule goes into a profile when every client of the API may rely on it, into an extension when only a client that uses its syntax meets it, and into a capability when it holds for some collections and not others.
3. Data
- Bodies MUST be JSON (RFC 8259) encoded as UTF-8. The exceptions are responses without a body (
204,304,HEAD), the event stream ofsyncand resources outside Restep (5.9). Their strings MUST NOT contain unpaired surrogates, which JSON can carry only escaped; the server MAY reject a request body with one, or with U+0000, with422 invalidand aformatentry. - A request with a body to a resource of Restep (a
POSTto a collection, an action or a batch; aQUERY) MUST carryContent-Type: application/json; aPATCHfollows 5.1. The server MUST answer415 unsupported_media_typeto any other media type, and to a body withoutContent-Type. An empty body is a body: withoutContent-Typeit MUST give415, which here prevails over the400that its emptiness would also allow (5.4), and withapplication/jsonit MUST give400 bad_request. The one exception is an empty body to an action (11.1). This matters most with cookies: a browser sendstext/plain,application/x-www-form-urlencodedandmultipart/form-datafrom any origin without a CORS preflight (5.8), so a server that read one of them as JSON would accept writes that the preflight exists to stop.- The media type is compared case-insensitively, as RFC 9110 says.
application/jsondefines no parameters (RFC 8259): the server MUST acceptcharset=utf-8, in any case and quoted or not, MUST answer415to any othercharset, and MUST ignore other parameters. - A
2xxresponse with a body MUST carryContent-Type: application/json, except the event stream (text/event-stream), a JSON Schema, which MAY useapplication/schema+json, and the service status, which MAY useapplication/health+json(4.4). Errors useapplication/problem+json(5.4) whateverAcceptsays: the server MUST NOT answer406only becauseAcceptdoes not listapplication/problem+json.
- The media type is compared case-insensitively, as RFC 9110 says.
- Field names defined by Restep are
snake_case. Each API chooses its own, but SHOULD stick to one convention. - A name that an API gives and that discovery declares or a parameter carries (the key of a collection, a singleton, an action, a relationship, a named filter or a reason, and a field that discovery declares or that
filter,sort,fields,includeorfilter-exprnames) MUST match this grammar (ABNF, RFC 5234):
It fitsname = ALPHA *63( ALPHA / DIGIT / "_" / "-" )snake_caseandcamelCase, and is case-sensitive. It never holds.,,,[,],:or a space, which parameters and paths use to separate dotted paths, lists, operators and actions, and never starts with-, which marks a descending sort (6.2). A dotted path (author.id) is names joined by., except that its last segment can be a language tag (name.es-mx, 6.1). A field whose name does not match MAY appear in representations, but the server MUST NOT declare it in discovery, and a parameter that names it gets the error for a field that does not exist or is not declared. An API need not rename fields that it never declares and that no parameter names. - Member names starting with
_are reserved for Restep (such as_actions,_etag). An API MUST NOT define fields with that prefix, except those starting with_x_. - Member names starting with
_x_are left to extensions outside Restep, which never defines one. They are annotations of the server, like Restep’s own_members: a write ignores them (5.1),fieldskeeps them (6.3), and clients MUST ignore those they do not know. Their values MUST NOT change between two reads of the same version of an item, since they count towards itsETag(7.2). Their names SHOULD carry the extension’s or the organisation’s name after the prefix (_x_acme_audit), so two extensions do not collide. What an extension needs a client to write goes in ordinary fields. - An item’s identifier is called
id. It MUST be a non-empty string made only of RFC 3986 unreserved characters (A–Z a–z 0–9 - . _ ~), so it can go into a path without escaping, and MUST NOT be.or.., which URI resolution would remove. It MUST NOT change. Twoids are the same only when they are the same sequence of code points: the server MUST NOT treatabcas taken byABC, nor serve an item at a path whose last segment is not itsid, such as item7at/books/07. The server MUST compare each segment of a path after percent-decoding it, so/books/%37is/books/7. - A field whose values may fall outside ±(253−1), or that needs exact decimal arithmetic (amounts of money), MUST be a string in every representation, whatever the value:
"price": "18.50". An amount of money SHOULD come with its ISO 4217 currency. - Instants MUST follow RFC 3339
date-timewith an offset:"2026-11-12T09:30:00Z". Calendar dates MUST usefull-date:"1987-03-14". Durations SHOULD be ISO 8601 ("PT90S"); a field holding seconds as a number SHOULD end in_seconds. - Absent and
nullare different. On reads, a field with no value MAY be omitted or set tonull, except a language map, which is{}; in aPATCH,nulldeletes and absent leaves untouched (RFC 7396). - A relationship, when a representation includes one, MUST be an object with at least
id(to-one), a list of such objects (to-many),null(an empty to-one) or[](an empty to-many). Never a bare identifier, so the field’s type does not change when the related item is included (section 9). When a relationship can point to more than one collection, each object MUST also carrytypewith the target collection’s name. An object MAY carryhref, the related item’s path as an absolute link (below), and MUST carry it when the target collection is a subcollection, whose item paths cannot be built fromidalone (section 9). - Links in bodies (
next,href) MUST be absolute URIs or absolute paths, starting with/and including the API root’s path (/api/books?cursor=…), so a colon inside a segment (/orders/2001:cancel) is never read as a scheme, as it would be in the relative reference2001:cancel. An absolute URI among these links, among the links of the discovery document, and in theLocationandLinkheaders of the API’s responses, MUST usehttpsor the scheme of the API root; a client MUST NOT dereference one with another scheme, such asfile:ordata:. - Clients MUST ignore fields they do not know and tolerate new enum values, also those that their stored copy of discovery or of a schema does not list: a client MUST NOT reject a response because of such a value, and MAY warn about it. Before sending one, a client MAY check its own input against what it has stored.
- Successful (
2xx) responses of collections, items and actions MUST NOT depend onAccept-Language, and do not needVary: Accept-Language. Numbers, amounts, dates, instants and durations always take the forms of this section; presenting them in a language is the client’s job. Only the API’s own texts change with the language (5.6). - A language map holds the same text in several languages: a JSON object whose keys are language tags (RFC 5646) and whose values are strings. Only top-level fields of an item can be language maps. Restep says nothing about the language of text fields that are not.
"name": { "en": "Zucchini", "en-gb": "Courgette", "es-es": "Calabacín", "es-mx": "Calabacita" }- Each key MUST be a well-formed tag (the grammar of RFC 5646, section 2.1; it need not be in the registry) in lowercase. The server MUST NOT change a key (
iwdoes not becomehe). A value can be any string,""included. - A language map’s type MUST NOT change: it is an object with one translation or none, even if the API speaks one language. A map with no translations MUST be given as
{}, not absent ornull, unless the representation leaves the field out (throughfieldsor permissions). The server MUST NOT fill a missing translation with another language’s text: the client picks what to show from the keys it gets. - In a
POST, a language map is an object of strings. In aPATCHit merges like any object (RFC 7396):{"name": {"fr": "Courgette"}}adds or changes French and leaves the rest,{"name": {"fr": null}}deletes it, and deleting a key that is not there does nothing. After merging, a missing language map is{}, so{"name": null}empties it. A declaredupdateschema (4.3) MUST acceptnullfor the field and for any well-formed lowercase key. - The server MUST validate the body before merging, including the keys it deletes, and MUST answer
422 invalidwith oneerrorsentry per failure, with apointerto what fails and thiscode:typeif the field is not an object or a value is not a string (in aPATCH,nullis valid in both places; in aPOSTit is not);formatif a key is not a well-formed lowercase tag (/name/ES);unknownif a translation is added, or given a value other than the stored one, under a well-formed tag the API does not accept.
- Each key MUST be a well-formed tag (the grammar of RFC 5646, section 2.1; it need not be in the registry) in lowercase. The server MUST NOT change a key (
4. Announcing Restep
4.1 Profile header
Every API response SHOULD carry one rel="profile" link (RFC 6906) to the version URI, and only that one, so the header has the same size whatever the server announces:
Link: <https://w3id.org/restep/1/>; rel="profile"
Which profiles and extensions the server implements is said only by the discovery document (4.2). Each one still has its own URI, the version URI followed by its name (https://w3id.org/restep/1/query), which names it in a problem or a document, but a server SHOULD NOT list them in the headers of every response.
Profiles apply to the whole API; some of their rules hold only where a collection declares them (filter, sync…). Which collection supports what is said only by the declarations in the discovery document.
4.2 Discovery document
A GET on the API root returns a document stating the server’s profiles, extensions and capabilities. A core-only server SHOULD serve it; a server that announces any other profile or extension, or has language maps (3), MUST serve it. A server whose root is taken MAY serve it elsewhere and point to it from its responses with Link: <…>; rel="service-desc" (RFC 8631). A response MAY carry several service-desc links, such as one to an OpenAPI document; the one to the discovery document SHOULD carry type="application/json", and clients MUST use the first target that is a discovery document.
Clients MUST treat a response as a discovery document only if it is a JSON object with a string member restep. Without one, clients MUST assume core only. If a Link header lists profiles and disagrees with the document, the document prevails.
One document for everyone. The discovery document describes the API, not what a principal may do with it:
- Its content MUST NOT depend on the principal (2) or on whether the request carries credentials; only its texts change, with
Accept-Language(5.6). Two documents served under the sameAccept-LanguageMUST be equal as JSON values (2). So two principals get the same document, and a copy kept with a client’s code can be compared with the next one. Everything it declares is visible to whoever can read it (13.12). An API whose collections, fields or capabilities differ by tenant gives each tenant its own API root, with its own discovery document. - The server MAY require credentials to serve it, answering
401without them or403to a principal that may not read it; whoever it serves it to gets the same document. Its response then depends on credentials (5.1) and MUST carryCache-Controlwithprivateorno-store; only a document served without credentials MAY bepublicand kept by a shared cache. - Its response SHOULD carry an
ETagand aCache-Controlwith amax-age. A client MAY keep it for as long as thatCache-Controlallows, and SHOULD revalidate it after that. A client that getsunsupported_parameter(5.3) or405for something its copy declares SHOULD fetch the document again before concluding that the capability is gone. - What a principal may not do is said by the response to the request, never by leaving it out of discovery. A declared method, action or singleton that this principal may not use MUST give
403 forbidden, or404 not_foundwhere its existence is concealed (5.4), never405orunsupported_parameter. For filters, sorting andfieldson a field the principal cannot read, see 6.1.
{ "restep": "1.0",
"version": "1",
"profiles": ["core", "query", "writes", "relations", "sync"],
"extensions": ["actions", "batch"],
"batch": { "path": "/batch", "max_operations": 20 },
"idempotency": { "ttl": 86400 },
"events": "/events",
"collections": {
"books": {
"path": "/books",
"description": "Books in the catalogue, one per edition.",
"methods": ["GET", "POST"],
"item_methods": ["GET", "PATCH", "DELETE"],
"schemas": { "create": "/schemas/book-create.json", "update": "/schemas/book-update.json" },
"filter": {
"id": { "type": "string", "ops": ["eq", "in"] },
"price": { "type": "decimal", "ops": ["eq", "lt", "le", "gt", "ge"] },
"rating": { "type": "number", "ops": ["ge", "null"] },
"category": { "type": "enum", "values": ["novela-negra", "poesia"], "ops": ["eq", "in"] },
"author.id": { "type": "string", "ops": ["eq", "in"] } },
"named_filters": {
"available": { "description": "Has at least one copy free to reserve now." },
"search": { "type": "string", "description": "Title, author or ISBN contains the text, case-insensitively." } },
"sort": ["id", "price", "rating", "title"],
"collations": { "title": "server" },
"max_limit": 50,
"count": "estimated",
"relations": {
"author": { "to": "authors", "include": true },
"reviews": { "to": "reviews", "many": true, "path": "/books/{book_id}/reviews" } },
"include_depth": 2,
"sync": { "retention": 604800 },
"actions": { "reserve": { "on": "item", "safe": false, "idempotent": true,
"description": "Holds a copy for the user for 48 hours.", "input": "/schemas/reserve.json" } } },
"reviews": { "path": "/books/{book_id}/reviews", "parent": "books", "id_from": "either",
"sort": ["id", "created_at"], "max_limit": 50 } },
"singletons": {
"me": { "path": "/me", "methods": ["GET", "PATCH"], "description": "The signed-in user’s profile and settings." } } }
An API SHOULD link its documentation for people with Link: <…>; rel="service-doc" (RFC 8631) in the response that serves its discovery document or, if it serves none, in the response to a GET on the API root, with the API root as anchor (RFC 8288) if that response is an error. A response MAY carry several, and each MAY state the languages of its target with hreflang; a client picks among them by hreflang, so the server need not choose them by Accept-Language. That documentation explains what discovery cannot say, such as business rules, the permissions each operation needs, usage limits and examples. Where it contradicts discovery, discovery prevails.
Link: <https://docs.example.com/api/>; rel="service-doc"; hreflang="es",
<https://docs.example.com/en/api/>; rel="service-doc"; hreflang="en"
- Each profile adds its own fields to the document, described in its section. Every object that this text defines in the document belongs to Restep: the root, each collection and each singleton,
schemas,batch,idempotency,sync, and each filter, named filter, relation, action, deprecation, language map, reason and inheritance object. A later minor version can add members to any of them, so a server MAY add its own members to any of them, and every member it adds that this text does not define MUST start withx-; clients ignore the members they do not know (below). This does not apply to the names the API gives its collections, singletons, fields, relations, actions and reasons, which are keys ofcollections,singletons,filter,named_filters,relations,actions,language_maps,collations,reasonsandinherit, and follow the grammar of names (3). - Clients MUST ignore members they do not know in the discovery document and in every object in it. Where a member that Restep defines has a value the client does not know (a filter’s
type, an action’sonormethod, a deprecation’skind, a value reserved for minor versions), the client MUST NOT fail because of it and MUST NOT use what that value qualifies: it treats that filter, action or notice as if it were not declared, unless this text gives another rule for that member (id_fromin 5.1, singletons in 5.9,collationsin 6.1,fromin 11.6). language_maps: the fields of a collection that are language maps (3), as an object whose keys are the field names:"language_maps": {"name": {}, "description": {}}. It MUST list all of them; if it is missing, the collection has none. The object of each field is left for minor versions.- A collection’s
pathMAY be a URI template (RFC 6570); subcollections are declared that way. Its variables MUST be simple strings ({name}) with distinct names, so/authors/{author_id}/books/{book_id}/reviews, not{id}twice; they take in order theids of the parent items (5.1). Such a collection MUST name inparentthe collection whose items it hangs from, and itspathMUST start with that collection’spathfollowed by/and its last variable:"reviews": {"path": "/books/{book_id}/reviews", "parent": "books"}. id_from(5.1) andcollations(6.1) are capabilities of a collection;singletonslists the API’s singletons (5.9).- Field types, where discovery declares them, come from this list:
string,integer,number,decimal(a string matching-?[0-9]+(\.[0-9]+)?),boolean,date,datetime,durationandenum(with itsvalues). Discovery only declares types where Restep needs them, such as filters; the shape of whole representations and request bodies goes in the schemas of 4.3. A representation MAY also link its schema withrel="describedby". - An origin that lists its APIs in
/.well-known/api-catalog(RFC 9727) MAY include a Restep API there, with the API root asanchor, aservice-desclink to its discovery document and, if there are any, itsservice-doclinks.
4.3 Describing operations
Optional members that let a client, a person reading the document or an agent picking a tool, know what each collection does and accepts without trying it. A server MAY declare any of them on any collection; Restep requires none, so a core server can still be written by hand.
methodsanditem_methods: the methods a collection and its items support, out ofGET,POST,PATCHandDELETE(HEADgoes withGET; actions andQUERYare announced on their own). A missing list means unknown, not all. A declared list MUST be exact: a method left out gives405, unless an error that comes first in 5.4 applies, a listed one never does, and theAllowheader of a405MUST list every declared method and no other of those four.description: a short plain-text explanation of a collection, a singleton, a filter field, a relationship, an action, an inherited field (11.6) or a reason (5.4). It SHOULD be one sentence.schemas: JSON Schemas (2020-12) of a collection’sitem(its representation withoutfieldsorinclude),create(the body of aPOST) andupdate(the body of aPATCH: a merge patch, where absent leaves a field untouched andnulldeletes it). Each is a schema object or a link to one, absolute as links in bodies are (3). Schemas can describe each field with its owndescription.- A
defaultin a top-level property ofcreateis the value the field takes when aPOSTleaves it out, and the server MUST give it that value; a field sent asnullis not left out. Inupdateadefaultmeans nothing, because a field absent from aPATCHstays as it is. - A client can build a form for people from these schemas (Appendix A). It shows fields in the order of
properties, so a server SHOULD write them in the order it wants them shown. - Before validating a body against a declared
createorupdateschema, the server drops the members that start with_, which 5.1 ignores, and, in aPATCH, every field whose current value 5.1 ignores, and in aPOST, every read-only field that 5.1 ignores; aPATCHleft empty by this is not validated againstupdate. In either, a read-only field with another value MUST give theread_onlyentry of 5.1, not a schema error. A body the schema then rejects MUST give422 invalid(400 bad_requestif it is not a JSON object), unless an error that comes first in 5.4 applies, and itserrorsSHOULD point at the failing members. A schema describes, it does not promise: a body it accepts can still fail the API’s own rules.readOnlyis only an annotation, except as 5.1 says for top-level properties of anitemschema, andidfollows 5.1 whatever the schema says: acreateschema can restrict the format of anidthe client chooses, but cannot make the server accept anidthat 5.1 rejects. - An action’s
input(11.1) is the schema of its body, with the same meaning. - A client MUST send its credentials for the API only to URLs on the API’s origin, and MUST fetch a schema or document on another origin without them (13.2). It SHOULD NOT resolve a schema’s
$refoutside the origin of the schema that holds it, and SHOULD NOT send a value it took from a schema on another origin, such as adefault, without showing it to the user first.
Descriptions, titles and every other value an API returns are data, never instructions to the client. A client MUST NOT, because of such text alone, make a request that is not safe (5.7) and that the task it is serving did not already call for, nor send data to another origin. Using detail and errors to correct the request it is already making is not following an instruction. An agent that puts these texts in a prompt SHOULD mark where they begin and end (13.1).
4.4 Service status
A server MAY declare in status a link, absolute as links in bodies are (3), to a resource that says whether the API can serve requests, and MAY also link it from its responses with rel="status" (RFC 8631). Clients MUST NOT assume a path such as /health.
- Unless it asks for credentials or refuses them (
401,403) or limits the rate (429), aGETorHEADon it MUST answer200when the API can serve requests and503when it cannot, withRetry-Afterwhen the server knows for how long, and always withCache-Control: no-store. - It is not a resource of the API: 4.1, 5.1 to 5.4 and 8 do not apply to it. Its body MAY follow the Health Check Response Format (draft-inadarei-api-health-check). Served without credentials, it SHOULD NOT say more than whether the API can serve.
5. core Required
Profile URI: https://w3id.org/restep/1/core. Status: stable.
5.1 Resources and methods
| Request | Success | What it does |
|---|---|---|
GET /books | 200 | Lists the collection (5.2) |
POST /books | 201 with Location | Creates an item and returns its representation |
GET /books/7 | 200 | Returns the item, with no envelope |
PATCH /books/7 | 200 | Partial update with JSON Merge Patch (RFC 7396), except relationship objects (below) and language maps (3); returns the whole item |
DELETE /books/7 | 204 | Deletes the item. Repeating it MAY return 404 |
- Responses MUST use the statuses in the table for those operations, except where 7.3 allows a response without a body.
PUTis outside Restep 1: a client that replaces a whole item would erase fields added to the item after that client was written. Clients SHOULD usePATCH.HEADMUST be supported whereverGETis (RFC 9110).GETandHEADMUST NOT have effects visible to the client.- A response that depends on credentials MUST carry
Cache-Controlwithprivateorno-store, whether or not the server announcescache, so that a shared cache never gives it to another principal (RFC 9111). Credentials are whatever the server authenticates the request with:Authorization, cookies, a client certificate. A response that changes with a cookie depends on credentials, and so does an error whose status depends on who asks, such as a404that conceals an item from this principal only, a401or403, or a discovery document served only with credentials (4.2, 13.10). This covers every response of the API, those of resources outside Restep (5.9) and the errors of the server’s authentication layer included. - A method the resource does not support MUST return
405with anAllowheader.OPTIONSis outside Restep: servers MAY answer it for CORS (5.8). PATCHMUST acceptapplication/merge-patch+jsonand SHOULD also acceptapplication/jsonwith the same meaning. Any other media type, or none, MUST give415, andcharsetfollows 3. A415to aPATCHSHOULD carryAccept-Patch(RFC 5789). A patch that is not a JSON object MUST give400 bad_request.- An item’s path MUST be its collection’s path, with any URI template expanded (RFC 6570), its variables taking in order the
ids of the parent items, and without a trailing/, followed by/and the item’s ownid:/books/7,/books/7/reviews/3. - Who chooses an item’s
idis a capability of its collection, declared inid_from:- Missing or
"server": the server MUST assignid, and MUST give422 invalid, with aread_onlyentry at/id, to aPOSTthat carries one. "client": aPOSTMUST carryid; without it, the server MUST give422 invalidwith arequiredentry at/id."either": aPOSTMAY carryid; without it, the server assigns one.- Other values are reserved for minor versions. A client that finds one it does not know MUST NOT send
idin aPOSTto that collection.
idnever changes: aPATCHthat carries a different one MUST give422 invalidwith aread_onlyentry, as below. For anidthe client chooses:- It follows 3. One that does not (not a string, empty, with other characters,
.or..) MUST give422 invalidwith atypeorformatentry at/id. The server MAY restrict its format further, and then SHOULD say how in thecreateschema (4.3); a well-formedidoutside that format gets the same422withformat. The server SHOULD require a format with enough entropy that clients do not collide by chance, such as a UUID or a ULID; where it conceals from some principals the existence of items of that collection (5.4), it MUST require a format that cannot be guessed, such as a version 4 UUID, because the409below tells whether anidis in use. A client SHOULD generate such anidfrom a random source and SHOULD NOT derive it from the item’s data (an email, a name), since whoever can guess it can take it first or learn from the409below that it exists (13.6). - An
idthat an item of the same collection (for a subcollection, under the same parent item) has or has had MUST give409 conflictwith anerrorsentry whosepointeris/idand whosecodeistaken. That response MUST be the same whether or not the client can see the item that holds theid, or could see the one that held it. The server MUST know theseids for as long as the collection exists; a subcollection exists as long as its parent item does. A server that reuses theidof a deleted parent item, which the next point advises against, MUST NOT let the new parent’s subcollection take anidthat the old one had. It MAY keep only a one-way hash of theids of deleted items. - So a client never gets back the
idof a deleted item: withsync, it could not tell the new item from the old one coming back. For the same reason, the server SHOULD NOT reuse in a collection theids it assigns itself. - So a
POSTwith anidchosen by the client never creates two items. A client that repeats it and gets409withtakenreads the item to learn whether its first attempt took effect (5.7); withwrites,Idempotency-Keyworks as for anyPOSTand returns the stored response instead (7.1).
- Missing or
- In a write, the server MUST ignore members whose names start with
_, so a client can send back a representation it read. - A read-only field is one no client can change with a
PATCH:id, an effective field (11.6), one only the server sets (created_at, a total), or a top-level property that theitemschema marks"readOnly": truedirectly in itsproperties(4.3); a server MUST NOT mark so a property that some client or some state of the item lets change with aPATCH. A value in aPATCHis current when it equals the field’s value as read under the field’s type (the same decimal, the same instant), or when applying it as this section says (a relationship by itsid, a language map by key) leaves the field as it was before thePATCH. If aPATCHcarries a read-only field with its current value, the server MUST ignore it; with another value, it MUST respond422 invalidwith aread_onlyentry whosepointeris the field, and MUST NOT apply any of that request. A field that this client, or the item’s current state, does not let it change follows the first half of that rule: its current value MUST be ignored, and another value MUST give403 forbiddenif this principal may not change it, or409 conflictif the item’s state does not allow it, without applying any of that request; either SHOULD carry anerrorsentry whosepointeris the field. For a field the client is allowed to read, the server compares after validating a language map as 3 says. For a field it cannot read, neither the rules above nor the checks of 3 that look at the stored value apply: the server MAY validate the value sent (a write-only field, such as a password, is validated as any other), but its answer MUST NOT depend on the stored value. - In a
POST, a read-only field other thanid(whose rules are above) MUST be ignored if its value is the one the item would get, and otherwise MUST give422 invalidwith aread_onlyentry whosepointeris the field. The case is a representation that was read and is sent back; a client that does not know that value, such as acreated_atthe server sets, leaves the field out. - A valid
PATCHthat, setting aside the fields it ignores, would change no data of the item MUST NOT change it: its representation and itsETag, if any, stay the same, and a field such asupdated_atdoes not move. So the read-only fields of a representation that was read never make aPATCHfail or change anything, if the item has not changed since. - In a write, a relationship object is replaced whole, not merged: the server MUST read only its
id(andtype, andhrefwhen its target is a subcollection) and MUST NOT change the related item through it. To link an item of a subcollection the client MUST send itshref, as read; anhrefthat is not the path of an item of the target collection, or whose last segment is not theidsent, MUST give422 invalid. A relationship to an item that does not exist, or that the principal cannot see, MUST give422 invalidwith an entry whosepointeris the relationship’sid(/author/id) and whosecodeisunknown, the same in both cases. A relationship whose value is current (it leaves the field as it was) is not checked this way: the server MUST ignore it, so sending back a representation as read never fails because of it.{"author": {"id": "4"}}links another author;{"author": null}unlinks it. A to-many list is replaced whole, as Merge Patch does with any array.
5.2 Collections
A collection MUST respond with an object holding items (a list) and next: the URL of the next page, or null when there are no more. next MUST always be present, even if the server does not paginate yet.
{ "items": [ { "id": "7", "title": "La niebla de Portugalete" } ],
"next": null }
- Clients MUST follow
nextas is, without changing or building it, except for the parameters 6.4 lets them change between pages. Encoding it again does not count as changing it: the server MUST read parameters after percent-decoding, sofilter[price]andfilter%5Bprice%5D, or%5band%5B, are the same, and MUST NOT depend on the order of parameters with different names. The server MUST read a+in the query as a space, as HTML forms and most HTTP frameworks do, and MUST write a literal+as%2Bin the links it builds; a client MUST send a literal+as%2B. Wherever this text says “after percent-decoding” of the query, a+is a space. - A collection MUST have a deterministic default order. When that order, or a sort (6.2), uses
id, it is the server’s order of itsids: total and stable, but not necessarily by code points (with numericids,"7"may go before"12"). Clients MUST NOT assume any order ofids. Without concurrent writes, followingnextuntilnullMUST return every item exactly once. With concurrent writes, items may be repeated or missed; a client that needs an exact copy usessync. - The server picks the page size. Without the
queryprofile, clients cannot change it. - The object MAY carry other fields defined by profiles (
total,state).
5.3 Reserved parameters: fail loudly
These parameter names, with or without brackets, belong to Restep: filter, sort, fields, include, count, limit, cursor, since and languages (unused in Restep 1), plus any name starting with $.
The forms Restep defines are name=value and, for filter, filter[field] and filter[field][op]. Any other bracketed form (filter[a][b][c], filter[], fields[]) is a form the resource does not support.
Unless an error that comes first in 5.4 applies, when a request uses a reserved parameter, or a form of one, that the resource does not implement for that method, the server MUST respond 400 with the code unsupported_parameter and the parameter name, exactly as received after percent-decoding, in parameter. It MUST NOT ignore it.
This is the rule that lets a server climb a step without breaking anyone: a client filtering against a server that cannot filter gets a clear error instead of the whole collection, as if the filter had been applied. Non-reserved parameters belong to each API, and Restep says nothing about them.
The two parameter codes tell a client whether to change the request or give up on the capability:
unsupported_parameterMUST be used when the request asks for something the resource does not offer: a reserved parameter it does not implement, a parameter form it does not support (filter=…withoutfilter-expr,sort[…]), a filter field or operator, sort key or relationship that is not declared,countwith any value on a collection that does not declare it (6.5), orfieldsorincludeon a method other thanGET,HEADandQUERY(6.3). It applies to every method:POST /books?filter[x]=1gives it too.invalid_parameterMUST be used when a supported capability gets a wrong value: a value that does not match the field’s type, alimitout of range, a field infieldsthat does not exist, an empty list, a repeated parameter, a bad cursor. Likeunsupported_parameter, it MUST carry inparameterthe name of the parameter at fault, exactly as received after percent-decoding; for a missing one, its name; in the body of aQUERY(11.4), the name of the equivalentGETparameter, such asfilter[price][le], or the member’s own name when there is none. With several at fault,parameternames one of them, anderrorsMAY list each with itsparameter. A server whose framework keeps only one value of a repeated parameter MUST still detect the repetition, reading the query string itself if it has to.- Some limits are declared:
max_limit(6.4),include_depth(9) andbatch.max_operations(11.2). A server MAY also limit, without declaring it, how much a request asks of a supported capability: the values of aninlist, the number of filters, the size of afilter-exprexpression. A request over such a limit MUST giveinvalid_parameternaming the parameter, whosedetailSHOULD state the limit; the server MUST NOT apply only part of it, nor answerunsupported_parameter, since the capability exists. A URL longer than the server accepts MUST give414, a body larger than it accepts413, and too many requests or open streams429(13.8).
5.4 Errors
Every 4xx or 5xx response the API generates MUST use application/problem+json (RFC 9457) when it has a body, with type, title, status (equal to the response’s) and a code. It SHOULD carry detail, saying, where it can, how to fix the request (the accepted values, the allowed range), and MAY carry instance and its own members. An error MUST NOT be sent as a 200 response; the only place an error goes inside a 200 is a per-operation result of batch.
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
{ "type": "https://w3id.org/restep/1/errors#invalid",
"title": "Invalid data",
"status": 422,
"code": "invalid",
"errors": [ { "pointer": "/price", "code": "required", "detail": "price is required." } ] }
codeMUST come from the table below. For a status the table does not list,codeMUST be that status’s description in the IANA HTTP Status Code Registry, insnake_case(502→bad_gateway,431→request_header_fields_too_large), orhttp_followed by the number for an unregistered status.typeSHOULD behttps://w3id.org/restep/1/errors#followed by the code, or a URI of the API’s own that documents the case. It MAY beabout:blank.- For errors of the API’s domain (insufficient funds, out of stock) the response MAY add
reason: a string defined by the API and stable within a version, which MUST follow the grammar of names (3) and SHOULD besnake_case.codekeeps the class (conflict,invalid), so a generic client still knows what to do. - The API MAY declare its reasons in discovery, in
reasonsat the root: an object whose keys are the values ofreason; each value carries thecodethat reason comes with and MAY carry adescription(4.3):"reasons": {"out_of_stock": {"code": "conflict", "description": "No copies left to reserve."}}. If declared, it MUST be complete: a problem MUST NOT carry areasonthat is not in it, nor carry it with anothercode. This applies to the top-levelreasonof every problem, also those inbatchresults, and not to the API’s own codes insideerrors. Ifreasonsis missing, which reasons exist is unknown. A client MUST handle areasonit does not know as it handles itscode, so adding a reason never breaks it. - Validation errors SHOULD list the problems in
errors. Each entry has apointer(a JSON Pointer, RFC 6901, into the request body; Restep uses the plain string form, not the URI fragment), or aparameterorheadername, plus acode:required,type,format,range,too_long,unknown,read_only,taken(anidalready used, 5.1), or one of the API’s own. - A
401MUST carryWWW-Authenticate(RFC 9110). - Clients MUST handle a
codethey do not know according to the class of thestatus. - A problem, its
detailand itserrorsentries included, MUST NOT reveal what the principal could not otherwise learn: values it cannot read, or whether a concealed resource exists, except that anidis taken (5.1). It SHOULD NOT carry internal details, such as stack traces, queries or the names of internal services (13.12). - When more than one of these errors applies to a request, the server MUST report one of the earliest step that applies, in this order:
401, then403;404, then410;405;400for a parameter or a header:unsupported_parameterandinvalid_parameter, which are not ordered between themselves, before the codes of a header (bad_request,idempotency_key_required);- any one of
400for the body,415,406and413, which are not ordered among themselves, except that an empty body withoutContent-Typegives415(3); - a replay or a
409 request_in_progress(7.1); 428, then412, then422or the403for a field that this principal may not change (5.1), then409 conflict, including the one for a field that the item’s state does not let change.
403that does not depend on the body or on the stored item. Other codes that share a status are not ordered. The order also decides between errors that other sections require (4.3, 5.3, 10, 11). Before giving an error, the server MUST rule out those of earlier steps that it can check. A413, or any other error, given by an HTTP server or an intermediary placed in front of the API before the request reaches it is outside this order. Whether conditional headers are evaluated at all follows RFC 9110 (section 13.2.1); when they are, this order prevails over the point at which RFC 9110 (section 13.2.2) evaluates them, so a body that is not JSON gives400before a failed precondition. The order says nothing about statuses it does not list, such as414,424,429and5xx. When the API does not reveal whether a resource exists, the server MUST give404for it, not403; a retired resource MUST give410, not404, unless its existence is concealed.
code | Status | When | Profile |
|---|---|---|---|
bad_request | 400 | The body is not JSON or does not have the expected shape; a malformed or refused header | core |
invalid_parameter | 400 | A supported parameter has a wrong value (5.3) | core |
unsupported_parameter | 400 | The resource does not offer what the parameter asks for (5.3) | core |
idempotency_key_required | 400 | The resource requires Idempotency-Key and it is missing | writes |
unauthenticated | 401 | Missing or invalid credentials; sent with WWW-Authenticate | core |
forbidden | 403 | Valid credentials without permission for this, where the client may know the resource exists | core |
not_found | 404 | The resource does not exist, or its existence is not to be revealed | core |
method_not_allowed | 405 | The resource does not support that method; sent with Allow | core |
not_acceptable | 406 | The server cannot produce any type in Accept | core |
conflict | 409 | Clashes with the current state: a duplicate (such as an id already used, 5.1), an impossible transition, an action not available in the item’s state (11.1) | core |
request_in_progress | 409 | The same request as one still running under the same Idempotency-Key (7.1); SHOULD come with Retry-After | writes |
state_expired | 410 | The server can no longer compute changes since that state | sync |
retired | 410 | A resource or action removed after its Sunset date (5.5) | core |
precondition_failed | 412 | A precondition (If-Match, If-None-Match) of a write failed: the resource changed since the client read it, or If-None-Match matched it | writes |
content_too_large | 413 | The body is too large, or a batch exceeds max_operations | core |
uri_too_long | 414 | The URL is too long (see query-method) | core |
unsupported_media_type | 415 | Content type not supported, or missing on a body (3) | core |
invalid | 422 | The body is understood but not valid; details in errors | core |
idempotency_mismatch | 422 | The same Idempotency-Key with a different request | writes |
not_executed | 424 | A batch operation that left no effect because another one failed | batch |
precondition_required | 428 | The resource requires If-Match to write | writes |
rate_limited | 429 | Too many requests; SHOULD come with Retry-After | core |
internal | 500 | Server failure | core |
not_implemented | 501 | The server does not know the method (such as QUERY) | core |
unavailable | 503 | Temporarily unavailable; SHOULD come with Retry-After | core |
5.5 Evolution and versions
A Restep API evolves without versions as long as changes are compatible, and only creates a major version when there is no other way.
Compatible changes. A server MAY make them at any time: adding fields to a representation; adding optional parameters, collections, singletons, actions or enum values; supporting new filters, sorts or includes; adding profiles or extensions; declaring reasons or adding reasons to it (5.4). They work because clients ignore what they do not know (section 3, 4.2).
Breaking changes. A server MUST NOT make them within a version, except through retirement (below):
- removing or renaming a field, or changing its type or meaning;
- making an input field, parameter or header required when it was not (including
If-Matchthrough428, andIdempotency-Key); - tightening validation so that a request accepted before is now rejected (making read-only a field that could be written, or starting to refuse
Idempotency-Keywithout credentials, 7.1, too), unless it closes a security hole; - removing a declared filter (named ones too), operator, sort key, relationship, inclusion, count, action, collection, singleton, profile, extension or method (4.3), a value of a declared enum, a collection’s
syncor the API’sevents(10); - changing the format of
ids, resource URLs or a collection’s default order, or a field’s collation (6.1); - changing the status or the
codereturned for the same case; - removing
reasonsonce declared, removing a reason from it, or changing a reason’scode.
Retiring. Within a version, a field or a declared capability can only disappear by retiring it:
- It is announced first. Discovery MUST list it in
deprecations:{"kind": "field", "name": "rating", "announced": "2026-12-01T00:00:00Z", "sunset": "2027-07-01T00:00:00Z"}.kindsays what is retired, and where the notice goes:- At the root:
version;profileandextension, with its name inname;collectionandsingleton, with its key inname;reason(5.4), with the reason inname. - In the collection:
field;filter(also a named filter);operator, with the filter field innameand the operator inop;value, with the filter field innameand the enum value invalue;sort;relation;include, with the relationship inname, which retires its expansion but not the relationship;count;max_limit, with the lower limit it will have invalue;action;methodanditem_method, with the method inname. - In a singleton:
fieldandmethod.
announcedMUST be the instant the notice was first published, and MUST NOT change afterwards.sunset, once there is a date, is the instant of the removal. Both are RFC 3339 instants. Afieldnotice also covers the filters, sort keys and inclusions of that name and every dotted path that starts with it (name.es-mxforname,author.idforauthor), which go with the field. Acountnotice with"value": "estimated"announces that a declared"exact"count will become"estimated"; withoutvalue, thatcountwill be removed. Responses that use what a notice retires MUST carryDeprecation(RFC 9745) and aLinkwithrel="deprecation"to the explanation. They are: forfield, every response that carries the field and every response to a request that names it in a parameter; forfilter,operator,value,sort,relation,includeandcount, every response to a request that uses them; formax_limit, every response to a request with alimitabove the new value; foraction,methodanditem_method, every response to them; forcollectionandsingleton, every response of that resource and its items; forreason, every problem with that reason; forversion,profileandextension, every response. When what is retired is a whole resource, an action or a version, its responses MUST also carrySunset(RFC 8594, as an HTTP-date) once there is a date. - At the root:
- At least six months SHOULD pass between
announcedandsunset. - After the date, a retired resource, singleton, action or version MUST respond
410 retired; a retired filter, operator, sort, relationship, inclusion or count (acountnotice withoutvalue) MUST give400 unsupported_parameter, like any undeclared one; after acountnotice with"value": "estimated", discovery MUST declare thatcountas"estimated", andcount=truestill addstotal, with"total_estimated": truewhen the number is approximate; a retired enum value in a filter MUST giveinvalid_parameterand no longer appear in data; alimitabove a loweredmax_limitMUST giveinvalid_parameter; a retired method MUST give405; a retired field MUST be absent from representations and is, for parameters and writes, a field that does not exist (6.3); a retired reason MUST NOT be given; a retired profile or extension MUST leaveprofilesorextensions, and its requirements no longer apply. Retiring a profile or extension also retires those that require it (1.2), with the samesunset.
Other changes. These are classified as follows; “retire” means the change is breaking and can be made through retirement, with the kind given.
| Change | Class |
|---|---|
count from "estimated" to "exact" | Compatible |
count from "exact" to "estimated" | Retire (count, with "estimated" in value) |
An action becomes safe or idempotent | Compatible |
An action stops being safe or idempotent | Breaking: retire the action (action) and declare another name |
Raising idempotency.ttl, sync.retention or max_limit | Compatible |
Lowering idempotency.ttl or sync.retention | Compatible if the new value still meets the minimum of this specification (7.1, 10) and the server keeps the old one for keys stored and states issued before the change |
Lowering max_limit | Retire (max_limit, with the new limit in value) |
No longer declaring max_limit | Breaking: limit is not accepted without it (6.4) |
No longer declaring methods, item_methods, schemas or a description, while the API behaves the same | Compatible: a missing declaration means unknown (4.3) |
| Removing a property from a schema, or relaxing it | Compatible if every request it accepted is still accepted and every field it described is still there; otherwise, the change to the field or to validation is what counts |
id_from from missing or "server" to "either" | Compatible only if the server can tell every id the collection has had (5.1); otherwise breaking |
Any other change of id_from | Breaking |
collations from "server" to a value that names the equality and order already in use | Compatible |
Any other declaration or change of collations for a field | Breaking, unless the field’s filter and sort key are new |
GET https://api.example.com/v1/books/7
→ 200
Deprecation: @1798761600
Sunset: Thu, 01 Jul 2027 00:00:00 GMT
Link: </v2/>; rel="successor-version",
<https://docs.example.com/v2>; rel="deprecation"
GET https://api.example.com/v1/books/7 after 1 July 2027
→ 410 application/problem+json
{ "type": "https://w3id.org/restep/1/errors#retired", "title": "Retired", "status": 410, "code": "retired" }
A new major version. A breaking change that cannot go through retirement requires one:
- The version MUST go in the path, as
vfollowed by an integer:/v2/. Each version is a separate API root with its own discovery document, which MUST declare it as"version": "2". - The version MUST NOT go in headers, parameters or media types: in the path it is visible, cacheable and routable with no code. This leaves out date-based versioning in a header, as Stripe does: Restep 1 does not offer it.
- The two versions MUST link to each other with
Link(RFC 5829), at least in the discovery document:rel="successor-version"from the old one andrel="predecessor-version"from the new one.
5.6 Language of the API’s texts
Errors, the discovery document and the schemas the API serves MAY depend on Accept-Language (RFC 9110, section 12.5.4). Only their texts for people change: in an error, title and detail, also those of each errors entry; in discovery, description; in a schema, also one embedded in schemas, the JSON Schema title and description annotations. Data never does (3).
- The server picks the language with the lookup of RFC 4647 (section 3.4) over the languages it can give that response in, trying the ranges of
Accept-Languagefrom highest to lowest weight and, at equal weight, in header order; case-insensitively, without canonicalizing ranges or tags (iwdoes not findhe), and without first dropping extensions or private-use subtags. It ignores*, ranges withq=0and malformed ranges (a malformedqincluded). If none matches, or the header is missing, it MUST use its default language. It MUST NOT answer406or400because ofAccept-Language. - In a server that offers its texts in more than one language, every response whose texts are picked this way (an error, the discovery document or a schema), in the default language too, MUST carry
Vary: Accept-Language, and a304of these the sameVaryas its200. A response with a body SHOULD carryContent-Language. Each language is a different representation: anETag, if present, MUST differ by language. - Lookup truncates the requested tag and never tries sibling variants: with
es-esandes-mxbut noes,Accept-Language: es-ARgets the default language. A server that offers regional variants of its texts SHOULD also offer the bare language. - A replay (7.1) returns the stored response, in its language, because
Accept-Languagedoes not count towards “the same request”.
5.7 Retries
A client repeats a request when it does not know whether it took effect (the connection dropped, it timed out) or when the server tells it to come back later. Whether that is safe depends on the method and on the answer.
- Safe to repeat as is:
GET,HEAD,QUERYand safe actions, which have no effect; actions declared"idempotent": true;DELETE, whose repetition MAY give404(5.1), which a client that is repeating it takes as done; andPATCHwith a merge patch, which leaves the item the same however many times it is applied. APATCHis idempotent except for concurrency: between the two attempts another client may have written, and the repetition undoes that change. WithIf-Match(7.2) the repetition gets412instead, also after a first attempt that succeeded, since that one changed theETag; the client then reads the item to find out. - Not safe without help: a
POSTto a collection, an action declared"idempotent": falseand a batch can take effect twice. A client SHOULD NOT repeat one of them automatically when it does not know whether the first attempt took effect, unless it carriesIdempotency-Keyand the server announceswrites(7.1), or it creates an item with anidthe client chose (5.1), which cannot be created twice. 429 rate_limitedand503 unavailable: the server MUST NOT give either of them to a request that had an effect, nor to one that it cannot tell had none (a timeout after the commit, a process that died): it answers those with another5xx, such as500,502or504. A gateway or load balancer that the API’s operator places in front of it, and that answers with aproblem+jsonbody, is bound by this rule as the server is. So the client MAY send the same request again, whatever its method.409 request_in_progress(7.1) is repeated in the same way, with the same key. WithRetry-After, the client SHOULD NOT repeat it before that time; without it, it SHOULD wait an increasing time between attempts, with some randomness, so that many clients do not come back at once. A429or503without aproblem+jsonbody may come from an intermediary, which this section does not bind.- Other
5xxstatuses (500,502,504…) and a lost response say nothing about the effect: the client repeats only what the first point allows, or what carries the sameIdempotency-Key. - Another
4xxanswers the same request in the same way. A client SHOULD NOT repeat it without changing something first: new credentials after a401, a fresh read after a412,If-Matchafter a428, the body after a422.
5.8 Browser clients
Restep does not require cross-origin access (Fetch, CORS protocol). For the operations a server makes available to a browser origin, it SHOULD send Access-Control-Allow-Origin on every response, errors included, and SHOULD answer their preflight without requiring credentials, since a preflight carries none. When those headers depend on the request’s Origin, every response SHOULD carry Vary: Origin, also one that does not carry them, and every such response that a shared cache may store (one that is public) MUST carry it. If it accepts credentialed requests (cookies, HTTP authentication or TLS client certificates; a token in Authorization is not one), it SHOULD name the origin rather than *, which browsers reject with credentials, and send Access-Control-Allow-Credentials: true. No rule of Restep applies to OPTIONS (5.1): the preflight of an operation open to that origin gets its CORS answer even for a missing item, without credentials or with reserved parameters.
It SHOULD list in Access-Control-Expose-Headers the response headers that the profiles and extensions it announces ask a client to read; in Restep 1, ETag, Location, Link, Allow, Accept-Patch, Retry-After, Deprecation, Sunset, Idempotent-Replayed, Preference-Applied and Accept-Query, plus those of 11.5. It SHOULD allow in a preflight the request headers and methods those operations use; in Restep 1, Content-Type, If-Match, If-None-Match, Idempotency-Key, Prefer, Authorization and DPoP, with PATCH, DELETE and QUERY. These lists are what Restep 1 defines; a later minor version may add to them.
A browser attaches some credentials on its own to requests that other origins’ pages start: cookies, HTTP authentication and TLS client certificates. A server that accepts any of them MUST refuse with 403 forbidden, without applying it, every request that is not safe (a POST, including actions and batches, a PATCH or a DELETE), that it would authenticate with such a credential and that a browser sent from an origin the server does not allow. It MUST treat as such a request whose Origin header (Fetch) is present and is neither the API’s origin nor one it allows. An origin it allows is one it names: a * in Access-Control-Allow-Origin allows none for this rule, since browsers do not accept it with credentials. It MAY treat Origin: null as the API’s origin when Sec-Fetch-Site is same-origin, since a page with Referrer-Policy: no-referrer sends it to its own origin, and MAY decide by Sec-Fetch-Site (Fetch Metadata) when Origin is missing. A request that the server authenticates only with a token in Authorization is not covered: a browser never adds one on its own, so a browser client of another origin that the server allows through CORS keeps working. Those cookies SHOULD carry SameSite=Lax or SameSite=Strict. The preflight and the media type of 3 keep other origins from sending a JSON body; this check also covers an action with an empty body, which any page can send without a preflight (11.1, 13.7).
5.9 Singletons and resources outside Restep
Restep covers collections, their items, their actions, singletons and the resources this specification defines: the discovery document, the batch path, the event stream, the service status (4.4) and the OAuth metadata (11.5). When the server serves a discovery document, collections and singletons are those it declares. Any other resource of the API, such as a PDF or an image linked with href, or a path the API has not declared, is outside Restep: of this specification only 5.3, 5.4 and the Cache-Control rule of 5.1 apply to it, so its body need not be JSON, but a reserved parameter it does not implement still gives unsupported_parameter, and its errors are still problem+json. Such a resource implements a reserved parameter if it reads it, whatever the parameter means there.
A singleton is a resource with no collection, such as the signed-in user’s profile (/me) or an account’s settings, as in AIP-156. The server declares it at the root, in singletons, under a name of its choosing:
"singletons": {
"me": { "path": "/me", "methods": ["GET", "PATCH"],
"description": "The signed-in user’s profile and settings.",
"schemas": { "item": "/schemas/me.json", "update": "/schemas/me-update.json" } } }
- Each singleton MUST have a
path, which MUST NOT be a template, and MAY carrymethods(out ofGETandPATCH, exact as in 4.3),description,schemas(itemandupdate) anddeprecations(5.5). Its path MUST NOT be a path that a collection or an item of one has or could have: not/books/featuredwhile/booksis a collection. - A client MUST ignore a singleton whose
pathis a URI template or whose declaration carriesparent: those forms are reserved for minor versions. - A singleton behaves as an item without
idor collection. It MUST supportGET(andHEAD), which returns its representation, a JSON object, and MAY supportPATCHwith a merge patch, as 5.1 says for items, returning the whole representation.POSTandDELETEon it MUST give405: a singleton is neither created nor deleted by the client. It exists for every principal that may use it; one that may not gets403or404(4.2). - What this specification says of an item’s representation, its read-only fields, its
PATCH, itsETagand itsIf-Match(3, 4.3, 5.1, 7.2, 8) applies to a singleton too, so withwritesevery response with its representation carries_etag, and aPATCHevaluatesIf-MatchandIf-None-Matchagainst its ETag; what it says ofid, item paths and collections does not. A singleton’s representation MAY carry anid, such as the user’s, which is then read-only. - With
query,fieldsMUST work on a singleton as on an item (6.3). Relationships in it follow 3, and each relationship object in it MUST carryhref, since a singleton declares norelationsto find its target from; declaring them,include, language maps and actions on a singleton are outside this version:includeand the other reserved parameters MUST giveunsupported_parameterthere.
6. query Profile
Profile URI: https://w3id.org/restep/1/query. Status: stable. It applies to collections; fields also applies to items. None of its parameters needs a parser: any HTTP framework reads them, though detecting a repeated parameter may need the raw query string (5.3).
6.1 Filters
GET /books?filter[category]=novela-negra&filter[price][le]=20
- The discovery document MUST declare in
filterwhich fields can be filtered, with their type and operators. Fields of a relationship use a dotted path (author.id). - A field whose value is a list, and any path through a to-many relationship (
reviews.rating,speakers.id), MUST NOT be declared infilterorsort: whether such a filter means “some element” or “every element” is reserved for a later minor version. filter[field]=valueis the same filter asfilter[field][eq]=value. Filters on the same field with different operators are different filters (filter[price][ge]=10&filter[price][le]=20). Several filters MUST be combined with AND; for OR, NOT and parentheses there is thefilter-exprextension.- Operators:
eq,ne,lt,le,gt,ge,inandnull. intakes values separated by commas; its values cannot contain commas (useeq,filter-exprorquery-methodfor those).filter[f][in]=is an empty list; an empty element between commas (a,,b) is the empty string.nulltakestrue(no value: absent ornull) orfalse.- The server MUST compare by the declared type: numerically for
integer,numberanddecimal(decimals exactly, without going through floating point), chronologically fordate(as calendar dates) anddatetime(as instants, exactly: a filter value more precise than what the server stores MUST be compared exactly or giveinvalid_parameter, never be rounded; an offset such as+02:00is sent as%2B02:00, 5.2), by length forduration(a day counts as 24 hours; a filter value with years or months MUST giveinvalid_parameter, because they have no fixed length), and by Unicode code points forstringandenum, case-sensitively and without language rules, unless the field’s collation says otherwise (below). Strings are compared as they are, without Unicode normalization: a composed and a decomposedéare different values. (JavaScript’s<compares UTF-16 code units, which order some characters outside the Basic Multilingual Plane differently from code points.) Abooleanfield MUST NOT declare operators other thaneq,neandnull, and theidfilter MUST NOT declarelt,le,gtorge, since the order ofids is the server’s (5.2).nullmay be declared on a field of any type and tests whether the value is absent ornull. - A dotted path that ends in the
idof a relationship whose target is a subcollection MUST NOT be declared infilterorsort: thatididentifies an item only under its parent. - A translation is filtered as
field.tag, with a language map of the collection and a lowercase key:filter[name.es-mx]=Calabacita. Discovery declares each one on its own, of typestring:"name.es-mx": {"type": "string", "ops": ["eq", "in"]}. It reads only that exact key, with no RFC 4647 matching and no fallback: if the item lacks the key, the field is absent. The language map itself and any other path that ends in or goes through one (author.name,author.name.es) MUST NOT be declared infilterorsort, and a language map MUST NOT share its name with a relationship of its collection, soname.es-mxis never a relationship path. - A collection MAY declare in
collationshow a field that holds strings (of typestring, or anenumof strings that is a sort key), or a translationfield.tag, is compared and sorted:"collations": {"title": "server"}. The value applies to the filter and to the sort key of that name, and tofilter-expr. Each key MUST be a field declared infilterwith typestring, or listed insortand holding strings, and MUST NOT beid(5.2)."codepoint", the value of every string field not listed: by Unicode code points, as above."server": equality (eq,ne,in) and order (lt,le,gt,ge,sort) are the server’s, such as a database collation that ignores case or accents. The order MUST be total, deterministic and stable, and agree with the equality: two values are equal exactly when neither goes before the other. The server SHOULD say which it is in the field’sdescription(4.3). A client MUST NOT assume code points, nor reproduce that order or that equality locally. Since only these properties are promised, a change in the server’s own collation that keeps them, such as a library update, does not change the declared value.- Other values are reserved for minor versions, such as collations named by Unicode tags. A client MUST treat a value that is not a string, or a string it does not know, as
"server".
- Every operator except
nullMUST NOT match items where the field is absent ornull. - A filter or sort key on a field that the principal cannot read in an item MUST treat the field as absent in that item: comparisons do not match it,
filter[field][null]=truedoes, and it goes last in a sort. A dotted path through a relationship (author.name) is a field the principal cannot read in an item whose related item it cannot see (9). So a declared filter never reveals a value the client cannot read, and neither does a count (6.5). The server MAY instead answer403 forbidden, naming the parameter inparameter, when the principal cannot read that field in any item. - A
nulloperand other thantrueorfalse, an operand of any other operator that does not match the field’s type (forin, each element), an emptyinlist, or the same filter (same field and operator, in either form) twice MUST giveinvalid_parameter. An undeclared field or operator,unsupported_parameter(5.3).
Named filters. Some criteria do not compare a field: “active sessions” (neither expired nor logged out), “those started from a phone” or “requests approved by someone with this name”. The server declares them by name in named_filters, and the client uses them with the short form of a filter:
GET /books?filter[available]&filter[search]=machado&filter[price][le]=20
- Discovery MUST declare each one in its collection’s
named_filters, with adescriptionthat says which items it returns and, if it takes a value, itstype(4.2, with itsvaluesif it isenum):"named_filters": {"available": {"description": "…"}, "search": {"type": "string", "description": "…"}}. Its meaning is the one its description gives, not a comparison with a field. A named filter MUST NOT share its name with a key of its collection’sfilter, and its name follows 3, so it never contains a dot. - Without
type, it is a switch: it applies withfilter[name]orfilter[name]=, and any value MUST giveinvalid_parameter. Withtype, the value is required: an empty one or one that does not match the type MUST giveinvalid_parameter. - It has no operators:
filter[name][eq], or with any other operator, MUST giveunsupported_parameter, as does an undeclared named filter. The same named filter twice MUST giveinvalid_parameter. - In everything else it is a filter: it is combined with AND with the others, the cursor is bound to it (6.4) and it gives
unsupported_parameterwherever filters do, as in:changes(10). Withfilter-exprit does not go into an expression, because it is not infilter. - Unlike a filter on a field, it compares nothing that
collationsdescribes: how it matches text is said by itsdescription. It MUST NOT select items by values the principal cannot read, unless its description states that criterion, which makes whether an item meets it public: whether an item matches would otherwise reveal those values (13.4). A named filter with atypeMUST NOT compare its value with values the principal cannot read, whatever its description says: each value it is given would ask a different question about them, and bisection would find them.
6.2 Sorting
sort=-rating,title: comma-separated fields, with a leading - for descending order. Sortable fields are declared in sort; any other MUST give unsupported_parameter. The server MUST break ties in a stable way (for instance, by id). Items without a value for a sort key MUST go last, in both directions. A translation is sorted as its declared field.tag (6.1): sort=name.es-mx. Strings sort by code points, without language rules, unless collations says otherwise (6.1); id sorts in the server’s order (5.2).
6.3 Fields
With fields=title,price the response MUST carry only those fields, plus id and members starting with _. It also works on a single item’s GET, where, with writes, the item also carries _etag (7.2). A field that does not exist MUST give invalid_parameter; a field that exists but that the principal cannot read is simply absent from the response, as it would be without fields. A field that the principal cannot read and that neither discovery nor a schema the API serves names MUST be treated, for that principal, as one that does not exist, so fields does not tell it that the field exists. fields=id is valid and returns only id and the _ members; an empty fields is an empty list (5.3). fields and include (9) apply to reads: GET, HEAD and QUERY. On a write they MUST give unsupported_parameter, and the response carries the whole item, or nothing with Prefer: return=minimal (7.3). A language map is one field: fields=name returns it whole, and a path into it (name.es; with relations, also author.name.es) MUST give invalid_parameter.
6.4 Pagination
limitsets the page size, between 1 and the declaredmax_limit. Outside that range the server MUST giveinvalid_parameter, not clamp it silently. A collection that acceptslimitMUST declaremax_limit; on one that does not declare it,limitMUST giveunsupported_parameter.nextMUST carry an opaquecursorparameter and keep the other parameters unchanged. Clients MUST NOT interpret or build cursors.- A cursor is bound to the collection, the filters and the sort it was issued for; with
QUERY, to thefilterandsortmembers of the body (11.4). A cursor the server did not issue (a tampered one), an expired one, or one used with another collection, other filters or another sort MUST giveinvalid_parameterwithparameter: "cursor". A cursor SHOULD also be bound to the principal (2) that received it, and MUST be if it refers to results computed for that principal, such as a stored snapshot, so that another principal cannot page through them. Signing it is the simplest way to tell a tampered one. A cursor SHOULD NOT carry item data in readable form, such as the sort values of a keyset in clear:nextURLs end up in logs. Encrypting it, or keeping the position on the server, avoids that (13.9). - A cursor MUST NOT be bound to
limit,fields,includeorcount: they change what each page carries, not which items the traversal visits. Between pages, a client MAY add, change or remove them in thenextURL of aGET, or in the body of aQUERY, and that MUST NOT invalidate the cursor. - A server MAY start with an offset inside the cursor and later move to keyset pagination without clients noticing. The guarantee is the one in 5.2: no repeats and no gaps without concurrent writes.
6.5 Counts
Discovery declares count as "exact" or "estimated". With count=true, the response MUST add total and, if the number is approximate, "total_estimated": true. On a collection that declares count, count=false is the same as leaving it out, and any value other than true or false MUST give invalid_parameter. On a collection that does not declare it, and on any server without this profile, count with any value, false included, MUST give unsupported_parameter (5.3). total MUST count only the items the client can see, also when it is estimated.
7. writes Profile
Profile URI: https://w3id.org/restep/1/writes. Status: stable. Writes that can be retried without duplicating and that do not overwrite each other. Caching is a profile of its own, cache.
7.1 Retry without duplicating
POST /orders
Idempotency-Key: "8e03978e-40d5-43e8-bc93-6894a57f9324"
- Every non-idempotent
POST, including actions declared"idempotent": false, MUST accept theIdempotency-Keyheader, except as below for requests without credentials: a Structured Fields String without parameters (RFC 9651). A malformed key MUST give400 bad_request, with anerrorsentry whoseheaderisIdempotency-Key. On other methods thanPOST, the server MUST ignore the header. This section defines the header’s syntax and meaning for Restep on its own: it follows the IETF draft (14.2) where they agree, and does not depend on that draft advancing or staying as it is. - A key belongs to one principal (2), not to a token, and one target (method and path, compared after percent-decoding, without the query): a retry with a renewed token still finds it. Two requests are the same when they share key, principal and target, their query parameters are the same after percent-decoding (their order does not count, as in 5.2), and their bodies are equal as JSON values (2). So the same key on the same path with another query is a different request, and gets
422 idempotency_mismatch. - Requests without an authenticated principal all count as one anonymous principal and share its keys. The server MAY refuse
Idempotency-Keyon such requests. If it does, it MUST declare it in discovery with"anonymous": falseinidempotency(missing meanstrue), and MUST answer with400 bad_request, with anerrorsentry whoseheaderisIdempotency-Keyand whosecodeisunknown, before any effect, aPOSTwithout credentials that carries the header and to which this section would otherwise apply; aPOSTto an action declared"idempotent": trueMUST ignore the header instead, and store nothing under it (11.1). Whileanonymousisfalse, a resource that requires the key MUST NOT require it of requests without credentials. A401would send the client to get credentials that the resource does not need. Otherwise this section applies to them as to any principal. A client SHOULD generate each key from a random source, with at least the 122 random bits of a version 4 UUID, and SHOULD NOT use it for another request: whoever guesses or learns a key can take it first under the same principal or, with the same request, get its stored response (13.5). - The server MUST keep each key for at least 24 hours from the first request, and SHOULD declare how long in discovery (
"idempotency": {"ttl": 86400}, in seconds). After that, the key counts as new. - If the same request arrives again, the server MUST return the same status and body without repeating the effect, and SHOULD add
Idempotent-Replayed: true. Headers such asDatemay differ. A replay, and the409 request_in_progressfor the same request while the first one is still running, take the place that 5.4 gives them: after every check of the earlier steps and before428. Neither evaluatesIf-Match,If-None-Matchor a428requirement: a replay returns the stored response even if they no longer hold. A different request under the same key evaluates them as usual, so412comes before422 idempotency_mismatch. - If the server fails after the effect and before storing the response, a retry with the same key MUST NOT repeat the effect: the server records both atomically, or recovers as if it had.
- A request that was rejected before it ran (a
4xxsuch as422, or a5xxthat left no effect) MAY be left unstored; then it does not use up the key, and the client can fix it and retry with the same one. A request that had an effect MUST be stored. - The same key with a different request MUST give
422 idempotency_mismatch, also while the first one is still running. The same request while the first one is still running MUST give a409problem withcoderequest_in_progress, which SHOULD carryRetry-After, unless the server waits for the first one to finish and then answers it as a replay, which it MAY do; the client MAY send it again with the same key, afterRetry-Afterwhen present. A resource that requires the key MUST give400 idempotency_key_requiredwithout it, except to a request without credentials whereanonymousisfalse(above). - A
core-only server does not know the header and ignores it. Clients MUST NOT rely onIdempotency-Keyunless the server announceswrites.
7.2 Optimistic concurrency
- Each item has a strong item ETag: the
ETagof its full representation, withoutfieldsorinclude, computed as if_etagwere absent; its other_members count. It is theETagof the representation this principal reads, so where that representation depends on the principal (_actions, fields it cannot read), so does the item ETag, andIf-Matchis evaluated against the writer’s. AGETof the full item without content coding MUST carry it, and servers MUST NOT use a weak validator (W/) for it. With a content coding (gzip), theETagheader MAY differ, as RFC 9110 requires. - Every response whose body is a single item’s representation, to a read or to a write, MUST carry the item ETag in
_etag, whatever its content coding and its parameters: a proxy or a CDN that compresses the response may weaken or change theETagheader without the server knowing, and the client still needs a validator forIf-Match. - A single item’s response with
fieldsorincludeis another representation: itsETagheader MUST change whenever anything in it changes, included items too, while its_etagstays the item ETag, so the client can write without another read. - An item in a collection response SHOULD carry in
_etagthe item ETag of the version it represents, when it supportsPATCHorDELETE, so a client can write without reading it first. In a collection that declaressync(10), such an item MUST carry it on every page, whatever the query parameters, withGETorQUERY(11.4). PATCHandDELETEMUST evaluateIf-Matchagainst the item ETag as RFC 9110 says (lists,*, strong comparison): if it does not match,412 precondition_failed. They MUST also evaluateIf-None-Match(lists,*, weak comparison): if it matches,412without applying the write. On an item that does not exist, such as one another write has just deleted, they MUST give404(410 retiredonly after a retirement, 5.5), whatever the preconditions say: the order of 5.4 puts it before412, where RFC 9110 would evaluateIf-Matchas false.- A
POSTto a collection, or to an action on it, has the collection as its target, and Restep gives a collection no ETag to write against. The server MUST evaluateIf-MatchandIf-None-Matchthere as RFC 9110 says, against theETagthat aGETof the collection without parameters would carry for this principal, or none if it cannot read the collection: soIf-Matchwith entity tags gives412unless thatETagis among them; where there is thatETag,If-Match: *succeeds andIf-None-Match: *gives412, and where there is none, the other way round. A client SHOULD NOT send them on such aPOST; to create an item only if itsidis free, it chooses theid(5.1). On an action on an item, the target is the item, with its item ETag. - Evaluating
If-Matchand applying the write MUST be atomic with respect to other writes to the same item. - A resource MAY require
If-Match; without it, it MUST answer428 precondition_required. Starting to require it is a breaking change (5.5).
7.3 Minimal responses
With Prefer: return=minimal (RFC 7240), writes MAY respond without a body: 201 with Location, or 204. When the item it created or changed still exists (not after a DELETE), such a response MUST carry that item’s ETag in ETag, since it has no _etag, and SHOULD carry Preference-Applied: return=minimal. By default they return the representation.
8. cache Profile
Profile URI: https://w3id.org/restep/1/cache. Status: stable. Reads that a cache can store, revalidate and invalidate. It requires only core, so a read-only API can announce it without building the idempotency store of 7.1.
- Every response to a
GETorHEAD, errors included, MUST carry an explicitCache-Control. - A response that depends on credentials is
privateorno-store, as 5.1 requires of every server. A response that does not MAY bepublic, such as a discovery document served without credentials (4.2). - A successful
GETof a full item or a singleton (5.9), withoutfieldsorinclude, MUST carry anETag. If the server also announceswrites, it is the item ETag of 7.2; otherwise it MAY be weak. AnyETagthe server gives MUST change whenever anything in the representation it validates changes, included items too. If-None-Matchon aGET,HEADorQUERYMUST be evaluated as RFC 9110 says (lists,*, weak comparison): when it matches, the server MUST answer304.304toQUERYis a Restep rule: RFC 9110 (section 13.1.2) names onlyGETandHEAD, while RFC 10008 makes aQUERYselect the same representation as the equivalentGETand answers a conditional one with304in its example. On writes,If-None-Matchbelongs to 7.2.- A successful response to a
GETSHOULD carryCache-Groups(RFC 9875) naming every item it represents, included ones too, and, for a collection, the collection itself, so a cache can drop the lists an item enters or leaves. A2xxresponse to aHEADSHOULD carry the groups theGETwould. A successful response to a write that committed changes (for a batch, the outer response, covering every committed operation) SHOULD carryCache-Group-Invalidationnaming every item it changed and their collections, even without a body. Group names are opaque and per origin; the item’s path ("/books/7") and the collection’s ("/books") are the obvious choice. Group names MUST NOT reveal to the client what it could not otherwise learn (5.4): a response names by its path only an item the client can see, and invalidates the others through a group it may know, such as their collection’s. A cache may or may not honour them, and RFC 9875 only guarantees 32 groups per field, of 32 characters each, so a long page or a long id may not get every item invalidated. The collection’s own group SHOULD come first.
9. relations Profile
Profile URI: https://w3id.org/restep/1/relations. Status: stable. The shape of relationships is set in section 3, and how they are written in 5.1, so any server follows them; this profile adds declarations and expansion.
- Discovery MUST declare each relationship in
relations, with its target collection into(a list, when it can point to several: see section 3),"many": trueif it is to-many, and"include": trueif it can be expanded. include=authorMUST fill that object with the full item; with a relationship to several collections, the item of the collection itstypenames. Dotted paths (include=author.publisher) are allowed up to the declaredinclude_depth(1 if not declared). A relationship that is not declared or not expandable, or a path deeper thaninclude_depth, MUST giveunsupported_parameter.- If the client cannot see the related item, the object MUST stay with only
id(andtype, andhrefwhere 3 requires it). - When the target is a subcollection, each relationship object carries
href(3): a client builds the path of an ordinary target from its collection’spathand theid(5.1), but the item of a subcollection also needs its parent’sid, whichhrefcarries.{"id": "3", "href": "/books/7/reviews/3"}. - When the server also implements
query,fieldsaccepts dotted paths (fields=title,author.name); a dotted path whose relationship is not inincludeMUST giveinvalid_parameter. - Relationships with many items (a book’s reviews) SHOULD be subcollections, such as
/books/7/reviews, declared with apathtemplate and aparent(4.2) and followingcoreand, if announced,query. The relationship that leads to one MAY carry the same template in itspath, asreviewsdoes in the example of 4.2. A to-many list embedded in a representation MUST NOT be paginated: if it can grow without bound, it SHOULD be a subcollection. - To filter by a relationship, discovery declares the dotted path in
filter:filter[author.id]=3.
GET /books/7
{ "id": "7", "title": "La niebla de Portugalete", "author": { "id": "3" } }
GET /books/7?include=author&fields=title,author.name
{ "id": "7", "title": "La niebla de Portugalete", "author": { "id": "3", "name": "Inés Arriaga" } }
PATCH /books/7 changes the link, not the author
{ "author": { "id": "4" } }
10. sync Profile Experimental
Profile URI: https://w3id.org/restep/1/sync. Status: experimental (1.2). Keep a local copy of whole collections up to date without downloading everything again. It requires query.
- A collection is synced when it declares
syncin discovery, as an object,{}if it has nothing to say. A collection MUST NOT declaresyncunless the server announces this profile inprofiles; without it, asyncdeclaration means nothing and no collection is synced. Only synced collections answer:changes; on any other,:changesMUST give404 not_found. Every synced collection MUST declareidinfilterwithin. The rest of this section is about synced collections. - Collection responses MUST carry
state: an opaque string that changes whenever anything the client can see in the collection changes. It reflects that client’s view: an item it stops being allowed to see counts as destroyed. A filtered response carries the samestateas the whole collection; a client that keeps a copy of the collection traverses it without filters. - Clients MUST NOT interpret or build a
state; they MAY compare two states for equality. The same considerations as for cursors apply to it (6.4, 13.9). - Every page of a traversal MUST carry the
stateof its first page, the request withoutcursor(the server can keep it in the cursor). A client MUST use it assincefor its next sync: changes made during the traversal show up there. - A traversal MUST NOT miss items: every item that existed, and matched the request, when the first page was served, and does not appear in
:changessince thatstate, appears in some page. Offset cursors do not guarantee this; keyset cursors or a snapshot do. GET /books:changes?since=<state>returns the identifiers created, updated and destroyed since that state. The response MUST carrysince,state,has_more,created,updatedanddestroyed. Each identifier MUST appear in at most one list, picked by what the client could see betweensinceand the returnedstate(an item that does not exist cannot be seen). These rules cover the items that changed, or whose visibility to the client changed, in that window:- an item it could see at
sinceand cannot see atstateMUST be indestroyed; - an item it can see at
stateMUST be inupdatedif it could see it atsinceand it changed or stopped being visible in between, and increatedif it could not see it atsince; - an item it cannot see at either end MUST be in
destroyedif it could see it in between, and MUST NOT appear otherwise.
updated. If the server cannot reconstruct what the client could see in the window, it MUST answer410 state_expired; whether it can MUST NOT depend on the existence of an item concealed from the client (5.4). Clients MUST treatcreatedandupdatedalike, fetching the item and replacing their copy, and MUST ignore anidindestroyedthat they do not have.- an item it could see at
- If
has_moreistrue, the returnedstateis intermediate: the client MUST call again with it untilhas_moreisfalsebefore treating its copy as current. :changescovers the whole collection: filters and the otherqueryparameters MUST giveunsupported_parameterthere, and a missingsinceMUST giveinvalid_parameter. Keeping a filtered view in sync is outside this version.- The client fetches the changed items with
GET /books?filter[id][in]=7,12. - The server SHOULD keep changes for at least 7 days and SHOULD declare how long in the collection’s
sync.retention(seconds). If it can no longer compute the changes, it MUST answer410 state_expired, and the client reloads the collection. - The action name
changesis reserved for this profile (11.1). - The server MAY offer notifications over Server-Sent Events at the path declared in
events, relative to the API root like thepathmembers of discovery (2); that response MUST carryCache-Control: no-store. It MAY limit the streams a principal keeps open, and MUST answer429 rate_limitedto one over that limit. Each event says which collections have a new state, naming each by its key or, for a subcollection, by its path relative to the API root with the template expanded ("/books/7/reviews"); the data itself is fetched with:changes. The server MUST NOT send an event for a change that does not change that principal’sstate, or the rhythm of events would reveal activity it cannot see. - Events are hints: clients MUST tolerate repeated, merged and reordered events. On opening the stream, and on every reconnection, a client MUST call
:changesfor each collection it keeps, from the last state it applied, and MUST advance that state only after applying the changes; an event alone never advances it. Servers MUST NOT rely onLast-Event-IDto resume. - The server SHOULD send an SSE comment at least every 30 seconds, to reduce idle timeouts. It MUST close the stream when the credentials that opened it stop being valid, and MUST answer
401to any reconnection that carries invalid credentials, an automaticEventSourceone included. After that, the application MUST wait for valid credentials before opening the stream again.
GET /books:changes?since=s128
{ "since": "s128", "state": "s131", "has_more": false,
"created": ["51"], "updated": ["7", "12"], "destroyed": ["34"] }
GET /events Accept: text/event-stream
event: state
data: {"books": "s131"}
11. Extensions
Each extension is announced in extensions and has its own profile URI (https://w3id.org/restep/1/batch…). What each one requires, and whether it is stable or experimental, is in 1.2.
11.1 actions Extension
Status: stable. Operations that are not create, read, update or delete, following AIP-136: the action name goes after a colon.
POST /orders/2001:cancel on an item
POST /books:import on the collection
GET /orders/2001:preview a safe action declared with "method": "GET"
- Each action MUST be declared in its collection’s
actions, withon("item"or"collection"),safeandidempotent. Action names follow 3 and SHOULD besnake_case; a collection MUST NOT declare an action namedchanges, whichsyncuses. - An action uses
POSTunless its declaration says"method": "GET", which only safe actions MAY do. Servers MUST also accept the colon encoded as%3A. - The declaration MAY carry a
descriptionand, if the action usesPOST, aninputschema (4.3). AGETaction has no body, so it MUST NOT declareinput. - A
POSTaction MUST treat an empty body, with or withoutContent-Type, as{}sent asapplication/json; so a client that has nothing to send can send either. A non-empty body follows 3. - The response MUST be the affected resource’s representation (
200), a new one (201withLocation) or nothing (204). - A request to an action that its collection does not declare, or that is declared
onthe other kind of resource, MUST give404 not_found, as any resource that does not exist; a declared action with another method MUST give405withAllow. A declared action that the item’s current state does not allow MUST give409 conflict, with areasonif the API has one (5.4); one that this principal may not use,403or404(4.2). - With
writes, an action declared"idempotent": trueMUST NOT reject a request because it carries a well-formedIdempotency-Key: it MAY ignore it, since repeating the action is already safe (5.7), or apply 7.1 to it; to a request without credentials, whereidempotencydeclares"anonymous": false, it ignores the key and stores nothing under it (7.1). A client MAY send one to anyPOSTaction. - A representation MAY list in
_actionsthe actions available in its current state, so clients do not duplicate business rules. Every action it lists MUST be declared in its collection’sactions, withonmatching and the same method, so the client knows whether it issafeandidempotent:
{ "id": "2001", "status": "paid",
"_actions": { "cancel": { "method": "POST", "href": "/orders/2001:cancel" } } }
11.2 batch Extension Experimental
Status: experimental (1.2). Several operations in one request, in order, with references to the results of earlier ones. They are sent to the path declared in batch.path.
POST /batch
{ "atomic": false,
"operations": [
{ "id": "a", "method": "POST", "path": "/orders", "body": { "book": { "id": "7" } } },
{ "id": "b", "method": "POST", "path": "/orders/{a#/id}:pay",
"headers": { "idempotency-key": "\"pay-2001\"" },
"body": { "amount": { "$ref": "a#/total" } } } ] }
→ 200
{ "results": [
{ "id": "a", "status": 201, "headers": { "location": "/orders/2001" }, "body": { … } },
{ "id": "b", "status": 200, "body": { … } } ] }
- Each operation MUST have an
id, unique in the batch, amethod, apathand, optionally,headers(with lowercase names) andbody. Each operation MUST follow the same rules as if it were sent alone, with the exceptions of this section. - An operation’s
pathMUST start with/and is relative to the API root (2), like thepathmembers of discovery; it MUST NOT carry a scheme, an authority, a fragment or dot-segments (.,..), and MUST name a resource of Restep (5.9) other than the event stream (10). A value that a reference (below) inserts into it MUST be a string that is a validid(3) or an integer, and the server MUST check this rule again on the path that results; otherwise the operation gets424 not_executed. - Its
headersMAY carry onlyif-match,if-none-match,idempotency-keyandprefer, pluscontent-typeandaccept-language, which the server MUST ignore: an operation’sbodyis already JSON and the batch request carriesContent-Type: application/json(3), and the batch’sAccept-Languageapplies (below). Every operation acts for the batch’s principal, with the batch request’s credentials,OriginandAccept. The server MUST NOT apply thePrefer,If-MatchorIf-None-Matchof the batch request itself to any operation. - A reference is
<id>#<JSON Pointer>into the response body of an earlier operation: in literal braces insidepath(%7Bis not one), where the value MUST be inserted percent-encoded as a path segment (RFC 3986), or as{"$ref": …}in place of a body value. An object whose only member is$refis always a reference, so a client that puts into a batch body data it did not write MUST make sure that no object in it has$refas its only member. - A body that is not a valid batch, a repeated operation
id, a reference to an operation that does not come earlier, a nested batch, apaththat breaks the rule for paths above before references are inserted, or a header outside those six MUST give400 bad_requestbefore any operation runs. 5.4 applies to the batch request as a whole before any operation runs; once the batch is accepted, it applies to each operation on its own, subject to the424 not_executedrules below. More operations thanmax_operationsMUST give413 content_too_large, which the server MAY give without validating the operations: a batch that is both too long and invalid can get400or413(5.4). - A batch that passes these checks, the atomic check below and those of any request (credentials, content type, rate limits, 7.1) MUST get
200with one result per operation, in order, each with its ownstatus,headersandbody; an error result is a problem object. This is the only exception to “no error inside a200” (5.4). - With
"atomic": true, either all operations take effect or none does. If one fails, it carries its error and every other operation MUST get424 not_executed, including those that ran and were rolled back. A server that cannot roll back one of the operations (an external payment, an email) MUST reject the atomic batch with422 invalidbefore running it. - Without
atomic, each operation applies on its own; an operation whose reference cannot be resolved, because the referenced one failed or the pointer finds nothing, MUST get424 not_executed. - With
writes, the batch itself MAY carryIdempotency-Key; then the whole batch follows 7.1, including its rule for requests without credentials whereanonymousisfalse. - Another exception: the texts of each new result (5.6) follow the batch’s
Accept-Language, and an operation’s own is ignored; a replayed result (7.1) keeps its own.Content-LanguageandAccept-LanguageinVarygo on the batch response, not in each result’sheaders:VaryincludesAccept-Languageonly if some new result can vary by language, andContent-Languageis left out unless every result with language-picked texts shares one.
11.3 filter-expr Extension Experimental
Status: experimental (1.2). A filter as an expression, in the spirit of AIP-160:
GET /books?filter=price <= 20 AND (category = "novela-negra" OR rating >= 4.5)
- Comparators
=,!=,<,<=,>and>=, which map toeq,ne,lt,le,gtandge;AND,OR,NOTand parentheses. Fields by name or dotted path (3); a path segment may contain-(name.es-mx).AND,OR,NOT,true,falseandnullare never field names in an expression: a field so named cannot be used in one. Values: strings in double quotes (with\"and\\as the only escapes), numbers,true,falseandnull.field = nullandfield != nullmap to thenulloperator. NOTbinds tightest.ANDandORMUST NOT be mixed at the same level without parentheses:a AND b OR cMUST giveinvalid_parameter. AIP-160 givesORprecedence overAND, most languages do the opposite; Restep asks for parentheses so nobody guesses. Juxtaposition (a b, AIP-160’s implicit AND) MUST giveinvalid_parametertoo.- A field or operator not declared in
filterMUST giveunsupported_parameter. Comparisons follow 6.1, absent andnullvalues, collations and fields the principal cannot read included; a number compared with adecimalfield is read as an exact decimal. - It cannot be combined with
filter[…]in the same request: that MUST giveinvalid_parameter.
11.4 query-method Extension Experimental
Status: experimental (1.2). For queries that do not fit in a URL, the QUERY method (RFC 10008): safe, idempotent and cacheable, with the query parameters in the body.
QUERY /books
Content-Type: application/json
{ "filter": { "price": { "le": "20" }, "category": { "in": ["novela-negra", "poesia"] } },
"sort": ["-rating"], "fields": ["title", "price"], "limit": 10, "count": true }
- Collections that accept it MUST announce it with
Accept-Query: application/json(RFC 10008) in their responses toGETandHEAD. - The body is a JSON object with the same members as the reserved parameters:
filteras an object of fields and operators (or, withfilter-expr, a string),sort,fieldsandincludeas lists,limitas a number andcountas a boolean. Values use their JSON type, andintakes a list, so its values can contain commas. A named filter goes as"name": value, with a value of its type, or"name": trueif it is a switch;falseor any other value on a switch givesinvalid_parameter. An unknown member MUST giveunsupported_parameter. - A
QUERYMUST return the same as the equivalentGET, with the same errors; a matchingIf-None-Matchgives304, as forGET(8). The URL MUST NOT carry reserved parameters other thancursor; the server MUST answer one withunsupported_parameter. - In the response,
nextcarries onlycursor, which here overrides the rule of 6.4 that keeps the other parameters. For the next page, the client MUST send a body with the samefilterandsortto thenextURL, and MAY changelimit,fields,includeandcount(6.4); the server MUST answer afilterorsortthat is not equal as a JSON value (2; an absent member,{}and[]are the same) withinvalid_parameteroncursor. - Caches that store
QUERYresponses use the body as part of the key; many CDNs do not do that yet.
11.5 oauth Extension
Status: stable. How a client finds out where to get a token for the API. It defines neither authentication nor authorization: it ties the OAuth 2.0 Protected Resource Metadata (RFC 9728) to the API root. A server that does not announce it authenticates as it sees fit.
GET /api/ (the API root: https://example.com/api/)
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://example.com/.well-known/oauth-protected-resource/api/"
GET https://example.com/.well-known/oauth-protected-resource/api/
{ "resource": "https://example.com/api/",
"authorization_servers": ["https://auth.example.com"],
"scopes_supported": ["books:read", "books:write"] }
- The server MUST serve the metadata at the URL that RFC 9728 (section 3.1) forms from the API root: the well-known suffix goes between the host and the root’s path, which keeps its final slash; only when the root is the bare host does its slash go. Under
https://example.com/api/it ishttps://example.com/.well-known/oauth-protected-resource/api/; underhttps://api.example.com/,https://api.example.com/.well-known/oauth-protected-resource. - In that document,
resourceMUST be the API root, character for character, final slash included, andauthorization_serversMUST list at least one issuer: RFC 9728 makes it optional, but without it the client has nothing to discover.scopes_supportedSHOULD be present. Each authorization server describes itself with RFC 8414 or OpenID Connect Discovery; Restep requires nothing of it. - The metadata is not a resource of the API: 4.1, 5.1, 5.2 and 5.3 do not apply to it. It MUST be served as
application/jsonwithout requiring credentials, so it never gives401, and it SHOULD carryCache-Control: publicwith amax-age. - When the API root requires credentials, its
401MUST carry the absolute URL of the metadata inresource_metadata(RFC 9728, section 5.1), in at least one challenge:Bearer,DPoPor any other the API accepts. RFC 9728 (section 3.3) makes clients discard metadata found that way whoseresourceis not the URL they requested, so on any other resource the server MUST NOT pointresource_metadataat the root’s metadata. The root’s metadata is for the exact root URL, without a query. A client that gets a401withoutresource_metadataforms the metadata URL from the root. - OAuth errors keep their Restep codes: the challenge carries the OAuth error and the body the Restep
code.invalid_requestis400 bad_request;invalid_token, andinvalid_dpop_proofanduse_dpop_nonce(RFC 9449), are401 unauthenticated;insufficient_scopeis403 forbidden. A403for a missing scope MUST carryerror="insufficient_scope"in its challenge (RFC 6750, section 3.1) and SHOULD name the scope needed inscope, unless that would reveal permissions the client must not know. A resource whose existence is concealed still gives404(5.4). - The server MUST refuse a token meant for another resource server (RFC 9700, section 2.3). A client asks for a token restricted to this API by sending its
resourcein theresourceparameter (RFC 8707). - With DPoP (RFC 9449) the challenge uses the
DPoPscheme. A retry with a fresh DPoP proof comes from the same principal and is the same request for 7.1. - A server that allows cross-origin requests (5.8) SHOULD list
WWW-AuthenticateinAccess-Control-Expose-Headers(andDPoP-Nonce, if it uses DPoP nonces), or a browser client cannot read them, and SHOULD serve the metadata withAccess-Control-Allow-Origin.EventSourcecannot sendAuthorization, so a browser client reads the event stream of 10 withfetch; the server SHOULD NOT accept tokens in the query string (RFC 6750, section 2.3).
11.6 inherit Extension Experimental
Profile URI: https://w3id.org/restep/1/inherit. Status: experimental (1.2).
A value can apply to an item without being stored in it: a product’s tax rate is its own if it has one; otherwise its category’s, its parent category’s or its store’s; and if none has one, a default. Restep expresses this with two fields and a declaration in discovery. The rules of this section apply only to the fields that inherit declares. A collection MUST NOT declare inherit unless the server announces this extension in extensions.
- The effective field (
tax_rate) gives the value that applies, already resolved. It is read-only. - The own field (
tax_rate_own) gives the item’s own value, ornullif it has none and inherits. It is the one that is written.
There are two because a single field would have to show the value that applies and also store the one that is written. A client that sends back what it read (5.1) would then turn every inherited value into an own value: the value does not change, but the item stops following its source and nobody notices. With two fields, writing the value you see and deciding whether it is inherited are different operations on different fields.
GET /products/7
→ 200
ETag: "p7-v3"
{ "id": "7", "name": "Zucchini", "category": { "id": "4" },
"tax_rate": "10",
"tax_rate_own": null,
"_inherited": { "tax_rate": { "from": { "href": "/categories/2" } } } }
Declaration. In the collection object, the keys of inherit are the effective fields:
"products": {
"path": "/products",
"relations": { "category": { "to": "categories" } },
"inherit": {
"tax_rate": { "own": "tax_rate_own", "from": ["category"], "default": true,
"description": "The product’s tax rate; without its own, its category’s." } } },
"categories": {
"path": "/categories",
"relations": { "parent": { "to": "categories" }, "store": { "to": "stores" } },
"inherit": { "tax_rate": { "own": "tax_rate_own", "from": ["parent", "store"], "default": true } } }
ownnames the own field. Both fields MUST be top-level and of one of the scalar types of 4.2, and cannot beid, a relationship or a language map: in those,nullor the merge patch already mean something else (3, 5.1).fromlists, in order, the relationships this step inherits from. Each MUST be to-one and declared inrelations(9), even if the server does not announce that profile, and its target collection MUST have a field with the same name as the effective one. If that field is also declared in itsinherit, the chain continues: so a category inherits from its parent category to whatever depth is needed, without dotted paths."default": truesays there is a default at the end of the chain and the effective value is never empty. The value is not published: changing it is a change of data, not of discovery.descriptionexplains the field as in 4.3.
Resolution. The effective value MUST be the own value, if it is not null; otherwise the effective value of the item linked by the first relationship in from that has a link; otherwise the default; and with no default, the field has no value (3). A link that would create a cycle (a category that ends up as its own ancestor) MUST give 422 invalid.
Reading.
- When the representation carries the effective field, it MUST carry it resolved and with its usual type. The own field carries its value or
null. - The item MAY explain the origin in
_inherited: an object whose keys are the effective fields present in the representation that do not come from the own field. If it carries it, it MUST name them all, so an effective field not in_inheritedhas its own value. Withfields(6.3),_inheritedonly covers the fields in the response. Each value is one of these:{"from": {"href": "/categories/2"}}: the absolute path (3) of the value’s actual source, not of the immediate parent. In the example, category 4 has no own value and category 2 does.{"from": "default"}: it comes from the default.{"from": "hidden"}: it is inherited, but the client cannot see the source. The server MUST NOT give the path of an item the client cannot see, just as a relationship is left with onlyid(9), nor of one whose existence it does not reveal (5.4).
fromit does not know as"hidden".
Writing. The own field is an ordinary field and follows the merge patch with no exceptions. It is the only one that changes inheritance:
PATCH body | Effect |
|---|---|
{"tax_rate_own": "4"} | It gets its own value, 4 |
{"tax_rate_own": "10"}, equal to the inherited one | It gets its own value, 10: the same value, but it no longer follows the category |
{"tax_rate_own": null} | Deletes the own value and inherits again |
No tax_rate_own | Nothing changes |
The effective field is read-only (5.1), so writing it never changes anything: a PATCH with its current value is ignored, and another value gives 422 invalid with a read_only entry, whose detail SHOULD name the own field. It is compared rather than always ignored so that a client trying to change it learns that nothing changed, instead of getting a misleading 200.
- In a
POST, an absent ornullown field makes the item start out inheriting, and the effective field follows the same rule, compared with the value that would result.
PATCH /products/7
{ "tax_rate": "4" }
→ 422 application/problem+json
{ "type": "https://w3id.org/restep/1/errors#invalid", "title": "Invalid data", "status": 422, "code": "invalid",
"errors": [ { "pointer": "/tax_rate", "code": "read_only",
"detail": "“tax_rate” is the effective value; write “tax_rate_own”." } ] }
Sending back the effective fields as read changes nothing. This is the rule of 5.1 applied to inheritance: a PATCH with the effective fields as read leaves the item as it was: they match and are ignored, the own fields it leaves out are not touched, and _inherited is ignored like any _ member. A client that does not know the own field exists can leave it out safely, and the only mistake it can make is writing the effective field, which gives the 422 above and tells it where to write. This works because in a PATCH what is absent is not touched: with a PUT, which Restep leaves out (5.1), leaving out the own field would delete it and the item would inherit again without anyone asking.
PATCH /products/7 the effective field as read, without the own field
{ "id": "7", "tax_rate": "10" }
→ 200, the item unchanged and the same ETag
Stale reads. If the source changes between the read and the write (category 2 moves to 5 %), the "tax_rate": "10" the client sends back no longer matches. With If-Match it gives 412, because the product’s ETag has already changed (7.2); without it, 422 with read_only. Either way it fails without changing anything, where a stale ordinary field would silently overwrite someone else’s change.
When a source changes. When a category’s value changes, the effective value of every item that inherits from it changes, though nobody touched them. For the client those items have changed, so what other sections already say applies to each:
- its
ETagchanges (7.2: it is that of the complete representation), also when only_inheritedchanges, for instance if category 4 sets as its own the same value it inherited; - with
sync, its collection’sstatechanges and:changeslists them (10); - with a shared cache, the write to the source SHOULD also invalidate the groups of those items and of the collections that can contain them (8).
This forces the server to store the effective values or to propagate each change to every descendant. It is the main cost of declaring inherit.
Filters and sorting. With query, filtering and sorting by the effective field compare the value the client sees: filter[tax_rate][eq]=10 gives those worth 10, inherited or not. Those that inherit are asked for with filter[tax_rate_own][null]=true, with no new operators, if that filter is declared (6.1).
Evolution. Adding inheritance to a new value, or to a field that was already read-only, is compatible: the own field and the declaration are added. Turning into an effective field one that could be written until now is not, because it would reject writes that used to be accepted (5.5): it takes a major version, or retiring the field and adding the pair under other names.
12. Conformance
There are two classes of conformance, and each is claimed per profile and per extension:
- A server conforms to a profile or extension when it meets every requirement on servers marked MUST or MUST NOT in sections 1, 3, 4 and 5 and in that profile’s or extension’s section, and announces the ones it requires (1.2). A server that announces a profile or extension claims conformance to it.
- A client conforms to a profile or extension when, in every use it makes of it, it meets every requirement on clients marked MUST or MUST NOT in the same sections. Every client uses
core; a client that never sends aQUERYneed not meet the rules ofquery-method. A library, a proxy or an agent that talks to a Restep API is a client, and a proxy is also a server to its own clients.
Requirements marked SHOULD, SHOULD NOT or MAY do not decide conformance. Section 13 and the appendices add no requirements.
12.1 Servers
These are the checks a conformance checker runs on a server; which of them restep-check runs today is listed on its page. Some need what a checker is given rather than what it can observe: credentials for two principals, a session with cookies, or a way to provoke 429, 503 or two writes that race. They are marked “given”; a checker runs each only when it is given that, and reports it otherwise as not run, not as passed.
core
- Every collection responds with
{items, next}, withnextpresent. - Without concurrent writes, following
nextuntilnullreturns every item exactly once. - An item that does not exist gives
404asproblem+jsonwithcode: "not_found". The path of an item with itsidchanged (another case, a leading zero) gives404unless an item has thatid; the path with a character of theidpercent-encoded (/books/%37) answers as the item’s own. - The discovery document’s
restepmatches the grammar of 1.1. Under the sameAccept-Language, its body is equal as a JSON value with and without credentials (unless it answers401without them) and, given two principals, between the two. Served only with credentials, it carriesCache-Controlwithprivateorno-store. - Every member the server adds to discovery outside Restep starts with
x-, and every key ofcollections,singletons,actions,relations,named_filtersandreasons, and every field that discovery declares, matches the grammar of names (3). - A
POSTto a collection that supports it, with a JSON body sent astext/plain, asapplication/x-www-form-urlencoded, withoutContent-Type, or asapplication/json; charset=latin1, gives415 unsupported_media_typeand creates nothing, and so does an empty body withoutContent-Type; withapplication/json; charset=UTF-8orcharset="utf-8"it is accepted, and an empty body withapplication/jsongives400 bad_request. Every2xxwith a JSON body carriesContent-Type: application/json. - Every
nextandhrefin a body is an absolute path or an absolute URI whose scheme ishttpsor the API root’s, and every absolute URI in aLocationorLinkheader has one of those schemes. - Where a collection does not declare
id_from, aPOSTwith anidgives422 invalid. Where it declares"client", one withoutidgives422with arequiredentry at/id; with"client"or"either", anidwith a character outside 3 gives422with an entry at/id, and repeating aPOSTthat succeeded, or reusing theidof a deleted item, gives409 conflictwith atakenentry at/idand creates nothing. - Each declared singleton answers
GETwith a JSON object, andPOSTandDELETEwith405; where it declaresmethods, itsAllowagrees with them. Its relationship objects carryhref, andincludeon it givesunsupported_parameter. - A subcollection declares
parent, and itspathtemplate has variables with distinct names and starts with its parent’spath. - Every unimplemented reserved parameter, and every form 5.3 does not define (
filter[a][b][c],fields[]), gives400 unsupported_parameter, on every method, unless an error that comes first in 5.4 applies: with valid credentials and no other fault, a missing item with an unsupported parameter gives404 not_found. - An unsupported method gives
405withAllow;HEADworks whereverGETdoes. Where discovery declaresmethodsoritem_methods, thatAllowagrees with them. - Where discovery declares
status,GETandHEADon it give200or503withCache-Control: no-store, or else401,403or429. - Every
invalid_parameterandunsupported_parameternames its parameter inparameter. - Where discovery declares a
createschema, aPOSTthat leaves out a property it requires gives422, and one that leaves out a top-level property with adefaultcreates an item with that value; where it declares a closedupdateschema, aPATCHwith a member the schema does not allow, even anullone, gives422, once the members 5.1 ignores are dropped. - Every error carries
type,title, astatusequal to the response’s, and acodefrom the list or derived from the IANA registry. - Every
reasonin a problem matches the grammar of names. If discovery declaresreasons, every problem with areason, also inbatchresults, carries a declared one with itscode. - A
PATCHwith{"author": {"id": "4", "extra": 1}}changes the link, does not storeextraand leaves both authors untouched, unless a declaredupdateschema rejects it. A relationship to anidthat does not exist gives422 invalidwith anunknownentry at itsid, and anhrefthat is not the path of an item of the target collection gives422. Given a principal that cannot see the related item, sending back the relationship as read, with another field changed, succeeds. - Merge Patch follows RFC 7396 (an array or scalar replaced by an object loses its old content), except that relationship objects are replaced whole (5.1) and language maps left with no translations read as
{}(3) and that, withinherit, deleting or changing an own field also changes its effective field (11.6), and a write that changesidgives422. - A
PATCHwith an item’s read-only fields as read changes neither its body nor itsETag, if any; another value inid, or in a top-level property the client can read that itsitemschema marksreadOnlydirectly inproperties, gives422 invalidwith aread_onlyentry at its pointer, changing nothing. - An error requested with an
Accept-Languagethe server does not offer, or a malformed one, gives the samecodeas without the header, never406or400because of it. Where the body of the discovery document or of an error changes between twoAccept-Languagevalues, both responses, the default language’s included, carryVary: Accept-Languageand, if they carry anETag, different ones. - With
Accept-Encoding: identity, theGETof an item gives the same body under anyAccept-Language(and, withwritesorcache, the sameETag). - Given a way to provoke them: a
429or503with aproblem+jsonbody leaves no effect, so repeating the request afterRetry-Aftercreates one item, not two. - A
401or403, other than those of the service status (4.4) and the OAuth metadata (11.5), carriesCache-Controlwithprivateorno-store. Given credentials: where aGETmade with them gets another status or body than the same request without them, or, given two principals, with the other’s, its response carriesCache-Controlwithprivateorno-store, also whencacheis not announced. - Given a session with credentials that a browser attaches on its own (cookies, HTTP authentication, a client certificate): a
POST,PATCHorDELETEwith them and anOriginthe server does not allow, an action with an empty body included, gives403 forbiddenand has no effect, also where the server sendsAccess-Control-Allow-Origin: *. - A request over a limit the server does not declare, such as an
inlist of thousands of values, gives the full result,invalid_parameternaming the parameter,413or414; never part of the result. - In an item, every field of
language_mapsis an object of strings with lowercase keys. WherePATCHis supported: an uppercase key gives422 invalidwith aformatentry at/name/ES; deleting an existing translation withnullkeeps the others, and putting it back restores it;{"name": null}leaves{}.
Evolution
- Whatever discovery lists in
deprecationscarriesDeprecationin the responses that use it, as 5.5 lists them; after itssunsetit responds as 5.5 says. Every notice has a knownkindand anannouncedinstant that does not change between two reads. - Comparing the discovery documents of two deployments of the same version, nothing declared disappears unless it was listed in
deprecationsand itssunsethas passed.
query
- Each declared filter returns only items that match it, comparing by the declared type (decimals exactly).
- An undeclared filter field, operator or sort key gives
unsupported_parameter; a value of the wrong type, a repeated parameter, or adurationvalue with years or months,invalid_parameter. - A
+in the query is read as a space:filter[f]=a+bandfilter[f]=a%20bgive the same page. - A declared named filter applies without operators; with an operator it gives
unsupported_parameter, and a switch with a value, or a typed one without a value or with one that does not match,invalid_parameter. None shares its name with a key offilter. - No
booleanfilter declares operators other thaneq,neandnull, and theidfilter declares none oflt,le,gtandge. sortorders and breaks ties stably across pages. A string field not listed incollationsfilters and sorts by code points; no key ofcollationsisidor a field not declared as a string.- No field that is a list, no path through a to-many relationship, and no path that ends in the
idof a subcollection’s item, is declared infilterorsort. - Repeating a parameter of
nextpercent-encoded in another way, or reordering parameters, gives the same page. limitabovemax_limitgivesinvalid_parameter, andlimiton a collection withoutmax_limitgivesunsupported_parameter; a tampered cursor, or one reused with other filters, another sort or another collection, givesinvalid_parameter; changinglimit,fields,includeorcountbetween pages keeps it valid.- No field of
language_maps, nor any path that ends in or goes through one, is declared infilterorsort; a declaredfield.tagfilter or sort reads only that key, and items without it are absent. fieldsreturns only those fields, plusidand members starting with_;fields=idis accepted.fieldsorincludeon aPOSTorPATCHgivesunsupported_parameter.- Given a principal that cannot read a field in some items: a declared filter on it matches none of them except with
nullset totrue, a sort on it puts them last, andtotalcounts only the items that principal can see. count=trueaddstotalwhencountis declared;count=trueandcount=falsegiveunsupported_parameterwhen it is not.
writes
- Repeating a
POSTwith the sameIdempotency-Keyafter the first one has finished returns the same response and creates nothing new. - The same key with another body, or on the same path with another query, gives
422 idempotency_mismatch; a malformed key, or one with parameters, gives400 bad_requeston aPOST. - The
ETagof a full item, asked for withAccept-Encoding: identity, is strong; every response whose body is one item, with or withoutfieldsand under anyAccept-Encoding, carries that item ETag in_etag, which two reads of an unchanged item give alike; a write ignores_members. - In a collection that declares
syncand whose items supportPATCHorDELETE, every listed item carries in_etagtheETagits ownGETreturns withAccept-Encoding: identityfor the same version. If-Matchwith an oldETaggives412, and a list that contains the current one succeeds; given a way to make two writes race with the sameIf-Match, one of them gets412.If-None-Matchwith the current one, weak or strong, gives412to a write and does not apply it.If-Matchwith an invented entity tag on aPOSTto a collection gives412and creates nothing.- A
PATCHorDELETEwithIf-Matchon an item that has just been deleted gives404, not412. - A write with
Prefer: return=minimalanswered without a body carries the item’sETag, unless it deleted the item. - The same request sent again while the first one is still running gives
409 request_in_progressor, once the first one finishes, its response; never a second effect. - Where a non-idempotent
POSTis accepted without credentials, the same request with the sameIdempotency-Keyand no credentials either is replayed as for any principal or, where discovery declares"anonymous": falseinidempotency, gets400 bad_requestwith an entry for the header, with no effect; a resource that requires the key does not giveidempotency_key_requiredto a request without credentials there.
cache
- Every response to a
GETorHEAD, errors included, carriesCache-Control; given credentials, with themprivateorno-store(as in core). - The
GETof a full item carries anETag, andIf-None-Matchwith it, weak or strong, gives304to aGETand aHEAD.
relations
- Relationships are objects with an
id, also withoutinclude, and every relationship is declared. One that can point to several collections carriestype; one whose target is a subcollection carries anhrefthat aGETanswers with that item. includeon a declared, expandable relationship fills the object; on any other,unsupported_parameter. Withquery, a dotted path infieldswhose relationship is not inincludegivesinvalid_parameter.
sync
- No collection declares
syncunlessprofileslists it. Every collection that declaressyncdeclaresidinfilterwithin;:changeson one that does not declare it gives404. :changesreports, in the lists 10 calls for, the creation, update and deletion of an item since the previousstate, and every page of a traversal carries the samestate; deleting an item mid-traversal does not make the traversal miss another one.- The response of
events, where declared, carriesCache-Control: no-store. Given a principal over its limit of open streams, a new one gets429 rate_limited.
actions
- A
POSTaction answers an empty body and{}alike; an undeclared action gives404 not_found, and a declared one with another method405withAllow; every action in_actionsis declared with the same method; no action is namedchanges. - With
writes, an action declared"idempotent": truedoes not reject a request for carrying a well-formedIdempotency-Key, with or without credentials, whateveridempotency.anonymoussays.
batch
- A repeated operation
id, a reference to a later operation, a nested batch, apathwith a scheme, an authority or dot-segments or to the event stream, or a header that 11.2 does not allow, gives400 bad_requestand runs nothing; more operations thanmax_operationsgive413; a batch with both faults gets either. A value inserted intopaththat is neither a valididnor an integer, such as../admin, gets424 not_executed. - With
"atomic": trueand one failing operation, every other result is424 not_executedand nothing persists. - Without
atomic, an operation whose reference cannot be resolved gets424 not_executed.
filter-expr
- An expression returns the same items as the equivalent
filter[…]parameters;ANDandORmixed at one level without parentheses, juxtaposition, or an expression together withfilter[…], giveinvalid_parameter; an undeclared field or operator givesunsupported_parameter.
query-method
- A collection whose
GETcarriesAccept-Queryanswers aQUERYas the equivalentGET, errors included; an unknown member, or a reserved parameter other thancursorin the URL, givesunsupported_parameter; the next page with anotherfilterorsortgivesinvalid_parameteroncursor.
oauth
- The metadata is at the URL RFC 9728 forms from the root, as JSON, without requiring credentials, with
resourceequal to the root and at least one authorization server. - The metadata does not give
401(and, as a recommendation, carriesCache-Control: public). - If the root requires credentials, its
401carries that absolute URL inresource_metadata; no401elsewhere points there. - Given a token without the scope a request needs: unless the resource’s existence is concealed, the request gets
403withcode: "forbidden"anderror="insufficient_scope"in the challenge.
inherit
- No collection declares
inheritunlessextensionslists it. Where one does andPATCHis supported: sending back withPATCHonly an item’s effective fields as read, without its own fields, changes neither its body nor itsETag;{"tax_rate_own": null}leaves the effective value equal to its source’s and, if there is_inherited, it names it; and a different value in the effective field gives422 invalidwith aread_onlyentry at/tax_rate, changing nothing.
12.2 Clients
These are the requirements on clients that the text makes, gathered by profile and extension. Each one is in the section cited, which prevails.
core
- It does not treat as a Restep 1 discovery document one whose
restepdoes not match the grammar or whose major version is not 1, nor assumescoreonly for one of another major version; for arestepvalue with a suffix, it does not assume conformance to any published version or to any other draft (1.1). - It does not use an experimental profile or extension unless
restepdeclares a version whose text of it the client implements (1.2). - It ignores fields and
_x_members it does not know, and does not reject a response because of an enum value that its stored copy of discovery or of a schema does not list (3). - It does not dereference a link whose scheme is neither
httpsnor the API root’s (3). - It sends the body of a
POSTto a collection, an action or a batch, and of aQUERY, withContent-Type: application/json(3). - It treats a response as a discovery document only if it is a JSON object with a string member
restep, and otherwise assumescoreonly; of severalservice-desclinks, it uses the first target that is a discovery document (4.2). - It ignores members of the discovery document it does not know, does not fail because of a value it does not know, and does not use a filter, action or notice whose
type,on,methodorkindit does not know (4.2). - It sends its credentials for the API only to URLs on the API’s origin, and fetches schemas and documents on other origins without them (4.3).
- It makes no request that is not safe, and sends no data to another origin, only because a text the API returned asks it to (4.3).
- It does not assume a path for the service status, such as
/health(4.4). - It does not send
idin aPOSTto a collection whoseid_fromhas a value it does not know, sends one whereid_fromis"client", and links an item of a subcollection by itshref(5.1). - It follows
nextas is, changing only the parameters 6.4 lets it change, sends a literal+in the query as%2B, and does not assume any order ofids (5.2). - It handles a
codeit does not know according to the class of thestatus, and areasonit does not know as itscode(5.4). - It ignores a singleton whose
pathis a URI template or that carriesparent(5.9).
query
- It does not assume code points for a field whose collation is
"server", nor reproduce that order or equality locally, and treats a collation value that is not a string, or that it does not know, as"server"(6.1). - It does not interpret or build cursors (6.4).
writes
- It does not rely on
Idempotency-Keyunless the server announceswrites(7.1).
sync
- It does not interpret or build a
state, and compares states only for equality (10). - It uses the
stateof a traversal’s first page assincefor its next sync, and calls:changesagain whilehas_moreistruebefore treating its copy as current. - It treats
createdandupdatedalike, and ignores anidindestroyedthat it does not have. - It tolerates repeated, merged and reordered events; on opening the stream and on every reconnection it calls
:changesfrom the last state it applied, and advances that state only after applying the changes, never on an event alone. - After a
401on the stream, it waits for valid credentials before opening it again.
batch
- Each operation has an
idunique in the batch, amethodand apath; it makes sure that no object in a body it did not write has$refas its only member (11.2).
query-method
- Its
QUERYURL carries no reserved parameter other thancursor, and for the next page it sends to thenextURL a body with the samefilterandsort(11.4).
inherit
- It treats a
fromin_inheritedthat it does not know as"hidden"(11.6).
The other profiles and extensions make no requirement of clients marked MUST or MUST NOT.
13. Security and privacy considerations
This section explains the risks of a Restep API and points to the requirements that address them, which are in the sections it cites. It adds no requirements. An API also has the risks of HTTP (RFC 9110, section 17), of JSON (RFC 8259, section 12), of problem details (RFC 9457, section 5) and of OAuth (RFC 9700); this section covers what Restep adds to them or decides about them.
13.1 Texts from the API are data
An agent that picks a tool from the discovery document puts descriptions, schema titles, reasons and error details into its prompt, and the data of each item with them. Whoever writes an item’s name, or controls the API, can write an instruction there. No agent built on a model can promise never to follow one, so 4.3 asks for what can be checked: a client makes no unsafe request, and sends no data to another origin, only because such a text asks it to, and an agent marks where the API’s text begins and ends in its prompt. A client also never grants an agent more permissions because a description asks for them. The names an API gives follow a grammar without spaces or punctuation (3), so they are safe as parts of tool names; an agent that adds a prefix (list_, get_), or whose tool registry ignores case or allows only shorter names, still has to resolve the collisions that result. A parameter in a problem is the parameter as received, which an attacker can write into a link: a client that shows it escapes it.
13.2 Credentials and origins
- A client sends its credentials only to URLs on the API’s origin (4.3). A discovery document can link schemas, documentation, a service status and, through
href, resources on any origin; anextlink could too. Fetched with the API’s credentials, any of them would hand those credentials to whoever controls the other origin. - Links use
httpsor the scheme of the API root, and a client does not follow one with another scheme (3), so a discovery document cannot send it tofile:ordata:. A client that follows links from a server, such as an explorer or a hosted agent, still has to keep them away from its own internal network. A schema on another origin is controlled by that origin, so a client does not resolve its$refelsewhere nor send itsdefaultwithout showing it to the user first (4.3). - A redirect to another origin is a URL on another origin. The Fetch Standard drops
Authorizationon such a redirect, but a library that copies headers by hand may not. - A token for the API is restricted to it: the server refuses one meant for another resource server (11.5), so a token leaked from another API does not work here.
13.3 Concealing existence
A 403 says that something exists. Restep lets an API conceal it instead:
- a resource whose existence the API does not reveal gives
404, not403, and a retired one410only if its existence is not concealed (5.4); a declared method, action or singleton that a principal may not use gives403or that404(4.2); - a relationship to an item the client cannot see keeps only its
id(9), which still reveals thatid, and itshrefandtypereveal its parent’sidand its collection; an API that must conceal even that leaves the field out for that principal, as any field it cannot read (6.3); - a write that links an item the client cannot see gets the same
422as one that links an item that does not exist (5.1), and the cache groups of a write name by its path only items the client can see (8); - a field that the principal cannot read and that discovery does not name is, for
fields, a field that does not exist (6.3), and the events of 10 are sent only when that principal’sstatechanges; - an inherited value whose source the client cannot see says
"hidden", never the source’s path (11.6); - in
:changes, lists follow what the client could see, and whether the server answers410 state_expireddoes not depend on concealed items (10); - a problem does not reveal what the principal could not otherwise learn (5.4).
The one place where Restep reveals existence on purpose is the taken entry of a client-chosen id (13.6). Response times can also tell an item that exists from one that does not; Restep does not ask for constant-time answers. An item’s ETag and a collection’s state may change when something the principal cannot see changes, which tells it that something did; a server that must conceal that computes them from what the principal can see.
13.4 Query oracles
A filter is a question about a value. If the server answered it with values the principal cannot read, whether an item is in the results would answer it, one bit at a time: filter[salary][lt]=50000, then 40000, finds a salary by bisection. Sorting gives the same answer by position, total by number, and filter[field][null] tells whether a value exists. The defences:
- A filter or sort key on a field the principal cannot read in an item treats it as absent there, a dotted path through a related item it cannot see included;
null, the order andtotalfollow from that (6.1, 6.5).filter-exprfollows the same rule (11.3). The403that 6.1 allows instead depends only on whether the field is readable in no item, which says nothing about values. - A named filter compares nothing that discovery declares, so the server decides what it reads; it does not select by values the principal cannot read unless its description states the criterion (6.1). “Has at least one copy free” can be public while the stock of each store is not. A named filter that takes a value never compares it with values the principal cannot read, whatever its description says: “salary above the given amount” would find each salary by bisection.
- An estimated
totalis still a count of what the principal can see (6.5): a server cannot take it from statistics of the whole table if some items are hidden from that principal. - A keyset cursor holds the sort values of the last item it returned; 6.4 asks that they not be readable (13.9).
13.5 Idempotency keys
A key belongs to a principal and a target (7.1). Requests without an authenticated principal share one, so every anonymous client shares one space of keys. Whoever guesses or sees another client’s key can then:
- send a different request under it first, so that the victim’s request gets
422 idempotency_mismatchand never runs; - send the same request, if it knows the whole body, and get the stored response, with what the server added to it: an
id, a timestamp, a secret or a link meant only for the sender; - learn from
Idempotent-Replayedthat someone already sent that exact request.
Clients generate keys from a random source and use each for one request (7.1). A server whose responses to anonymous writes carry anything only the sender may see can refuse keys without credentials: it declares so in idempotency and answers 400 (7.1), not 401, which would send the client after credentials the resource does not need. Keys travel in a header and end up in the same logs as the rest of the request.
13.6 Client-chosen identifiers
- Collisions. Two clients that pick the same
idget one item and one409. The server requires a format with enough entropy, and clients generate it at random (5.1). - Taking an
idfirst. If a client derives itsids from data (an email, an order number) or picks them in sequence, someone else can create an item with theidit will use, and the client’s own creation fails with409. - The
409as an oracle.takenanswers the same whether or not the client can see the item, so it does not reveal what the client may see; it does reveal that theidis or was in use (5.1). With randomids, guessing one is impractical. With a format that can be guessed, it tells whether an item exists, so a collection whose items are concealed from some principals (13.3) requires a format that cannot be guessed (5.1). The server can check the format but not the entropy: a well-formed version 4 UUID may still have been derived from data, so the protection holds only as far as every client generates itsids at random. - Time in the
id. Sortable identifiers (ULID, UUID version 7) carry the instant of their creation, and sequential ones carry how many items came before. Whoever sees theidlearns them. This holds as well for theids a server assigns. - Hashes of deleted
ids. A server may keep only a one-way hash of theids of deleted items (5.1). Where thoseids were derived from personal data, the hash does not anonymise them: whoever holds it can recompute it for each candidate, such as every email address on a list.
13.7 Browsers and cross-site requests
- A browser attaches cookies to requests that pages of other origins start. A request with a non-simple method or media type needs a CORS preflight first, which the server can refuse; a
POSTsent astext/plain,application/x-www-form-urlencodedormultipart/form-datadoes not. So a server requiresapplication/jsonon request bodies (3): a server that read a form as JSON would accept writes from any page. - An action with an empty body needs no preflight either (11.1). A server that accepts credentials a browser attaches on its own (cookies, HTTP authentication, client certificates) refuses every request that is not safe and carries them from an origin it does not allow, by
OriginorSec-Fetch-Site(5.8), which also covers browsers or paths the rules above miss;SameSitecookies are a second line. A page withReferrer-Policy: no-referrersendsOrigin: nulleven to its own origin, whichSec-Fetch-Sitetells apart. GETandHEADhave no effects (5.1), and an action can useGETonly if it is safe (11.1), so a link or an image cannot write.- CORS with credentials names the origin (5.8). A server that copies any request’s
OriginintoAccess-Control-Allow-Origintogether withAccess-Control-Allow-Credentials: truegives every site the user’s access. - A token in
Authorizationis not attached by the browser, so it is not exposed to cross-site requests; where a page keeps it is outside Restep.
13.8 Limits and abuse
- Declared limits:
max_limit(6.4),include_depth(9) andmax_operations(11.2). Going over them givesinvalid_parameter,unsupported_parameterand413. - Undeclared limits, such as the values of an
inlist, the number of filters or the size of an expression, giveinvalid_parameterwith the limit indetail, never a partial result (5.3). A client that syncs splits a longfilter[id][in]into several requests, or usesquery-method. Otherwise:414for a URL,413for a body,429for requests and event streams (10). - Some requests cost more than they look: an
includemultiplies the page by its depth, an exactcountscans (a server can declare"estimated"), a filter may have no index, an atomic batch holds locks, and the idempotency store and the change log grow withttlandretention. A server declares only what it can serve under load, and limits requests per principal and, for anonymous ones, per network address. 429and503with aproblem+jsonbody mean no effect, also when the API’s own gateway gives them (5.7), so a client that waits asRetry-Aftersays, or backs off with randomness, does not turn a failure into a storm of retries.
13.9 Cursors and states
- Clients do not interpret or build cursors (6.4). The server binds a cursor to its collection, filters and sort, and should bind it to the principal; it must when the cursor refers to results computed for that principal, such as a snapshot (6.4). Signing it shows when it was tampered with, and a tampered one gives
invalid_parameter, never another page. - A cursor goes in the
nextURL, and URLs end up in logs, in browser history and inReferer. 6.4 asks that it not carry item data that can be read, such as keyset values in clear; encrypting it, or keeping the position on the server, avoids that. - A
stateofsyncis opaque in the same way. The changes it leads to are computed for the principal who asks (10), so astatethat one principal received and another sends lists only what the second one could see.
13.10 Caching
- A shared cache that stored a response meant for one principal would give it to the next. Every server, with or without the
cacheprofile, marks a response that depends on credentialsprivateorno-store(5.1). RFC 9111 (section 3.5) already keeps shared caches from storing responses to requests withAuthorization, but not those sent with cookies or a client certificate. - A
404that conceals an item from one principal depends on credentials too, and so does its200for another. - The discovery document is the same for every principal (4.2), so it carries nothing that one principal may know and another may not. A shared cache may keep it only when it is served without credentials: one served only with credentials is
privateorno-store(4.2), or a cache would hand it to whoever has none. - With
cacheand responses whose CORS headers depend onOrigin,Vary: Originkeeps a shared cache from giving one origin’s answer to another (5.8). - RFC 9110 (section 13.2.1) has a server evaluate preconditions only when the request would otherwise succeed, so a
304never tells a principal without access that itsETagmatches.
13.11 Tokens
- The server refuses tokens meant for another resource server, and a client asks for one restricted to the API with a resource indicator (11.5, RFC 8707).
- Tokens in the query string end up in logs, in history and in
Referer, so the server should not accept them; a browser reads the event stream withfetch, which can sendAuthorization(11.5). DPoP binds a token to a key the client holds (RFC 9449). - Only the root’s
401points to the root’s metadata (11.5), because RFC 9728 has a client discard metadata whoseresourceis not the URL it asked for. - The metadata is served without credentials and lists the authorization servers and scopes; a
403for a missing scope leavesscopeout when naming it would reveal permissions (11.5).
13.12 Privacy
- Discovery. Whoever can read the discovery document learns every collection, singleton, field that can be filtered, action and reason the API declares. It is the same for everyone (4.2): an API that cannot publish that much requires credentials to read it and serves it
private(4.2), gives each tenant its own API root, or leaves out of its API what must stay unknown. - Errors. A
reasonsays why the request failed, not anything about others; its declaration inreasonsis public.detailanderrorsdo not reveal what the principal could not otherwise learn, nor internal details (5.4). The service status served without credentials says only whether the API can serve (4.4). - Replays.
Idempotent-Replayedsays that the same request was made before under the same principal; for the anonymous principal, possibly by someone else (13.5). - Identifiers. Sortable and sequential
ids reveal when an item was created and how many there are (13.6). - Queries in URLs. A filter such as
filter[email]=…puts personal data in the URL, and so in logs.query-methodputs it in the body instead. - Sync.
destroyedlists theids of items the client could see and no longer can; it reveals nothing about items the client never saw (10).
14. References
14.1 Normative
Needed to implement a requirement marked MUST or MUST NOT.
- RFC 2119 and RFC 8174: requirement key words. RFC 5234: ABNF, for the grammar of
restep(1.1). - RFC 9110: HTTP semantics (methods, status codes,
ETag,If-Match,If-None-Match,Accept-Language). RFC 9111: HTTP caching (Cache-Control). - RFC 6585:
428and429. RFC 4918:424. - RFC 8259: JSON. RFC 9457: Problem Details for HTTP APIs. RFC 6901: JSON Pointer.
- RFC 7396: JSON Merge Patch. RFC 5789:
PATCH. - JSON Schema 2020-12: the schemas of 4.3.
- RFC 3986: URIs. RFC 6570: URI templates.
- RFC 3339: dates and times.
- RFC 5646: language tags. RFC 4647: matching of language tags (lookup).
- RFC 8288: web linking (
Link,anchor,hreflang). RFC 8631:service-desc,service-docandstatus. RFC 5829: thesuccessor-versionandpredecessor-versionrelations. - RFC 9745 and RFC 8594:
DeprecationandSunset. - RFC 9651: Structured Field Values for HTTP, the syntax of
Idempotency-Key. - RFC 10008: the
QUERYmethod. - Server-Sent Events (HTML Standard): the event stream of 10.
- Fetch Standard: the
Originheader and the CORS protocol. - RFC 9728: OAuth 2.0 Protected Resource Metadata. RFC 6750: Bearer tokens and their challenges. RFC 9700: OAuth 2.0 security best current practice, for the audience of tokens. For the
oauthextension.
14.2 Informative
Background, sources of ideas and specifications that an implementation may use but that no requirement depends on.
- IETF draft The Idempotency-Key HTTP Header Field (revision 08, 22 October 2026). Restep defines the header’s syntax and meaning itself (7.1).
- IETF draft for the Health Check Response Format:
application/health+json(4.4). - RFC 6906: the
profilelink relation (4.1). RFC 9727:api-catalog. - RFC 7240:
PreferandPreference-Applied(7.3). - RFC 9875: HTTP Cache Groups (8).
- RFC 8414 and OpenID Connect Discovery 1.0: authorization server metadata. RFC 9449: DPoP. RFC 8707: resource indicators.
- Fetch Metadata Request Headers (W3C):
Sec-Fetch-Site(5.8). - RFC 8620: JMAP, changes and back-references between operations, which
syncandbatchfollow. - Google’s AIP-136 (actions), AIP-156 (singletons), AIP-158 (pagination) and AIP-160 (filter expressions).
- JSON:API 1.1.
Appendix A. Building forms from schemas
This appendix is not normative. It describes how a generic client can show a form for people from the schemas of 4.3, so that a server knows what its schemas will look like on screen.
- The form for a new item comes from
create; the form to edit one comes fromupdate, filled with the item as read. titleanddescriptionare a field’s label and help, in the language of 5.6.defaultis the value the form starts with. Increateit is also the value the server gives a field left out (4.3), so leaving it unchanged and leaving the field out mean the same. A schema on another origin is that origin’s, so itsdefaultis shown before it is sent (4.3).examplesare shown as examples and never sent.- A
oneOfofconstvalues, each with itstitle, gives the choices and their labels. format,maxLengthand the other assertions say how to enter a value and let the client check it before sending; the server checks it again.- A
readOnlyfield is shown and not edited; awriteOnlyone, such as a password, is never filled with a value read. - Fields appear in the order of
properties, which the server writes in the order it wants (4.3). - Layout, grouping and the controls used are the client’s.
A form whose starting values depend on the user or on the moment (today’s date, an inherited value) cannot come from discovery, which is the same for everyone; see Appendix B.
Appendix B. Future work
This appendix is not normative. These cases are left out of Restep 1. None needs an incompatible change: each can come as an addition in a minor version (1.1) or as a new extension, once implementations show how it should work. Until then, an API that needs one solves it its own way, with names outside those Restep reserves (5.3).
- Long-running operations:
202 Acceptedand an operation resource (as in AIP-151), so each API does not invent its own. Deferred because the operation’s shape, its cancellation and how it meetsIdempotency-Keyand actions need an implementation first. - Keeping filtered views in sync (as JMAP’s
queryChanges). Deferred because it needs to know which items a view held in the past, andsyncitself is still experimental. - Small additions: named views (
$view), aprevlink for backward paging, batch results streamed as they finish, and reusing aQUERYthrough theLocationthat RFC 10008 already defines. Deferred because no case has needed them yet. - Signed messages (RFC 9421, with
Content-Digestfrom RFC 9530 and keys published as JWKS, RFC 7517) for integrity between companies through intermediaries. Deferred because Restep 1 has no case that needs them: TLS covers the client and the server, and the events of 10 carry no data. A signature that expires would also give401to a retry before it reaches the idempotency store of 7.1. - An
openapiextension: what an OpenAPI description of a Restep API says (a description per operation, request bodies, errors asproblem+json) and how a checker holds it to the discovery document, which would still prevail. Deferred until the tools that translate between the two show what is worth requiring. - Consequential actions: marking actions whose effects cannot be undone or reach outside the API (a payment, an email), so a client can ask a person first, as MCP’s
destructiveHintandx-openai-isConsequentialdo. Deferred because a single flag does not tell “deletes data” from “charges someone”, and a vocabulary needs more cases. - Named filters inside
filter-expr, and a text search of Restep’s own, which would have to say how ordering by relevance combines withsortand with cursors. Deferred because that combination is not designed; today a search is a named filter of typestring(6.1). - A projection by language (
languages, already reserved), so clients need not receive whole language maps. Deferred because maps are small in the cases seen so far. - Sorting with language rules (CLDR collation): with code points,
sort=name.es-esputs “Ñora” after “Zanahoria”, and"server"(6.1) does not let a client know the order. The values ofcollationsother than"codepoint"and"server"are kept for collations named by Unicode tags (-u-co-,-u-ks-). Deferred because databases implement those tags unevenly. - Filters on fields that are lists and on paths through to-many relationships: whether they mean “some element” or “every element”, and a list type for discovery. 6.1 reserves the case, so it can be added without breaking anyone.
- Text direction (
dir, from the W3C’s Strings on the Web), which a language tag is not enough to infer. It would go in each field’s object inlanguage_maps, never changing the type of the values. Deferred because no implementation has needed it yet. - Declaring in advance which operations require
Idempotency-Key(7.1) orIf-Match(7.2), instead of learning it from a400or a428. Deferred because the error already tells a client what to do, and requiring either one is a breaking change anyway (5.5). - Inheriting values that are not scalars (11.6): a language map translation by translation, or an object field by field. Deferred until
inherititself has evidence. - Local times in a time zone (RFC 9557,
2026-03-30T10:00:00+02:00[Europe/Madrid]), declared likelanguage_maps. RFC 9557 describes fixed instants with zone information; a future local time whose instant follows changes to its zone’s rules is left to the application, and Restep would have to say which of the two such a field is. Deferred for that reason. - Soft deletion: what a
GETon a deleted item answers, how the trash is seen, restoring with the sameid, and purging. Under 10, an item that becomes visible again appears ascreatedorupdated, depending on the window. Deferred because restoring anidmeets the rule thatids are not reused (5.1). - Units of measure: a fixed unit per field, declared in discovery with UCUM codes without changing the value’s type, unlike a unit that varies per item, which goes with its value as an amount goes with its currency (3). Deferred because no implementation has needed it yet.
- Manual order: moving an item among others without rewriting all of them (fractional keys sorted by code point, or a
:moveaction withbeforeandafter). Deferred because both designs work and neither has been tried in a Restep API. - Forms with starting values that depend on the client or the moment (today’s date, the client’s shop, an inherited value), which discovery, the same for every client, cannot carry: a safe collection action such as
GET /orders:newthat returns the body of aPOSTalready filled in, without creating anything. Therestep-serverlibrary tries it asnew; deferred until that trial settles its shape. - Values as of a date (
$as_of): separating when a value applies from when it was recorded, and what it does to validators,stateand cursors. Deferred because it touches every profile. - Singletons under an item, such as
/stores/{store_id}/settings, and relationships,include, language maps and actions on singletons (5.9). Deferred because they need a way to declare a singleton’s parent, which 4.2 has only for collections. Clients of 1.0 already ignore a singleton with a template or aparent, so they can come in a minor version. - More kinds of retirement: lowering
include_depthorbatch.max_operations, and withdrawingsyncfrom a collection oreventsfrom the API (5.5). Today each needs a new major version. Deferred because no API has needed them; clients ignore notices of akindthey do not know (4.2), so new kinds can come in a minor version. - A version per experimental part: serving a new minor version of Restep while keeping the text of an earlier one for
syncorbatch, so a server need not move every experimental part at once and a client need not be updated for a part whose text did not change. Today the version inrestepdecides the text of every part (1.2). Deferred because it needs a new member of discovery and there is no second version yet to try it with. - Parameters of
GETactions (11.1): how a safe action that usesGETdeclares and receives its input, which today has no body and no declared parameters. Deferred until an action needs one. - How long the
ids of deleted items are kept (5.1): today for as long as the collection exists. A limit, such assync.retention, would bound the cost, but once anidwas forgotten the server could accept it again for a new item, while a client’s copy, kept for longer than that limit, still holds the old item under it. Deferred because it changes whatsynccan promise.
Appendix C. Changes
This appendix is not normative. It lists what each draft settled, the most recent first. The sections cited are those of this draft.
Draft 6
Incompatible with draft 5. What an API that followed draft 5 has to change:
- A
POSTto a collection, an action or a batch, and aQUERY, with a body of another media type, withoutContent-Type, empty withoutContent-Type, or with acharsetother than UTF-8, gives415, and so does aPATCHwith another media type; every2xxwith a JSON body saysapplication/json(3, 5.1). - The names that discovery declares and parameters carry, and every
reason, follow a grammar, and a field whose name does not cannot be declared (3, 5.4). Twoids are the same only code point by code point, and an item answers only its own path, compared segment by segment after percent-decoding (3). Links, in bodies and inLocationandLink, usehttpsor the API root’s scheme, and_x_members do not change between two reads of the same version of an item (3). - The discovery document is the same for every principal, equal as a JSON value, and
privateorno-storewhen served only with credentials; a declared method, action or singleton that a principal may not use gives403or404, never405orunsupported_parameter(4.2). - A subcollection’s template uses variables with distinct names and declares
parent, and a relationship to one of its items carrieshref(3, 4.2, 9). - A
POSTwith anidto a collection withoutid_fromcarries aread_onlyentry at/idin its422; another read-only field in aPOSTis ignored only with the value the item would get, and is dropped before validating against acreateschema (4.3); a field this principal may not change gives403, and one the item’s state does not let change409, both ordered with422(5.4); a relationship to an item that does not exist or that the principal cannot see gives422withunknown, unless it is sent back with its current value; a server that reuses theidof a deleted parent item does not let its subcollection take theids the old one had (5.1). - A response that depends on credentials carries
privateorno-storeon every server, not only with caching,401and403and resources outside Restep included (5.1). - Parameters are read after percent-decoding, whatever the order of different names, and a
+in the query is a space wherever the query is read after percent-decoding,parameterand the comparison of 7.1 included (5.2). countwith any value where it is not declared,fieldsorincludeon a write, and a bracketed form Restep does not define giveunsupported_parameter(5.3, 6.3, 6.5). A request over an undeclared limit givesinvalid_parameter, never part of a result (5.3).- Problems do not reveal what the principal could not otherwise learn (5.4).
- Every deprecation notice carries an
announcedinstant that does not change, and the six months count from it; acountnotice says withvaluewhether the count becomes estimated or goes; the responses that carryDeprecationare listed bykind; withdrawing a collection’ssyncor the API’seventsis a breaking change (5.5). 429and503go only to requests that had no effect, never to one whose effect the server cannot tell, also from the API’s own gateways (5.7).- A server that accepts cookies, HTTP authentication or client certificates refuses, with
403, a request that is not safe, carries them and comes from an origin it does not allow (5.8). - A singleton’s path is not one an item could have, and its relationship objects carry
href(5.9). - Filters and sorting treat a field the principal cannot read as absent, and a named filter does not select by such values unless its description states it, nor, if it takes a value, compare it with them; no field that is a list, no path through a to-many relationship and no path to the
idof a subcollection’s item is declared infilterorsort; abooleanfilter declares onlyeq,neandnull, and theidfilter no order operators; adatetimefilter value is never rounded (6.1). - A collection that accepts
limitdeclaresmax_limit, and a cursor that refers to results computed for a principal is bound to it (6.4). - The query counts towards “the same request” for
Idempotency-Key, which is a Structured Fields String without parameters and is ignored on other methods thanPOST; a server that refuses keys without credentials declares"anonymous": falseand answers400, not401, to aPOSTwithout credentials that carries one, except an idempotent action, which ignores it, and then requires the key of no request without credentials (7.1).If-MatchandIf-None-Matchare evaluated on aPOSTto a collection (7.2). - With
writes, every response whose body is one item carries_etag, whatever its content coding; a write to an item just deleted gives404, not410; a minimal response carries the item’sETag(7.2, 7.3). writesno longer bringsCache-Controland304: a server that gave them announcescacheas well; cache group names do not reveal items the client cannot see (8).- Only a collection that declares
sync, under thesyncprofile, answers:changes;eventsis relative to the API root, names a subcollection by its path relative to the API root, and sends nothing when the principal’sstatedoes not change (10). - Actions: an empty body is
{}; an undeclared action gives404;_actionslists only declared actions with their method; an idempotent action does not reject a well-formedIdempotency-Key, and ignores it without credentials whereanonymousisfalse(11.1). - A batch operation has a
pathrelative to the API root, without dot-segments, to a resource of Restep other than the event stream, into which a reference inserts only a valididor an integer, checked again after inserting it; it carries only the headers 11.2 lists, acts with the batch’s credentials, and takes noPrefer,If-MatchorIf-None-Matchfrom the batch request (11.2). - Inherited values are the
inheritextension, listed inextensions(11.6). - The URIs of the version, profiles and error types, and the
$idof the JSON Schemas, move tohttps://w3id.org/restep/1/, which redirects to the text: the profile link isLink: <https://w3id.org/restep/1/>; rel="profile", and an error’stypeishttps://w3id.org/restep/1/errors#followed by its code (4.1, 5.4). Thehttps://restep.wubytes.com/1/URIs are no longer identifiers, though the text is still read there (1.3).
What a client that followed draft 5 has to change:
- It sends
application/jsonwith request bodies (3), and a literal+in the query as%2B(5.2). - It does not assume, for a draft declared as
"1.0-draft.6", the guarantees of a published version, does not treat a document of another major version as Restep 1, nor fall back tocorewith it (1.1), and uses an experimental part only under a version whose text of it it implements (1.2). - It ignores members and values of discovery it does not know, and what they qualify (4.2), handles an unknown
reasonas itscode(5.4), ignores singletons with a template or aparent(5.9), does not interpret astate(10), and treats an unknownfromas"hidden"(11.6). - It sends credentials only to the API’s origin, does not follow links with other schemes (3), and makes no unsafe request only because a text of the API asks it to, which are now requirements (4.3).
- It does not send
idwhereid_fromhas a value it does not know, and links an item of a subcollection byhref(5.1). - It assumes no order of
ids, nor code-point order wherecollationssays"server"(5.2, 6.1). - It expects
Cache-Controland304on reads fromcache, not fromwrites(8), and a400to anIdempotency-Keysent without credentials whereidempotencysays"anonymous": false, except from an idempotent action, which ignores it (7.1). - In a batch, it keeps
$refout of data it did not write (11.2). - It recognises the profile link and Restep’s error types under
https://w3id.org/restep/1/, not underhttps://restep.wubytes.com/1/(4.1, 5.4).
Additions. A draft or candidate declares itself with a suffix in restep (1.1); profiles and extensions are stable or experimental (1.2); a licence, a rule on the use of the name and a process for changes (1.3); what separates a profile, an extension and a capability, and when two JSON values are equal (2); how long a client keeps the discovery document, and that it may require credentials (4.2); client-chosen ids with id_from and the taken entry (5.1); more kinds of retirement and a table of changes that were not classified (5.5); what can be retried (5.7); singletons, and resources outside Restep, which can be a PDF (5.9); collations (6.1); a 403 with parameter for a filter on a field the principal can read in no item (6.1); waiting for a request in progress instead of 409, and refusing anonymous idempotency keys, declared in idempotency.anonymous (7.1); the cache profile (8); a limit on event streams (10); checks for every extension, marked where a checker needs to be given something (12.1); client conformance (12.2); security and privacy considerations (13); normative and informative references (14); and these appendices. Date-based versioning in a header was closed: Restep 1 does not offer it (5.5). The order of errors was relaxed: 400 for the body, 415, 406 and 413 are no longer ordered among themselves, a 413 from a server placed in front of the API is outside the order, and replays go right before 428; the 403 for a field the principal may not change goes with 422, and step 1 keeps only the 403 that depends on neither the body nor the stored item (5.4).
Draft 5
A single, fixed rel="profile" link per response, to the version URI, so headers do not grow with what the server announces (4.1); _x_ members for extensions outside Restep (3); a link to the documentation for people (service-doc, 4.2); and a catalogue of domain reasons in discovery (5.4), at the root only, in which a reason has one code and, once declared, stays until the next major version; that a read-only field sent back with its current value is ignored, and a PATCH that would change no data leaves the item as it was, updated_at and ETag included (5.1); that in :changes an item’s visibility picks its list, so one created and destroyed within the window is reported in destroyed if the client could see it (10); inherited values, with a read-only effective field and an own field that is written, so that sending back what was read never pins an inherited value (11.6); and what a form takes from the schemas, with a binding default in create (4.3); and named filters, for criteria that do not compare a field, like the scopes of many ORMs (6.1). And three that came from building the tools: _etag in the collection items a client can write, required where the collection answers :changes (7.2); 409 request_in_progress for the same request while the first one is still running, which replaces 409 conflict in that case, so an API that followed draft 4 changes that code (7.1); and what a browser client needs from CORS (5.8).
Draft 4
How a client discovers authorization, with the oauth extension, without new error codes or scopes in discovery; that an idempotency key and a cursor belong to the principal, not to the token (7.1, 6.4); that api-catalog is optional (4.2); what helps agents and other generic clients use an API without trying it, as optional members of discovery (4.3): the methods of each collection, short descriptions, and JSON Schemas for items and request bodies; parameter on every invalid_parameter (5.3) and detail as a recommendation (5.4); several service-desc links (4.2); the method of an action, declared (11.1), so a GET action of an earlier draft now says "method": "GET"; how to find the service status, without a fixed path (4.4); and languages: the API’s texts follow Accept-Language (5.6), data never does, and translated text goes in language maps with lowercase tags, which can be filtered and sorted by exact tag (3, 6.1).
Draft 3
The order between errors (5.4); an item’s path (5.1); what a cursor is bound to (6.4); filters repeated in either form, ranges as two filters on one field, and null on booleans (6.1); invalidation with cache groups (8); and how a client resumes the event stream (10).
Draft 2
filter[field][op] is enough for query, and expressions stay in filter-expr; no dedicated media type, since application/json, application/problem+json and the profile URIs are enough; discovery declares field types only where Restep needs them (4.2); and there is no per-field cache policy in Restep 1, because each combination of fields is already its own URL for a cache.