> ## 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](/api/introduction)

## Common Tasks

These endpoints cover the most common automation tasks:

**Experiments**

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

**Feature flags**

* [Get a single feature](/api/features-v2/operation/getFeatureV2) (`GET /v2/features/{id}`), including its rules in every environment.
* [Toggle a feature on or off](/api/features-v2/operation/toggleFeatureV2) (`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](/api/fact-metrics/operation/postFactMetric) (`POST /v1/fact-metrics`) or [list fact metrics](/api/fact-metrics/operation/listFactMetrics) (`GET /v1/fact-metrics`).
* [Get a fact table](/api/fact-tables/operation/getFactTable) (`GET /v1/fact-tables/{id}`) to inspect its SQL, columns, and filters.
* [List data sources](/api/data-sources/operation/listDataSources) (`GET /v1/data-sources`) to find the ids other endpoints ask for.

**Targeting**

* [Create a saved group](/api/saved-groups/operation/postSavedGroup) (`POST /v1/saved-groups`) to reuse a list of ids or a targeting condition across features and experiments.
* [Create a segment](/api/segments/operation/postSegment) (`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](/lib) 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](/self-host/cdn) or run the [GrowthBook Proxy server](/self-host/proxy), 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.

<AccordionGroup>
  <Accordion title="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;
    }
    ```
  </Accordion>

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

### Encryption

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

<AccordionGroup>
  <Accordion title="Typescript Type Definition">
    ```ts theme={null}
    interface SDKEncryptedEndpointResponse {
      status: 200;
      encryptedFeatures: string;
    }
    ```
  </Accordion>

  <Accordion title="Example JSON object">
    ```json theme={null}
    {
      "status": 200,
      "encryptedFeatures": "abcdef123456GHIJKL0987654321..."
    }
    ```
  </Accordion>
</AccordionGroup>

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.
