Skip to main content

Direct API Access

We have a Postman Collection that you can use to play around with the API and get a feel for how it works.

Run in Postman

You can also access the API directly with tools like curl or httpie, or with clients for languages that we do not currently have SDKs for.

API Explorer

You can view the API via Swagger at https://api.flagsmith.com/api/v1/docs/.

Environment Key

Publicly accessible API calls need to have an environment key supplied with each request. This is provided as an HTTP header, with the name X-Environment-Key and the value of the environment API key that you can find within the Flagsmith administrative area.

Curl Example

curl 'https://api.flagsmith.com/api/v1/flags/' -H 'X-Environment-Key: TijpMX6ajA7REC4bf5suYg'

httpie Example

http GET 'https://api.flagsmith.com/api/v1/flags/' 'X-Environment-Key':'TijpMX6ajA7REC4bf5suYg'

Private Endpoints

You can also do things like create new flags, environments, toggle flags or indeed anything that is possible from the administrative front end via the API.

To authenticate, get a token by logging in with an account credentials:

curl 'https://api.flagsmith.com/api/v1/auth/login/' \
-H 'content-type: application/json' \
--data-binary '{"email":"<ACCOUNT EMAIL ADDRESS>","password":"<ACCOUNT PASSWORD>"}'

{"key":"<KEY HASH>"}

Then use this token for subsequent requests. For example, to create a new evironment:

curl 'https://api.flagsmith.com/api/v1/environments/' \
-H 'content-type: application/json' \
-H 'authorization: Token <TOKEN FROM PREVIOUS STEP>' \
--data-binary '{"name":"New Environment","project":"<Project ID>"}'

You can find a complete list of endpoints via the Swagger REST API at https://api.flagsmith.com/api/v1/docs/.

Useful SDK Endpoints

Send Identity with Traits and receive Flags

This curl command below will perform the entire SDK workflow in a single call:

  1. Creating an Identity
  2. Setting Traits for the Identity
  3. Receiving the Flags for that Identity
curl --request POST 'https://api.bullet-train.io/api/v1/identities/' \
--header 'X-Environment-Key: <Your Env Key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"identifier":"identifier_5",
"traits": [
{
"trait_key": "my_trait_key",
"trait_value": 123.5
},
{
"trait_key": "my_other_key",
"trait_value": true
}
]
}'