Skip to content

Flagsmith APIs Used

Lionel Serrao edited this page Nov 29, 2026 · 1 revision

Flagsmith APIs Used

Every Flagsmith feature Flag Responder relies on, and why. All verified against self-hosted Flagsmith 2.295.2. Paths are relative to /api/v1.

Authentication

Admin API calls send an organisation API key (Authorization: Api-Key …). A personal token (Token …) works too: the client tries the other scheme once if the first is refused. Checking what a user gets uses the environment's client-side key (X-Environment-Key), the same way your app's SDK does.

Reading

What for Endpoint
Projects, environments, flags, tags /projects/, /environments/?project=, /projects/{id}/features/, /projects/{id}/tags/
Each environment's defaults /environments/{key}/featurestates/
How many overrides each flag has /projects/{id}/features/?environment={envId} (num_segment_overrides, num_identity_overrides)
Every state of one flag: default, segment and identity overrides /features/featurestates/?environment=&feature=
Which segment each override belongs to /features/feature-segments/?environment=&feature=
Alerts /projects/{id}/feature-health/events/
A/B tests and results /environments/{key}/experiments/, …/{id}/, …/{id}/results/
What one user gets, and why POST /identities/ with transient: true (nothing is stored)

Writing

What for Endpoint
Toggle a default (normal environment) PATCH /environments/{key}/featurestates/{id}/
Toggle / kill in a versioned environment POST /environments/{id}/features/{fid}/versions/ with publish_immediately
Kill / restore a segment override PUT /features/featurestates/{id}/
Kill / restore an identity override PATCH /environments/{key}/identities/{iid}/featurestates/{id}/
A/B test traffic off / on PATCH /environments/{key}/experiments/{id}/rollout/
Pause / resume an A/B test POST …/experiments/{id}/pause/, …/start/
Create a missing flag POST /projects/{id}/features/
Feature Health provider for alerts GET/POST /projects/{id}/feature-health/providers/
Code References POST /projects/{id}/code-references/

Things learned the hard way

  • A/B tests use a hidden system segment (experiment-<id>-rollout). Writing to it directly returns 409 system_segment_modification. Use the experiment's rollout/ endpoint instead.
  • Pausing a test doesn't stop its traffic. It only stops new exposures counting. To stop users getting the variant, turn the rollout off too.
  • Versioned environments renumber states with every version. Remember overrides by segment id and identity id, never by state id.
  • "Hide disabled flags" makes Flagsmith leave an off flag out of what users get, rather than returning it as off.
  • The Grafana/Alertmanager provider matches the flagsmith_environment label to the environment's name exactly. Anything else, including a missing label, marks the flag unhealthy for the whole project.
  • Completing a test needs a rollout_decision field (for example "control").

Self-hosting bits

self-hosted/docker-compose.yml pins the open-source image and switches Experimentation on (EXPERIMENTATION_ENABLED). The demo's A/B test stores events in Flagsmith's own Postgres through a warehouse connection (/environments/{key}/warehouse-connections/), and gets them through the events API ($flag_exposure and purchase).

Clone this wiki locally