Skip to content

Segments & environments API

Segments are reusable, named audiences that flag rules can reference. Environments (e.g. production, staging) scope flag behavior. All endpoints require the management key vsk_live_….

Base URL: https://statskit.ai/api/v1

GET /segments

Scoped to an environment via ?env=.

Terminal window
curl "https://statskit.ai/api/v1/segments?env=production" \
-H "Authorization: Bearer vsk_live_..."

POST /segments

Define a segment by clause-based rules and/or included/excluded keys, then reference it from flag targeting.

Terminal window
curl -X POST https://statskit.ai/api/v1/segments \
-H "Authorization: Bearer vsk_live_..." \
-H "Content-Type: application/json" \
-d '{
"key": "beta_users",
"name": "Beta users",
"env": "production",
"rules": [ { "clauses": [ { "attribute": "beta", "op": "in", "values": ["true"] } ] } ]
}'

PATCH /segments/:key

Terminal window
curl -X PATCH https://statskit.ai/api/v1/segments/beta_users \
-H "Authorization: Bearer vsk_live_..." \
-H "Content-Type: application/json" \
-d '{ "name": "Beta cohort" }'

DELETE /segments/:key

Scoped to an environment via ?env=.

Terminal window
curl -X DELETE "https://statskit.ai/api/v1/segments/beta_users?env=production" \
-H "Authorization: Bearer vsk_live_..."

GET /environments

Terminal window
curl https://statskit.ai/api/v1/environments \
-H "Authorization: Bearer vsk_live_..."

POST /environments

FieldTypeNotes
keystringStable environment key
namestringDisplay name
Terminal window
curl -X POST https://statskit.ai/api/v1/environments \
-H "Authorization: Bearer vsk_live_..." \
-H "Content-Type: application/json" \
-d '{ "key": "staging", "name": "Staging" }'