Drupal content entities and fields flow through a JSON:API boundary to a separate frontend, with a decision branch for reads and writes

Editorial illustration; the architecture and interface are representative and are not a live Drupal installation.

When a team wants a React frontend, a mobile app, or an external service to pull content from Drupal without rebuilding editorial workflows, enabling the core jsonapi module (drush en jsonapi) is usually the fastest starting point. It exposes Drupal’s entity types and bundles out of the box with zero custom PHP.

The real architectural question is not “Can Drupal return JSON?”—it is “Does our requirement actually map to Drupal entities and field-level permissions?” The Drupal documentation draws a sharp line between JSON:API and the more configurable core REST module. Respecting that line before writing frontend code saves a lot of painful refactoring later.

What JSON:API gives you out of the box

Drupal JSON:API exposes nodes, media, files, taxonomy terms, and users along predictable paths such as /jsonapi/node/article for collections and /jsonapi/node/article/{uuid} for individual items. Because it follows the JSON:API specification rather than an ad-hoc response shape, frontend developers get consistent pagination, sorting, filtering, and relationship includes without inventing a custom schema for every content type.

For example, fetching the latest 10 published articles with only the fields a card listing needs—plus their image and tags—looks like this:

GET /jsonapi/node/article?filter[status]=1&sort=-created&page[limit]=10&include=field_image,field_tags&fields[node--article]=title,path,created,field_image,field_tags HTTP/1.1
Accept: application/vnd.api+json

Using fields[...] (sparse fieldsets) and include= keeps payloads small and avoids over-fetching every unused field on the node.

Designing the boundary before writing code

Start by listing the actual screens and actions the frontend needs, not just the endpoints. “Show the latest ten articles and their hero images” maps cleanly to entity retrieval. “Approve an article for legal review, log an audit entry, and notify the editor” is a business workflow, not a simple entity fetch.

Once you know what belongs in entities, lock down what is exposed. By default, enabling jsonapi exposes all entity types and bundles that a user has permission to view—including user entities or internal taxonomy vocabularies you might never intend a public frontend to query. Two practical guardrails help here:

  1. Restrict write operations if you only need content delivery. In jsonapi.settings.yml (or under /admin/config/services/jsonapi), keep “Accept only JSON:API read operations” enabled (read_only: true) unless the decoupled client genuinely creates or updates entities.
  2. Use jsonapi_extras when you need cleaner control. If you want to disable specific resource types, rename ugly field_... machine names, or strip internal metadata from public responses, the contributed jsonapi_extras module gives you that control without breaking the spec.

Test every endpoint against real roles—especially anonymous—rather than testing while logged in as User 1 or an administrator. A field that renders fine in your browser session might return 403 Forbidden or disappear from relationships for an anonymous visitor if file or media permissions are misconfigured. Also test missing images, unpublished references, and deleted taxonomy terms so the frontend handles null relationships gracefully.

Entity writes vs. business actions

JSON:API supports POST, PATCH, and DELETE subject to Drupal access control, which works well for straightforward CRUD—like saving a user profile field or updating an article body. Where teams get into trouble is forcing multi-step business logic into a chain of PATCH requests.

If an action needs to cross multiple entities atomically, trigger external webhooks, or enforce rules that go beyond field validation, write a dedicated custom ControllerBase route or a core REST resource instead. Keeping business actions in an explicit endpoint makes validation, logging, and error handling far clearer than hiding side effects inside hook_entity_presave() triggered by a generic PATCH.

Revisions, translations, caching, and logging

Editorial sites rarely have just one version of a page. You may have a published revision, a draft revision, and multiple language prefixes (such as /en/jsonapi/... and /ms/jsonapi/...). Decide early which revision state the frontend is allowed to read, and test translated content with fallback languages explicitly rather than assuming English behaviour applies everywhere.

For performance, treat caching as part of the API contract. Drupal attaches cache tags (like node:42 or node_list:article) to JSON:API responses, which works well with internal page cache, Varnish, or Cloudflare when configured properly. Decide how fresh each listing needs to be—a news homepage might tolerate a short cache lifetime, whereas a breaking correction notice needs immediate tag invalidation.

When things fail, log HTTP status codes, resource types, and correlation IDs so you can distinguish an unauthorised 403, a malformed 400 filter, and a genuine 500 error—without dumping bearer tokens or personal payloads into log files.

JSON:API vs. core REST or custom controllers

Choose JSON:API when your main goal is predictable, standards-based access to Drupal’s content model. Choose core REST or a custom controller when you need non-entity data sources, aggregated dashboard payloads, multi-entity transactions, or auth-adjacent flows like registration and password resets.

Mistakes to avoid in production

  • Leaving read_only: false enabled when the decoupled frontend only reads content.
  • Exposing user, revision, or internal taxonomy endpoints to anonymous traffic without auditing permissions.
  • Mimicking a multi-step approval workflow with repeated client-side PATCH calls.
  • Hardcoding development UUIDs or assuming JSON field order is guaranteed.
  • Ignoring null relationships when referenced media or terms are unpublished.

For related guides that complement this checklist, see:

JSON:API shines when your Drupal content model is already clean and well-structured. Start with a small read-only slice, verify permissions across real roles and translations, and keep custom business workflows in explicit endpoints rather than bending JSON:API into an application engine.

Sources