JSON:API Spec Reference

JSON:API resource objects, relationships, links and error objects with field names.

Reference for the JSON:API v1.1 document structure — top-level members, resource objects, relationships, links and error objects — with each member's type, requirement and meaning.

What is JSON:API?

JSON:API is a specification for how a client should request and modify resources, and how a server should respond, using JSON. It standardises document structure, pagination, filtering, sparse fieldsets and relationships so clients and servers can interoperate without bespoke conventions.

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

  • data and errors MUST NOT both appear in one document.
  • A client-created resource MAY omit id; the server assigns it.
  • Use the included array for compound documents (related resources inline).
  • Error source.pointer is a JSON Pointer to the offending member.