Feature Flags
SDKs
Rest API

Rest API Reference

Basestack Feature Flags is designed to offer seamless functionality and efficient communication. This Rest API communication empowers you to easily manage feature flags and utilize various functionalities within your application.

API Explorer

These two main endpoints are essential for consuming the SDK aspect of the API.

Get a Flag by Slug/Name

Retrieve a specific feature flag linked to a particular project and environment (e.g., Develop, Staging, etc).

## Get Flag By Slug/Name
curl "https://your-basestack-hosted-app-domain.com/api/v1/flags/:slug" \
     -H 'x-project-key: xxxx-xxxx-xxxx' \
     -H 'x-environment-key: xxxx-xxxx-xxxx'

You can find these parameter values in your project's settings

Responses

Success:
{
  "slug": "header",
  "enabled": true,
  "payload": {},
  "expiredAt": null,
  "description": "header",
  "createdAt": "2023-07-20T14:08:16.433Z",
  "updatedAt": "2023-07-20T14:08:16.433Z"
}
Error:
{
  "enabled": false,
  "error": true,
  "message": "Flag with slug header does not exist"
}

Get All Flags

Retrieve all feature flags associated with a particular project and a specific environment (e.g., Develop, Staging, etc)

## Get All Flags
curl "https://your-basestack-hosted-app-domain.com/api/v1/flags" \
     -H 'x-project-key: xxxx-xxxx-xxxx' \
     -H 'x-environment-key: xxxx-xxxx-xxxx'

You can find these parameter values in your project's settings

Responses

Success:
{
  "flags": [
    {
      "slug": "footer",
      "enabled": true,
      "payload": {},
      "expiredAt": null,
      "description": "footer",
      "createdAt": "2023-07-20T14:08:27.284Z",
      "updatedAt": "2023-07-20T14:08:27.284Z"
    },
    {
      "slug": "header",
      "enabled": true,
      "payload": {},
      "expiredAt": null,
      "description": "header",
      "createdAt": "2023-07-20T14:08:16.433Z",
      "updatedAt": "2023-07-20T14:08:16.433Z"
    }
  ]
}
Error:
{
  "flags": []
}

Missing Parameters

Missing Project Key or Environment Key in headers

{
  "error": "Missing Project Key or Environment Key in headers"
}

Missing Flag Slug in query params

{
  "error": "Missing flag slug in query params"
}

Environment Variables

As you set up the REST API, you'll come across various Environment Variables that are crucial for its proper configuration. To access and understand all these related Environment Variables, navigate to the deployment configuration. This section will provide you with the necessary context and information to effectively configure the REST API for your project.

Typescript Type Definition

export interface Flag {
  slug: string;
  enabled: boolean;
  payload?: unknown;
  expiredAt?: Date;
  createdAt: Date;
  updatedAt: Date;
  description: string;
  error: boolean;
}