Management SDK

Typed SDK for interacting with Reflag’s Management API.

Use @reflag/management-sdk to programmatically manage feature flags such as listing flags, and enabling or disabling them for specific users or companies.

For a practical example of what you can build, see the Customer Admin Panelarrow-up-right example app.

Installation

npm i @reflag/management-sdk
# or
yarn add @reflag/management-sdk

Create a client

Initialize the SDK with a Reflag Management API Keyarrow-up-right.

import { Api } from "@reflag/management-sdk";

const api = new Api({
  accessToken: process.env.REFLAG_API_KEY,
});

API surface

Main exports:

  • Api: base client

  • createAppClient(appId, config): app-scoped client

  • ReflagApiError: normalized API error type

  • Generated request/response types and models from @reflag/management-sdk

Core method groups:

  • Applications: listApps, getApp

  • Environments: listEnvironments, getEnvironment

  • Flags: listFlags, createFlag, updateFlag

  • User/company evaluation: getUserFlags, updateUserFlags, getCompanyFlags, updateCompanyFlags

Quick start

App-scoped client

If most calls are for one app, use createAppClient to avoid repeating appId.

Common workflows

Create and update a flag

createFlag and updateFlag return { flag } with the latest flag details.

Use null to clear nullable fields like description or ownerUserId on update.

Read user flags for an environment

getUserFlags evaluates flag results for one user in one environment and returns the user’s current values plus exposure/check metadata for each flag.

Toggle a user flag

Use true to explicitly target on, and null to remove specific targeting.

Read company flags for an environment

Toggle a company flag

Use true to explicitly target on, and null to remove specific targeting.

Error handling

The SDK throws ReflagApiError for non-2xx API responses.

Example app

See packages/management-sdk/examples/customer-admin-panel/README.md for a small Next.js app using this SDK in server actions.

License

MIT

Last updated

Was this helpful?