API
List Flags
GET /v1/flags — retrieve all flags for the authenticated environment.
Request
GET /v1/flagsHeaders
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sf_... |
Response
Returns all flags for the project, with environment-specific configuration for the authenticated environment. Flags are ordered alphabetically by key.
200 OK
{
"flags": [
{
"flag": {
"id": "clx...",
"projectId": "clx...",
"key": "new-checkout-flow",
"name": "New Checkout Flow",
"description": "Redesigned checkout experience",
"type": "boolean",
"defaultValue": false,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-15T10:30:00.000Z"
},
"environment": {
"id": "clx...",
"flagId": "clx...",
"environmentId": "clx...",
"enabled": true,
"rules": [
{
"id": "rule-1",
"attribute": "email",
"operator": "contains",
"value": "@acme.com",
"returnValue": true
}
],
"updatedAt": "2025-01-15T12:00:00.000Z"
}
}
]
}The environment field is null if no environment-specific configuration exists for this flag (meaning the flag hasn't been configured in this environment yet).
Example
curl -s -H "Authorization: Bearer sf_production_abc123..." \
https://api.switchflag.dev/v1/flags | jqError responses
| Status | Body | Reason |
|---|---|---|
| 401 | {"error": "Unauthorized"} | Missing or invalid API key |
| 429 | {"error": "Too many requests"} | Rate limit exceeded |