# Getting started

Five minutes from an invite to a flag your code reads.

## 1. Sign in

Flag is in an invite-only beta, so sign-ups are closed. Open the invite link from your email, then sign in with a
passkey, a password or (where set up) Google, Microsoft, GitHub, Apple or your company's SSO. Open the app at
[/app/](/app/). Org admins invite more people under [Settings → Members](/settings/org/members).

## 2. Create a flag

Each org starts with a **default** project and two environments: **production**, marked *critical*, and
**development**. Under **Flags**, choose **New flag** and start from a template:

| Template | Kind | Variations | For |
|---|---|---|---|
| Release | boolean, temporary | On / Off | shipping a feature behind a flag |
| Kill switch | boolean, permanent | Enabled / Killed | turning something off in an emergency |
| Operational setting | number, permanent | 100 / 50 | tuning a batch size or a timeout |
| AI Config | JSON, permanent | model settings (JSON Schema checked) | choosing a model, prompt and temperature |

Or choose the kind and variations yourself. Give it a **key**: that's what your code asks for, for example
`new-checkout`. New flags are **off** in every environment.

The same over the [REST API](/docs/api/), with an API key from [Settings → API keys](/settings/org/keys) (`$ORG` is
your org's slug):

```sh
curl -X POST https://flag.nightroll.app/api/v1/orgs/$ORG/projects/default/flags \
  -H "Authorization: Bearer $KEY" -H 'content-type: application/json' \
  -d '{"key": "new-checkout", "template": "release"}'
```

## 3. Get an SDK key

Under **Environments**, pick the environment and choose:

- **New server SDK key** (`srv_...`) for back ends. It is secret and shown only once: put it in your secret store.
  Server SDKs download the environment's whole configuration, encrypted with this key.
- or copy the **client-side ID** (`cli_...`) for browsers and mobile apps. It is public and only sees flags marked
  *available to client-side SDKs*, with targeted keys hashed.

Each key belongs to one environment. Rotate keys from the same page: the old ones keep working for as long as you
choose.

## 4. Read the flag from your code

### TypeScript (Node, Bun, Deno)

```sh
npm install @nightroll/flag
```

```ts
import { FlagClient } from '@nightroll/flag';

const flags = new FlagClient({ sdkKey: process.env.FLAG_SDK_KEY });
await flags.ready();

const user = { kind: 'user', key: 'user-123', email: 'ada@example.com', plan: 'pro' };
if (flags.boolVariation('new-checkout', false, user)) {
  // the new checkout
}
```

### Browsers and React

```ts
import { FlagClient } from '@nightroll/flag/web';
import { FlagProvider, useFlag } from '@nightroll/flag/react';

const flags = new FlagClient({ clientId: 'cli_...' });

function App({ user }) {
  return <FlagProvider client={flags} context={{ key: user.id, plan: user.plan }}><Checkout /></FlagProvider>;
}
function Checkout() {
  return useFlag('new-checkout', false) ? <NewCheckout /> : <OldCheckout />;
}
```

Mark the flag **available to client-side SDKs** (under *Variations & settings*) for browsers to see it.

### Any other language: OFREP

Any OpenFeature SDK with an OFREP provider works: point it at `https://flag.nightroll.app` with the header
`Authorization: Bearer <key>`. Or call it directly:

```sh
curl https://flag.nightroll.app/ofrep/v1/evaluate/flags/new-checkout \
  -H "Authorization: Bearer $FLAG_SDK_KEY" -H 'content-type: application/json' \
  -d '{"context": {"targetingKey": "user-123", "plan": "pro"}}'
```

More in [SDKs](/docs/sdks/).

## 5. Turn it on

Open the flag. In **Targeting**, pick **development**, tick *Targeting is on*, and add what you need:

- **Individual targets**: keys that always get a variation (your own user, say).
- **Rules**: for example *email ends with `@acme.com`* serves *On*; *is in segment `beta-testers`* serves *On*.
- **Default rule**: what everyone else gets, one variation or a percentage rollout (10% On, 90% Off).

Choose **Review & save**: Flag shows a dry run of exactly what changes before anything does. In production you also
see the **blast radius** (recent traffic, dependent flags, connected SDKs) and type `production` to confirm. Streaming
SDKs get the change within about a second.

Check it worked under **Evaluate** (paste a context, see the variation and every step that led to it) and **Insights**
(evaluations per hour by variation, from your SDKs).

## 6. Let your agent help

Create an API key, then:

```sh
claude mcp add --transport http flag https://flag.nightroll.app/mcp --header "Authorization: Bearer $KEY"
```

Or add `https://flag.nightroll.app/mcp` as a custom connector in claude.ai or Claude Desktop and approve it in the
browser. The [QuickStart](/quickstart) walks through it, with prompts to try.

## Next

- Protect production: **Environments → Settings** (critical, require approval).
- Release on a schedule: a flag's **Schedules**.
- Clean up: **Stale flags** and **Kill switches**.
- Automate: [REST API](/docs/api/).