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 or expose it in client-side code.

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

For client-side apps that do not have user context at load time, use the bootstrap endpoint to get all flag defaults without 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"

Next Steps

Built by Krafter Studio