# Superflag

> Feature flags for targeted rollouts and experiments. Change versioned config from the dashboard, CLI, or API; SDKs evaluate with a cached snapshot. Evaluate flags locally with @happycatlabs/superflag-node and @happycatlabs/superflag-react. Manage configuration with @happycatlabs/superflag-cli or the HTTP API.

## When to use Superflag

Use Superflag when an application needs feature flags, percentage rollouts, kill switches, or hosted experiments, and you want deterministic local evaluation instead of a render-critical remote check.

Do not use Superflag as a general analytics warehouse, a CMS, or a substitute for application authorization. It is a flag and experiment control plane.

How an agent should call Superflag:

1. Read this file, then https://superflag.sh/openapi.json.
2. Install @happycatlabs/superflag-cli (`npm install --global @happycatlabs/superflag-cli`) for management workflows.
3. Use @happycatlabs/superflag-node with an `sdk_` key on servers and @happycatlabs/superflag-react with a `pub_` key in browsers.
4. For hosted MCP, add `https://superflag.sh/api/mcp` to the agent's MCP settings. Sign in with the existing Superflag account, choose an app, environment, and read, write, or read and write permission, then approve. The browser returns to the agent. Review or disconnect grants in Settings → Agent connections. For an MCP host without browser connection, a scoped `cli_` Bearer token remains an advanced option. OAuth here applies to hosted MCP, not the CLI or general HTTP API.
5. Send `Authorization: Bearer <credential>` on other HTTP routes. Both account logins and scoped agent tokens use `cli_`; inspect effective access with `whoami --json`. Legacy `admin_` keys work only on supported app HTTP routes, not CLI discovery or hosted MCP. `sdk_` / `pub_` keys are for environment evaluation, not management. Hosted MCP provides reads to readable grants and `superflag_flags_mutate` to app- or environment-scoped `write` or `read-write` grants. Write calls require an immutable app ID, environment slug, flag key, operation, expected version, and idempotency key. A `write` grant cannot read flag values or reports.
6. Treat JSON errors as `{ error: { code, message, resolution? } }`. Frozen config 401s also keep a string `error` for older clients. Unknown `/api/v1/**`, `/api/ofrep/**`, and `/api/webhooks/**` paths return JSON `404`; wrong methods return JSON `405` with `Allow`. `/api/request` is the hosted docs proxy, not a Superflag API route. Monthly plan quotas are JSON `429` bodies, not IETF RateLimit headers.

## Docs

- [Feature flags for AI agents](https://superflag.sh/agents): headless setup, scoped worker access, typed SDKs, and MCP boundaries
- [Cloud-agent setup](https://superflag.sh/docs/cli/authentication#set-up-a-cloud-agent): provision and verify a worker token without sharing the account login
- [Docs home](https://superflag.sh/docs): conceptual and SDK documentation
- [Quickstart](https://superflag.sh/docs/quickstart): first flag and SDK install
- [HTTP API](https://superflag.sh/docs/api-reference/overview): auth, envelopes, route families
- [CLI](https://superflag.sh/docs/cli/installation): install @happycatlabs/superflag-cli

## API and CLI

- [OpenAPI 3.1](https://superflag.sh/openapi.json): public Superflag HTTP API
- [Capability contract](https://superflag.sh/api/v1/contract): live server capabilities
- [Versioned OpenAPI](https://superflag.sh/api/v1/openapi): same document under /api/v1
- CLI package: `@happycatlabs/superflag-cli` (executable `superflag`)
- Server SDK: `@happycatlabs/superflag-node`
- React SDK: `@happycatlabs/superflag-react`
- React Native SDK: `@happycatlabs/superflag-react-native`

## Trust and contact

- [Features](https://superflag.sh/features): what Superflag ships for feature decisions
- [About](https://superflag.sh/about)
- [Contact](https://superflag.sh/contact) — support@superflag.sh
- [Privacy](https://superflag.sh/privacy)
- [Terms](https://superflag.sh/terms)
- [Sitemap](https://superflag.sh/sitemap.xml)
- Optional full agent dump: [/llms-full.txt](https://superflag.sh/llms-full.txt)
