Projects API
Base path: /api/projects. Requires the token auth cookie.
List projects
GET /api/projectsReturns every project owned by the authenticated user.
Create a project
POST /api/projectsCreates a project and its first environment in one call.
Body
{
"name": "Checkout Service",
"description": "Flags for the checkout flow",
"environment_name": "production",
"environment_icon": "globe",
"environment_url": "https://checkout.example.com"
}name and environment_name/environment_url are required. The project slug is derived from name (lowercased, spaces → hyphens). Writes two audit log entries (project + environment creation) and registers environment_url's origin for CORS. Returns 201 with the created project.
Update a project
PATCH /api/projects/:idBody: { "name": "New Name" } — regenerates the slug.
Delete a project
DELETE /api/projects/:idCascades to environments, flags, flag values, and audit logs at the database level (ON DELETE CASCADE).
List a project's environments
GET /api/projects/:id/environmentsReturns { project, environments, stats }.
Create an environment on a project
POST /api/projects/:id/environmentsBody
{ "name": "staging", "icon": "flask", "url": "https://staging.example.com" }name and url are required. Registers the new origin for CORS and writes an audit log entry. Returns 201 with { environment }.
Delete an environment
DELETE /api/projects/:id/environments/:envIdRemoves the environment's origin from the CORS allowlist and writes an audit log entry.
Create a flag on a project
POST /api/projects/:id/flagsBody
{
"key": "new-checkout-flow",
"name": "New checkout flow",
"type": "boolean",
"default_value": false,
"description": "Rolls out the redesigned checkout"
}type must be one of boolean, string, number, json. string and json default values are JSON-serialized before storage. Automatically creates a flag_values row (seeded with default_value) for every existing environment on the project, invalidates each environment's flag cache, writes an audit log entry, and pushes a flag_created SSE event to every connected SDK client for those environments. Returns 201:
{ "flag_id": "…", "envIds": [{ "environment_id": "…" }], "message": "Flag created" }Get a project's audit logs
GET /api/projects/:id/auditlogsClear a project's audit logs
DELETE /api/projects/:id/auditlogs