Start Here

REST API

Public control plane and evaluation endpoints for managing and evaluating FlagForge flags

Overview

The FlagForge REST API is the HTTP control plane served by @flagforge/api. Operators use server-authenticated endpoints to manage projects, environments, typed feature flags, segments, webhooks, and audit logs. Applications and the TypeScript SDK use client-authenticated endpoints to bootstrap flag definitions or evaluate flags for an evaluation context.

The API also serves an interactive Swagger UI at /docs and an OpenAPI 3.1 document at /openapi.json. Use these endpoints to inspect the live contract and try requests against a running local API.

Base URL

The verified local development server URL is:

text
http://localhost:4000

Append the versioned paths in the resource table to this base URL. For example, the project collection is http://localhost:4000/v1/projects.

Authentication

Management endpoints use Bearer server API keys, while evaluation and configuration endpoints use Bearer client API keys. The health and documentation endpoints require no authentication; see Authentication for the supported API-key schemes and authorization rules.

Note:

Use a srv_ server key for project-management requests and a cli_ client key for evaluation or SDK bootstrap requests. A missing, malformed, or invalid Bearer token is rejected by the API.

Resources

The following table lists the public routes exposed by the API. Paths beginning with /v1 are versioned API routes.

MethodPathResourceDescription
GET/healthHealthLiveness probe that also verifies database connectivity.
GET/docsDocumentationInteractive Swagger UI for the API contract.
GET/openapi.jsonDocumentationRaw OpenAPI specification.
POST/v1/projectsProjectsCreate a new project that owns environments, flags, segments, keys, webhooks, and audit logs.
GET/v1/projectsProjectsList projects visible to the authenticated server key.
GET/v1/projects/{projectId}ProjectsFetch a single project by ID.
DELETE/v1/projects/{projectId}ProjectsDelete a project and cascade related resources.
POST/v1/projects/{projectId}/environmentsEnvironmentsCreate an environment under a project. Environment keys are unique per project.
GET/v1/projects/{projectId}/environmentsEnvironmentsList environments for a project.
POST/v1/projects/{projectId}/flagsFlagsCreate a typed boolean, string, number, or JSON flag with named variations.
GET/v1/projects/{projectId}/flagsFlagsList flags for a project.
GET/v1/projects/{projectId}/flags/{flagKey}FlagsFetch a flag by key within a project.
PATCH/v1/projects/{projectId}/flags/{flagKey}FlagsUpdate flag metadata or variations.
DELETE/v1/projects/{projectId}/flags/{flagKey}FlagsDelete a flag by key.
PUT/v1/projects/{projectId}/flags/{flagKey}/targetingFlagsReplace per-environment targeting, including rules, defaultVariationKey, and offVariationKey.
POST/v1/projects/{projectId}/segmentsSegmentsCreate a reusable audience segment whose conditions can be referenced from targeting rules.
GET/v1/projects/{projectId}/segmentsSegmentsList segments for a project.
POST/v1/projects/{projectId}/webhooksWebhooksRegister a webhook URL for flag lifecycle events, with an optional signing secret.
GET/v1/projects/{projectId}/webhooksWebhooksList webhooks configured for a project.
GET/v1/projects/{projectId}/audit-logsAudit logsList flag change history, with optional flagKey and event filters for flag.created, flag.updated, flag.deleted, and targeting.updated.
POST/v1/evaluateEvaluationEvaluate all flags for an evaluation context using a client API key.
GET/v1/configEvaluationReturn flag definitions for SDK bootstrap and local evaluation.
GET/v1/flags/{flagKey}/evalEvaluationEvaluate one flag by key for a client-authenticated context.

Successful and failed requests use the route-specific schemas exposed in the OpenAPI document. API errors use a uniform envelope with an error code and message, such as:

json
{
  "error": {
    "code": "not_found",
    "message": "Flag \"checkout\" not found."
  }
}
Authentication

Configure Bearer server and client API keys for the appropriate endpoint groups.

OpenAPI Discovery

Use the running API's Swagger UI and OpenAPI JSON document to inspect request and response schemas.

Server-Side Evaluation

Compare bootstrap, single-flag evaluation, and bulk evaluation when local SDK evaluation is not used.