Skip to content

Projects API

Base path: /api/projects. Requires the token auth cookie.

List projects

GET /api/projects

Returns every project owned by the authenticated user.

Create a project

POST /api/projects

Creates a project and its first environment in one call.

Body

json
{
  "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/:id

Body: { "name": "New Name" } — regenerates the slug.

Delete a project

DELETE /api/projects/:id

Cascades to environments, flags, flag values, and audit logs at the database level (ON DELETE CASCADE).

List a project's environments

GET /api/projects/:id/environments

Returns { project, environments, stats }.

Create an environment on a project

POST /api/projects/:id/environments

Body

json
{ "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/:envId

Removes the environment's origin from the CORS allowlist and writes an audit log entry.

Create a flag on a project

POST /api/projects/:id/flags

Body

json
{
  "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:

json
{ "flag_id": "…", "envIds": [{ "environment_id": "…" }], "message": "Flag created" }

Get a project's audit logs

GET /api/projects/:id/auditlogs

Clear a project's audit logs

DELETE /api/projects/:id/auditlogs