API
Get Flag
GET /v1/flags/{key} — retrieve a single flag by its key.
Request
GET /v1/flags/{key}Path parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The flag key (e.g. new-checkout-flow) |
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer sf_... |
Response
Returns the flag definition and its environment-specific configuration for the authenticated environment.
200 OK
{
"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 the flag hasn't been configured in this environment.
This is the same shape the SDK receives internally. The SDK caches this response and runs the evaluation engine locally.
404 Not Found
Returned when no flag with the given key exists in the project:
{
"error": "Flag not found"
}Example
curl -s -H "Authorization: Bearer sf_production_abc123..." \
https://api.switchflag.dev/v1/flags/new-checkout-flow | jqError responses
| Status | Body | Reason |
|---|---|---|
| 401 | {"error": "Unauthorized"} | Missing or invalid API key |
| 404 | {"error": "Flag not found"} | No flag with this key in the project |
| 429 | {"error": "Too many requests"} | Rate limit exceeded |