Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

JSON:API Flag

Security covered Under active development 5 sites

This module enhances JSON:API by exposing the flagging status of entities. It adds computed fields to responses, allowing clients to see flagging counts and which flags a user has applied. Additionally, it provides dedicated endpoints for flagging and unflagging entities, simplifying interactions with the API.

Exposes Flag state over JSON:API.

Core JSON:API already exposes flagging entities, so creating and deleting flaggings needs no contrib module. What it cannot do is tell you the flag state of the entity you just asked for. This module adds computed fields so a client fetching an article gets that state in the same response, instead of one filtered request per flag, and adds two endpoints that flag and unflag without assembling a flagging document by hand.

Computed fields

These appear on every content entity, and on user entities, and respect the permissions of the account making the request.

  • flaggings_current_user, the flag ids the current user has applied to this entity
  • flag_counts_entity, flag id mapped to how many times the entity is flagged
  • user_flaggings, on user entities, the flags that user has applied

Endpoints

POST   /jsonapi/flag/{flag}/{entity_id}
DELETE /jsonapi/flag/{flag}/{entity_id}

{flag} takes a flag machine name or a uuid, and {entity_id} an id or a uuid. Both routes accept every authentication provider enabled on the site. POST requires the flag permission and DELETE requires the unflag permission, and the entity being flagged must be viewable by the requesting account.

Before the endpoints will answer

Core sets jsonapi.settings.read_only to TRUE by default, which makes both endpoints return 405. Turning it off affects every JSON:API write on the site, not only this module's, so weigh it rather than flipping it. The README covers this and the rest in full.

Drupal 10–11

Ask your assistant about JSON:API Flag

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Aug 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
2.0.0 Stable 10–11 Aug 28, 2026