> ## Documentation Index
> Fetch the complete documentation index at: https://docs.growthbook.io/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> Use the GrowthBook REST API to manage the app, plus public SDK Connection endpoints that SDKs use to fetch feature flags.

GrowthBook offers a full REST API for interacting with the application.

[View REST API Docs](https://docs.growthbook.io/api/introduction.md)

Two key settings help when an agent or script makes changes: the `X-GrowthBook-Requested-By` header names the member who asked for each one, and **Require confirmation** holds risky changes until a person confirms them in GrowthBook. See [API Keys for Agents](https://docs.growthbook.io/integrations/ai-agents/api-keys.md).

## Common Tasks

These endpoints cover the most common automation tasks:

**Experiments**

* [Create an experiment](https://docs.growthbook.io/api/experiments/operation/postExperiment.md) (`POST /v1/experiments`) or [list existing experiments](https://docs.growthbook.io/api/experiments/operation/listExperiments.md) (`GET /v1/experiments`).
* [Get results for an experiment](https://docs.growthbook.io/api/experiments/operation/getExperimentResults.md) (`GET /v1/experiments/{id}/results`) to pull the latest analysis into your own reporting.

**Feature flags**

* [Get a single feature](https://docs.growthbook.io/api/features-v2/operation/getFeatureV2.md) (`GET /v2/features/{id}`), including its rules in every environment.
* [Toggle a feature on or off](https://docs.growthbook.io/api/features-v2/operation/toggleFeatureV2.md) (`POST /v2/features/{id}/toggle`) in one or more environments, for example from a deploy script or an incident runbook.

**Metrics and data**

* [Create a fact metric](https://docs.growthbook.io/api/fact-metrics/operation/postFactMetric.md) (`POST /v1/fact-metrics`) or [list fact metrics](https://docs.growthbook.io/api/fact-metrics/operation/listFactMetrics.md) (`GET /v1/fact-metrics`).
* [Get a fact table](https://docs.growthbook.io/api/fact-tables/operation/getFactTable.md) (`GET /v1/fact-tables/{id}`) to inspect its SQL, columns, and filters.
* [List data sources](https://docs.growthbook.io/api/data-sources/operation/listDataSources.md) (`GET /v1/data-sources`) to find the ids other endpoints ask for.

**Targeting**

* [Create a saved group](https://docs.growthbook.io/api/saved-groups/operation/postSavedGroup.md) (`POST /v1/saved-groups`) to reuse a list of ids or a targeting condition across features and experiments.
* [Create a segment](https://docs.growthbook.io/api/segments/operation/postSegment.md) (`POST /v1/segments`) to analyze experiment results for a subset of users.

## SDK Connection Endpoints

In addition to the REST API above, there is one additional readonly endpoint - the SDK Connection Endpoint.

The SDK Connection Endpoint provides readonly access to a subset of your feature flag data, just enough for the [GrowthBook SDKs](https://docs.growthbook.io/lib.md) to assign values to users. They are meant to be public and do not require authentication to view.

In **GrowthBook Cloud**, the SDK Connection Endpoints are served from our global CDN: `https://cdn.growthbook.io/api/features/...`. If you are self-hosting, you can use [your own CDN](https://docs.growthbook.io/self-host/cdn.md) or run the [GrowthBook Proxy server](https://docs.growthbook.io/self-host/proxy.md), which provides built-in caching and performance optimizations.

SDK Connection Endpoints are scoped to a single Environment (e.g. `dev` or `production`) and can also be scoped to a single Project. Manage all of your SDK Connections on the **Features → SDKs** page.

> **Typescript Type Definition**
>
> ```ts theme={null}
> interface SDKEndpointResponse {
>   status: 200;
>   features: {
>     [key: string]: FeatureDefinition
>   }
> }
>
> interface FeatureDefinition {
>   defaultValue: any;
>   rules?: FeatureDefinitionRule[];
> }
>
> interface FeatureDefinitionRule {
>   force?: any;
>   weights?: number[];
>   variations?: any[];
>   hashAttribute?: string;
>   hashVersion?: number;
>   seed?: string;
>   namespace?: [string, number, number];
>   key?: string;
>   coverage?: number;
>   condition?: any;
>   meta?: VariationMeta[];
>   name?: string;
>   phase?: string;
> }
>
> interface VariationMeta = {
>   passthrough?: boolean;
>   key?: string;
>   name?: string;
> }
> ```

> **Example JSON object**
>
> ```json theme={null}
> {
>   "status": 200,
>   "features": {
>     "feature-key": {
>       "defaultValue": true
>     },
>     "another-feature": {
>       "defaultValue": "blue",
>       "rules": [
>         {
>           "condition": {
>             "browser": "firefox"
>           },
>           "force": "green"
>         }
>       ]
>     }
>   }
> }
> ```

### Encryption

If you've enabled encryption for your SDK endpoint, the response format changes:

> **Typescript Type Definition**
>
> ```ts theme={null}
> interface SDKEncryptedEndpointResponse {
>   status: 200;
>   encryptedFeatures: string;
> }
> ```

> **Example JSON object**
>
> ```json theme={null}
> {
>   "status": 200,
>   "encryptedFeatures": "abcdef123456GHIJKL0987654321..."
> }
> ```

You will need to decrypt the features first before passing into the SDK. Our front-end SDKs (JavaScript and React) handle this for you automatically and we're in the process of adding built-in support to our other SDKs.
