API

The API is one way to keep cached experiment configuration up-to-date on your servers.

With the API, your servers pull experiment overrides from GrowthBook in a cronjob (or similar).

With Webhooks, GrowthBook pushes experiment overrides to your servers as soon as they change.

Creating an API Key

When logged into GrowthBook as an admin, navigate to Settings -> API Keys.

There you can generate an API key and give it an optional description.

Experiment Overrides Endpoint

As of right now, there is only a single public API endpoint that returns experiment configuration info.

For self-hosted deployments, the endpoint is at http://localhost:3100/config/{myKey} (note: port 3000 is the default front-end app, port 3100 is the API)

For GrowthBook Cloud, the endpoint is on our global CDN: https://cdn.growthbook.io/config/{myKey}

Here is an example API response:

{
  "status": 200,
  "overrides": {
    "experiment-key": {
      "status": "running",
      "weights": [0.5, 0.5],
      "coverage": 1,
      "groups": ["beta"],
      "url": "^/post/[0-9]+$"
    },
    "another-experiment": {
      "status": "stopped",
      "force": 2
    }
  }
}

The status field just mirrors the HTTP status code.

The overrides field has one entry per experiment with overrides that should take precedence over hard-coded values in your code.

  • status - Either "draft", "running", or "stopped". Stopped experiments are only included in the response if a non-control variation won.
  • weights - How traffic should be weighted between variations. Will add up to 1.
  • coverage - A float from 0 to 1 (inclusive) which specifies what percent of users to include in the experiment.
  • groups - An array of user groups who are eligible for the experiment
  • url - A regex for which URLs the experiment should run on
  • force - Force all users to see the specified variation index (0 = control, 1 = first variation, etc.).

Official Client Libraries

We offer official client libraries that work with these data structures in a few popular languages with more coming soon.