API Overview

The Flagify REST API lets you manage flags, environments, and targeting rules programmatically. All SDK operations are backed by this API.

Base URL

https://api.flagify.dev/v1

Authentication

All API requests require an API key passed via the X-API-Key header:

curl https://api.flagify.dev/v1/flags \
  -H "X-API-Key: sk_prod_AbC12xYz_your-secret-key"

API key format

Flagify API keys follow a structured format:

{type}_{environment}_{keyId}_{secret}
SegmentValuesDescription
typepk, skpk = publishable (client-side), sk = secret (server-side)
environmentdev, staging, prodThe environment this key is scoped to
keyIdrandom stringUnique key identifier
secretrandom stringCryptographic secret

Examples:

sk_prod_AbC12xYz_dGhpcyBpcyBhIHNlY3JldA     # secret key, production
pk_dev_XyZ98aBc_Y2xpZW50LXNpZGUta2V5         # publishable key, development

Flag endpoints

MethodPathDescriptionKey type
GET/v1/flagsList all flags in the projectsk
POST/v1/flagsCreate a new flagsk
GET/v1/flags/:keyGet a specific flagsk
PATCH/v1/flags/:keyUpdate a flagsk
DELETE/v1/flags/:keyDelete a flagsk

Evaluation endpoints

Used by the SDKs. These are the only endpoints a publishable (pk_*) key can call.

MethodPathDescriptionKey type
GET/v1/eval/flagsFetch all flags for the environment bound to the keypk or sk
GET/v1/eval/flags/:keyFetch a single flagpk or sk
POST/v1/eval/flags/evaluateEvaluate all flags for a user context (batch, used by SDK sync)pk or sk
POST/v1/eval/flags/:key/evaluateEvaluate a single flag for a user contextpk or sk
GET/v1/eval/streamSSE stream of flag changespk or sk

Segment & targeting endpoints

Segments are reusable user groups; targeting rules bind flags to segments or inline conditions per environment.

MethodPathDescriptionKey type
GET/v1/projects/:projectId/segmentsList segments in a projectsk
POST/v1/projects/:projectId/segmentsCreate a segmentsk
DELETE/v1/segments/:idDelete a segmentsk
GET/v1/flag-environments/:flagEnvId/targetingList targeting rules for a flag in one environmentsk
PUT/v1/flag-environments/:flagEnvId/targetingReplace all targeting rules for a flag in one environmentsk

Environment & API key endpoints

MethodPathDescriptionKey type
GET/v1/environmentsList environmentssk
GET/v1/environments/:id/api-keysList API keys for an environmentsk
POST/v1/environments/:id/api-keysGenerate a new API key pairsk
POST/v1/environments/:id/api-keys/rotateRotate API keyssk
POST/v1/environments/:id/api-keys/revokeRevoke all active API keys for an environmentsk

Audit log endpoints

Every write (flag create/toggle, key generation, membership change, billing action, …) is recorded in a workspace-scoped audit log.

MethodPathDescriptionKey type
GET/v1/workspaces/:wid/auditList audit events (paginated)sk

Query parameters:

ParamDescription
cursorOpaque pagination cursor from a previous response
limitPage size (default 50)
actionFilter by action name (e.g. flag.toggled, key.generated)
resourceTypeFilter by resource type (e.g. flag, apikey, membership)
actorUserIdFilter by the user who performed the action
projectIdFilter to events that belong to a single project

Billing endpoints

Workspace-scoped billing operations. All require owner/admin role on the workspace.

MethodPathDescriptionKey type
GET/v1/workspaces/:wid/billingGet current plan, usage, and Stripe statussk
POST/v1/workspaces/:wid/billing/checkoutCreate a Stripe Checkout session for a plan upgradesk
POST/v1/workspaces/:wid/billing/portalCreate a Stripe Customer Portal sessionsk
POST/v1/workspaces/:wid/billing/preview-changePreview the proration for a plan changesk
POST/v1/workspaces/:wid/billing/change-planApply a plan change (upgrade/downgrade)sk
POST/v1/workspaces/:wid/billing/apply-retention-discountApply a retention discount during a cancellation flowsk
POST/v1/workspaces/:wid/billing/downgrade-feedbackRecord feedback captured during a downgradesk
POST/v1/webhooks/stripeStripe webhook receiver (signed by Stripe — not called directly)none

Request format

All request bodies use JSON. Set the Content-Type header:

curl -X POST https://api.flagify.dev/v1/flags \
  -H "X-API-Key: sk_prod_AbC12xYz_your-secret-key" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "new-feature",
    "type": "boolean",
    "description": "Enable the new feature"
  }'

Response format

All responses return JSON with a consistent structure:

{
  "data": {
    "key": "new-feature",
    "type": "boolean",
    "enabled": false,
    "created_at": "2025-01-15T10:30:00Z"
  }
}

Errors follow the same structure:

{
  "error": {
    "code": "not_found",
    "message": "Flag 'nonexistent' not found"
  }
}

Rate limits

PlanRequests per minute
Free60
Pro600
EnterpriseCustom

Rate limit headers are included in every response:

X-RateLimit-Limit: 600
X-RateLimit-Remaining: 594
X-RateLimit-Reset: 1705312800