Feature Flags
Category: Operations ยท ๐ฆ 1 install
This page is generated from the Air Pipe marketplace. Browse it live to install into your organization.
A Postgres-backed feature flag service. Create, toggle, and check flags from any service or deployment pipeline without touching application code.
What's includedโ
| File | Purpose |
|---|---|
config.yml | AirPipe config with docs: true |
schema.sql | Feature flags table + seed data |
Endpointsโ
| Method | Path | Description |
|---|---|---|
GET | /flags | List all flags |
POST | /flags/check | Is a flag enabled? |
POST | /flags/create | Create a flag |
POST | /flags/toggle | Flip enabled state |
POST | /flags/set | Explicitly set enabled/disabled |
POST | /flags/delete | Remove a flag |
Setupโ
1. Run the schemaโ
psql $DATABASE_URL -f schema.sql
The schema seeds three example flags (new_dashboard, beta_api_v2, dark_mode).
2. Set managed variableโ
| Name | Value |
|---|---|
DATABASE_URL | your Postgres connection string |
Testingโ
BASE=https://your-airpipe-host
# List all flags
curl $BASE/flags
# Check a specific flag
curl -X POST $BASE/flags/check \
-H "Content-Type: application/json" \
-d '{"name": "new_dashboard"}'
# โ {"name":"new_dashboard","enabled":false}
# Enable it
curl -X POST $BASE/flags/toggle \
-H "Content-Type: application/json" \
-d '{"name": "new_dashboard"}'
# โ {"name":"new_dashboard","enabled":true,...}
# Check it again
curl -X POST $BASE/flags/check \
-H "Content-Type: application/json" \
-d '{"name": "new_dashboard"}'
# โ {"name":"new_dashboard","enabled":true}
Checking flags from your applicationโ
async function isEnabled(flagName) {
const res = await fetch('https://your-airpipe-host/flags/check', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: flagName })
});
const { enabled } = await res.json();
return enabled;
}
if (await isEnabled('new_dashboard')) {
// show new UI
}
Protecting these endpointsโ
Flag management endpoints should not be public. Add an API key check as the first action in each interface:
- name: ValidateApiKey
input: a|headers|
hide_data_on_success: true
assert:
http_code_on_error: 403
tests:
- value: x-api-key
is_equal_to: a|ap_var::FLAGS_API_KEY|
The read-only /flags/check endpoint can remain public if flags are not sensitive.
Notesโ
- Flag names are validated against
^[a-z0-9_]+$on creation to keep them consistent and URL-safe. flags/toggleflips the current state.flags/setis for when you need an explicit value (e.g. from a CI pipeline:enabled: falseon deploy,enabled: trueafter smoke tests pass).- All updates set
updated_at = NOW()so you have a change history you can query.