BETA
Skip to content

Quickstart ​

Create and evaluate your first feature flag in under five minutes. This guide walks you through getting an API key, creating a project, adding a flag, and evaluating it from your app.

Prerequisites ​

  • A Krafter account (invite-only -- request access at app.krafter.dev)
  • An API key with flags:write scope

Step 1: Get Your API Key ​

  1. Log in to the Krafter dashboard.
  2. Navigate to Settings > API Keys.
  3. Click Create API Key and give it a descriptive name (e.g., "Flags Backend").
  4. Select the flags:write scope (includes read access).
  5. Copy the generated key. It starts with kr_live_ and will only be shown once.

WARNING

Store your API key securely. Do not commit it to version control, and do not put it in client-side code — a platform key is scoped to your whole team. For browsers and mobile apps use a client key instead (Step 5).

Step 2: Create a Project ​

Projects organize your flags by application or team. Each project has its own set of environments.

bash
curl -X POST https://app.krafter.dev/api/v1/flags/projects \
  -H "Authorization: Bearer kr_live_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My App"
  }'
json
{
  "data": {
    "id": "b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e",
    "name": "My App",
    "created_at": "2025-01-15T10:00:00Z"
  }
}

Save the project id -- you will need it when creating flags and evaluating them.

Step 3: Create a Feature Flag ​

Create a boolean flag to gate a new feature:

bash
curl -X POST https://app.krafter.dev/api/v1/flags \
  -H "Authorization: Bearer kr_live_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e",
    "key": "new_checkout",
    "name": "New Checkout",
    "flag_type": "boolean",
    "default_value": false,
    "description": "Enable the redesigned checkout flow"
  }'
json
{
  "data": {
    "id": "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
    "project_id": "b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e",
    "key": "new_checkout",
    "name": "New Checkout",
    "flag_type": "boolean",
    "default_value": false,
    "enabled": false,
    "description": "Enable the redesigned checkout flow",
    "created_at": "2025-01-15T10:05:00Z"
  }
}

The flag is created but disabled by default. You can toggle it on when you are ready.

Step 4: Evaluate Flags From Your App ​

The evaluate endpoint returns all flag values for a given project and environment. Pass user context to enable targeting rules.

bash
curl -X POST https://app.krafter.dev/api/v1/flags/evaluate \
  -H "Authorization: Bearer kr_live_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e",
    "environment": "production",
    "context": {
      "user_id": "usr_123",
      "plan": "pro"
    }
  }'
json
{
  "flags": {
    "new_checkout": {
      "value": false,
      "rule_id": null
    }
  }
}

The flag returns false because it is disabled. Toggle it on via the dashboard or the API:

bash
curl -X PATCH https://app.krafter.dev/api/v1/flags/a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d/toggle \
  -H "Authorization: Bearer kr_live_abc123def456"

Now evaluate again -- the flag returns true.

TIP

When you do not have user context at load time — server-side rendering, or a first paint before sign-in — use the bootstrap endpoint to get all flag values without a context:

bash
curl "https://app.krafter.dev/api/v1/flags/bootstrap?project_id=b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e&environment=production" \
  -H "Authorization: Bearer kr_live_abc123def456"

Step 5: Evaluate From a Browser or Mobile App ​

Everything above uses a platform key, which belongs on your server. Do not put it in a browser bundle — it is scoped to your whole team, so anyone who reads it out of your JavaScript can list every project, flag, targeting rule and segment you have, and read your unreleased development values.

For client-side code, create a client key instead. In the dashboard, pick your project under Flags, open Client Keys, and create one for the environment you are shipping:

bash
curl -X POST https://app.krafter.dev/api/v1/flags/client/evaluate \
  -H "Authorization: Bearer krf_client_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{"context": {"user_id": "usr_123", "plan": "pro"}}'
json
{
  "flags": { "new_checkout": true },
  "environment": "production"
}

The key names the project and the environment, so neither is in the request. It evaluates flags and records events, and it reads no definitions — which is what makes it safe to ship. See Client Keys for rotation, revocation and the full endpoint list.

Next Steps ​

Built by Krafter Studio