Quickstart

This guide takes you from zero to evaluating your first feature flag in your own code. It should take about five minutes.

1. Create a flag

  1. Open Flags in the sidebar and click New flag.
  2. Give it a name — for example New checkout. RestFlags turns this into a key automatically (new-checkout). The key is the immutable identifier you use in code and the API.
  3. Choose a kind. For an on/off switch, pick Boolean.
  4. (Optional) add a description or tags.
  5. Click Create.

Your flag now exists in all three environments, switched off.

2. Turn it on

  1. Click the flag to open its detail page.
  2. Make sure the environment switcher in the top bar is set to Development.
  3. Flip the enabled toggle on.

With no targeting rules, an enabled boolean flag serves its true variation to everyone in that environment.

3. Create an API key

Your application authenticates to RestFlags with an API key.

  1. Open API keys in the sidebar and click Create new key.
  2. Name it (e.g. Local dev), choose the Development environment and the Read only scope.
  3. Click Create. The full token is shown once — copy it now. It looks like rf_test_xxxxxxxxxxxx.

4. Evaluate the flag from your code

Send a POST request to /api/v1/flags with the flag key and a user context:

curl https://api.restflags.com/api/v1/flags \
  -H "Authorization: Bearer rf_test_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "flag": "new-checkout",
    "environment": "development",
    "user": { "id": "user-123" }
  }'

The response tells you the value and why:

{ "value": true, "variant": "on", "reason": "fallthrough" }

Use that value in your application:

const res = await fetch("https://api.restflags.com/api/v1/flags", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESTFLAGS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    flag: "new-checkout",
    user: { id: currentUser.id },
  }),
});
const { value } = await res.json();

if (value) {
  renderNewCheckout();
} else {
  renderOldCheckout();
}

5. Roll it out gradually

Back on the flag's detail page you can now:

  • Set a rollout percentage to serve true to, say, 10% of users.
  • Add a targeting rule to serve true only to a specific audience.
  • Promote the same configuration to Staging and Production.

Next steps