rectangle-terminalUse Reflag in your CLI

High-level guide to flagging features in your CLI

If you use API token for auth

First, create an endpoint in your backend for the CLI to call:

POST /get-flags
Authorization: Bearer <APIKEY>

The endpoint will take the API key and use it to look up the associated user.

Then, use the API Reference to get enabled flags for the authenticated user. Return the flags to the CLI:

{
  flags: ['flag1', 'flag2']
}

Finally, check for access with a simple:

/function isFlagEnabled(flag: string) {
    return flags.contains('myflag');
}

If you use API token for auth AND Node.js

First, create an endpoint in your backend for the CLI to call:

POST /get-flags
Authorization: Bearer <APIKEY>

The endpoint will take the API key and use it to look up the associated user.

Use the Node.js SDK get enabled flags for the authenticated user.

Finally, check for access with a simple:

If you use OAuth for auth

Use Node.js SDK or API Reference to get flags for the authenticated user.

In Node, configure the SDK like so:

Check access for individual flag:

Or get all flags:

Last updated

Was this helpful?