# Use Reflag 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](/api/public-api/public-api-reference.md) to get enabled flags for the authenticated user. Return the flags to the CLI:

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

Finally, check for access with a simple:

```tsx
/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](/supported-languages/node-sdk.md) get enabled flags for the authenticated user.

```jsx
import { ReflagClient } from "@reflag/node-sdk";

// configure the client
const boundClient = reflagClient.bindClient({
  user: {
    id: "c1_u1",
    name: "John Doe"
  },
  company: {
    id: "c1",
    name: "Acme, Inc."
  },
});

// get flags
const flags = boundClient.getFlags();
```

Finally, check for access with a simple:

```tsx
if(flags['myflag'].isEnabled) {
    //feature access
}
```

### If you use OAuth for auth

Use [Node.js SDK](/supported-languages/node-sdk.md) or [API Reference](/api/public-api/public-api-reference.md) to get flags for the authenticated user.

In Node, configure the SDK like so:

```jsx
import { ReflagClient } from "@reflag/node-sdk";

// configure the client
const boundClient = reflagClient.bindClient({
  user: {
    id: "c1_u1",
    name: "John Doe"
  },
  company: {
    id: "c1",
    name: "Acme, Inc."
  },
});
```

Check access for individual flag:

```jsx
const { isEnabled } = boundClient.getFlag("myflag");

if (isEnabled) {
    //feature access
}    
```

Or get all flags:

```jsx
const flags = boundClient.getFlags();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reflag.com/guides/use-reflag-in-your-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
