Skip to content
Flagpost Get started

Flagpost documentation

Everything you need to create a flag, evaluate it from your code and operate it safely in production.

Overview

Flagpost has two surfaces. The management API and dashboard are where you define flags, rules, segments and config values. The evaluation layer is what your applications talk to: the SDKs, which evaluate rules locally, and a small read-only endpoint for environments where an SDK is not an option.

Every REST example on this page uses the same base URL, and all requests must use HTTPS:

https://flagpost.keysgroup.site/v1

Requests and responses are JSON. Timestamps are UTC in ISO 8601 form. Flag keys are lowercase, may contain dots, dashes and underscores, and are limited to 120 characters.

Quickstart

This takes about ten minutes: create a key, install an SDK, and read a flag you created in the dashboard.

1. Create a server key

In the dashboard open Settings → Keys and create a server key for your development environment. Store it as an environment variable. Never commit it to a repository.

export FLAGPOST_SERVER_KEY="paste-your-key-here"

2. Install the SDK

# JavaScript and TypeScript
npm install @flagpost/sdk

# Python
pip install flagpost

# Go
go get flagpost.keysgroup.site/sdk/go

Java users add the labs.flagpost:flagpost-sdk artifact from the standard Java package repository. Kotlin, Ruby and Swift packages are listed in the SDK reference.

3. Evaluate a flag

JavaScript

import { Flagpost } from "@flagpost/sdk";

const fp = await Flagpost.init({
  sdkKey: process.env.FLAGPOST_SERVER_KEY,
  environment: "production",
});

const user = { key: "u_2093", plan: "pro", country: "US" };

if (fp.isEnabled("checkout.new-payment-sheet", user)) {
  showNewPaymentSheet();
}

const pageSize = fp.config("search.results_per_page", user, 20);

4. Flip it from the dashboard

Create the flag checkout.new-payment-sheet, switch it on for the development environment, and reload your app. The SDK receives the change over a streaming connection in about a second, so you do not need to restart anything.

Not seeing the change? Check that the key belongs to the same environment you edited, and that the context you pass contains a key. Rollouts bucket on that value.

Authenticating requests

Every request carries a key as a bearer token in the Authorization header. Keys belong to one environment, and the prefix tells you what a key can do.

Key types
KeyPrefixUse it forSafe in a browser?
Server keyfp_srv_Server SDKs. Downloads the full ruleset for local evaluation.No
Client keyfp_cli_Browser and mobile SDKs. Returns only the results for the context you send.Yes
Management keyfp_mgt_Creating and changing flags through the REST API, scoped by role.No
curl -s "https://flagpost.keysgroup.site/v1/flags?limit=3" \
  -H "Authorization: Bearer $FLAGPOST_API_KEY"

A missing or malformed key returns 401 with the code invalid_key. A valid key without the needed scope returns 403 with insufficient_scope.

Rotating keys

Create the new key first, deploy it, confirm traffic has moved on the key’s usage page, then revoke the old one. Keys can be given an expiry date when they are created. Scale workspaces can also restrict management keys to a list of IP ranges.

Concepts

Flag
A named switch with a type (boolean, string, number or JSON), a set of variations, and separate state in every environment.
Context
What you are evaluating for: usually a user, sometimes an organization or a device. A context has a required key plus any attributes you want to target on.
Rule
One or more conditions on context attributes, and what to serve when they match: a fixed variation or a percentage rollout. Rules are checked top to bottom and the first match wins.
Segment
A reusable group of contexts, defined by rules or by an uploaded list of keys, that any flag can target.
Environment
An isolated copy of every flag’s state, with its own keys. A change in staging never affects production.
Config
A flag that serves a string, number or JSON value instead of on and off, typically used for settings that change more often than releases.

Percentage rollouts hash the context key together with the flag key, so a user stays in the same bucket as you move the percentage up, and different flags bucket independently.

REST API

Endpoints
MethodPathDescription
GET/v1/flagsList flags in the project.
POST/v1/flagsCreate a flag.
PATCH/v1/flags/{key}/environments/{env}Change state, rules or rollout in one environment.
POST/v1/flags/{key}/killForce a flag off in one or more environments.
POST/v1/evaluateEvaluate flags for a context.
GET/v1/auditQuery the audit log.

Create and ramp a flag

curl -s -X POST https://flagpost.keysgroup.site/v1/flags \
  -H "Authorization: Bearer $FLAGPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "checkout.new-payment-sheet",
    "type": "boolean",
    "description": "Single-page payment sheet with saved methods",
    "tags": ["checkout", "q4"]
  }'
{
  "key": "checkout.new-payment-sheet",
  "type": "boolean",
  "environments": {
    "development": { "enabled": false },
    "staging": { "enabled": false },
    "production": { "enabled": false }
  },
  "created_at": "2026-11-18T09:12:44Z"
}

New flags start switched off everywhere. To start a rollout in production, patch that environment. Rules run in order, and fallthrough is what everyone else gets.

curl -s -X PATCH https://flagpost.keysgroup.site/v1/flags/checkout.new-payment-sheet/environments/production \
  -H "Authorization: Bearer $FLAGPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "rules": [
      { "if": { "attribute": "plan", "op": "in", "values": ["pro", "scale"] }, "serve": true },
      { "if": { "attribute": "country", "op": "in", "values": ["US", "CA"] },
        "rollout": { "percent": 25, "bucket_by": "key" } }
    ],
    "fallthrough": false,
    "comment": "Start the US and Canada ramp at 25%"
  }'

Supported operators are eq, in, not_in, gte, lt, starts_with, matches and in_segment. Version attributes compare as versions, not strings, so 4.10.0 is greater than 4.9.2.

Evaluate a context

Use a client key. The response contains only the flags you ask for, already resolved for that context.

curl -s -X POST https://flagpost.keysgroup.site/v1/evaluate \
  -H "Authorization: Bearer $FLAGPOST_CLIENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"key": "u_2093", "plan": "pro", "country": "US"},
       "flags": ["checkout.new-payment-sheet", "search.results_per_page"]}'
{
  "evaluated_at": "2026-11-18T09:15:02Z",
  "results": {
    "checkout.new-payment-sheet": { "value": true, "reason": "rule_match", "rule": 0 },
    "search.results_per_page": { "value": 25, "reason": "fallthrough" }
  }
}

The reason field explains the answer: rule_match, rollout, fallthrough, off, killed or error. It is the first place to look when a user sees something unexpected.

Kill switch

curl -s -X POST https://flagpost.keysgroup.site/v1/flags/payments.retry-v2/kill \
  -H "Authorization: Bearer $FLAGPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"environments": ["production"], "comment": "Elevated declines from an upstream provider"}'
{
  "key": "payments.retry-v2",
  "killed": ["production"],
  "pushed_to_connections": 412,
  "killed_at": "2026-11-17T17:30:09Z"
}

A killed flag serves its off variation to everyone until someone lifts the kill from the dashboard or with DELETE on the same path. Rules and rollout percentages are kept, so lifting it restores the previous state.

Audit log

curl -s "https://flagpost.keysgroup.site/v1/audit?flag=checkout.new-payment-sheet&since=2026-11-01T00:00:00Z&limit=2" \
  -H "Authorization: Bearer $FLAGPOST_API_KEY"
{
  "entries": [
    {
      "at": "2026-11-18T09:41:12Z",
      "actor": "user:u_102",
      "action": "rollout.update",
      "environment": "production",
      "before": { "percent": 25 },
      "after": { "percent": 50 },
      "comment": "Error rate flat at 25%, moving to half"
    }
  ],
  "next": "eyJvIjoyfQ"
}

SDK reference

Official SDKs
LanguagePackageTypeVersion
JavaScript / TypeScript@flagpost/sdkServer and browser4.3.1
PythonflagpostServer, async client3.1.0
Goflagpost.keysgroup.site/sdk/goServer2.6.2
Javalabs.flagpost:flagpost-sdkServer3.4.0
Kotlinlabs.flagpost:flagpost-kotlinMobile and server1.0.2
RubyflagpostServer2.2.4
SwiftFlagpostMobile2.2.0

All SDKs accept the same core options:

Core SDK options
OptionDefaultMeaning
sdkKeyrequiredServer or client key for one environment.
environmentfrom keyEnvironment name, used in logs and diagnostics.
streamingtrueReceive changes over a long-lived connection. When false the SDK polls.
pollInterval30 sPolling interval when streaming is off or unavailable.
bootstrapnoneA saved ruleset to start from, so the first evaluation never waits.
offlinefalseNever contact Flagpost. Only the bootstrap ruleset is used. Handy in tests.

When Flagpost is unreachable

Server SDKs keep evaluating against the last ruleset they received and reconnect in the background with jittered backoff. If an SDK has never connected and has no bootstrap data, it returns the default value you passed to the call and records an error reason, so a cold start during an outage degrades to your defaults rather than to an exception.

Webhooks

Webhooks notify your systems when something changes. Add an endpoint under Settings → Webhooks and choose the events you care about.

Webhook events
EventSent when
flag.updatedRules, state or rollout of a flag change in any environment.
flag.killedA flag is forced off with the kill switch.
rollout.step_completedA scheduled rollout reaches its next percentage.
environment.promotedA reviewed change is promoted to the next environment.

Each delivery carries an X-Flagpost-Event header and an X-Flagpost-Signature header containing an HMAC-SHA256 of the raw body, keyed with the endpoint’s secret. Verify it before trusting the payload:

import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(rawBody, header, secret) {
  const expected = "sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(header ?? "");
  return a.length === b.length && timingSafeEqual(a, b);
}

Respond with any 2xx status within ten seconds. Failed deliveries are retried up to eight times over about a day, with exponential backoff.

Limits and errors

Rate limits
SurfaceLimit
Management API, per key600 requests per minute
/v1/evaluate, per client key10,000 requests per minute
Audit log queries, per workspace60 requests per minute
Streaming connections, per server key50 concurrent

When you are over a limit the API returns 429 with a Retry-After header in seconds. Every response also carries X-RateLimit-Remaining. Errors share one shape:

{
  "error": {
    "code": "flag_not_found",
    "message": "No flag with key checkout.new-payment-shet exists in this project.",
    "request_id": "req_7c41a09e2d"
  }
}

Quote the request_id when you write to support@flagpost.keysgroup.site. It lets us find your request in seconds.