Skip to content

Flags API

Base path: /api/flags. Requires the token auth cookie. (Flags are created via POST /api/projects/:id/flags.)

Get a flag's values across environments

GET /api/flags/:flagId/environments

Returns one row per environment the flag exists in, joined with environment metadata:

json
[
  {
    "id": "…",
    "flag_id": "…",
    "environment_id": "…",
    "is_enabled": true,
    "rollout_percentage": 25,
    "targeting_attribute": "userId",
    "targeting_value": "internal-beta",
    "targeting_return_value": null,
    "updated_at": "2026-08-01T12:00:00.000Z",
    "environment_name": "production",
    "environment_slug": "production",
    "environment_icon": "globe"
  }
]

Toggle a flag on/off in an environment

PATCH /api/flags/:flagId/environments/:envId/toggle

Body: { "is_enabled": true }

The lightweight on/off switch — only touches is_enabled, leaving rollout/targeting untouched. Updates the Redis flag cache in place, pushes a flag_updated SSE event, and writes an audit log entry (flag_toggle).

Edit a flag's full value in an environment

PATCH /api/flags/:flagId/environments/:envId

Body

json
{
  "is_enabled": true,
  "rollout_percentage": 50,
  "targeting_attribute": "plan",
  "targeting_value": "enterprise",
  "targeting_return_value": "premium-tier"
}

Use this for rollout percentage and targeting rule changes, not just the on/off state. Invalidates (rather than patches) the environment's flag cache, writes an audit log entry with old/new values, and pushes a flag_updated SSE event.

Delete a flag

DELETE /api/flags/:flagId

Deletes the flag (cascading its flag_values rows), invalidates the flag cache for every environment it existed in, writes an audit log entry, and pushes a flag_deleted event to each affected environment's SDK clients.

json
{ "envIds": [{ "environment_id": "…" }], "success": true, "message": "Flag deleted" }

Get a flag's audit history

GET /api/flags/:flagId/audit

Returns the audit log entries scoped to this flag, filtered to the current project and requesting user.