The JSON:API v1.1 document structure
JSON:API standardises the shape of request and response bodies: where the primary data lives, how errors are returned, how resources link to one another, and which members are allowed at each level. This reference covers the top-level document, resource objects, relationships, links and error objects.
How it works
Every JSON:API response is a single document. At the top level it carries
data, errors or meta (at least one, and data/errors are mutually
exclusive):
{
"data": {
"type": "articles",
"id": "1",
"attributes": { "title": "JSON:API" },
"relationships": {
"author": {
"links": { "self": "/articles/1/relationships/author" },
"data": { "type": "people", "id": "9" }
}
},
"links": { "self": "/articles/1" }
}
}
A resource object is identified by its type plus id. Relationships hold
resource linkage (resource identifier objects) and links. Error objects appear
in an errors array, each describing one problem with members like status,
code, title, detail and source.
Tips and notes
dataanderrorsMUST NOT both appear in one document.- A client-created resource MAY omit
id; the server assigns it. - Use the
includedarray for compound documents (related resources inline). - Error
source.pointeris a JSON Pointer to the offending member.