Skip to content

Experiments API

Manage A/B tests and experiments.

List Experiments

http
GET /v1/experiments

Response:

json
{
  "data": [
    {
      "id": "exp_123",
      "key": "checkout-v2",
      "status": "running",
      "variants": ["control", "variant-a"],
      "createdAt": "2024-01-15T10:00:00Z"
    }
  ]
}

Get Experiment

http
GET /v1/experiments/:key

Response:

json
{
  "data": {
    "id": "exp_123",
    "key": "checkout-v2",
    "status": "running",
    "variants": [
      { "key": "control", "weight": 50 },
      { "key": "variant-a", "weight": 50 }
    ],
    "metrics": ["conversion_rate", "revenue"],
    "results": {
      "control": { "conversion": 0.12, "sampleSize": 5000 },
      "variant-a": { "conversion": 0.15, "sampleSize": 4800 }
    }
  }
}

Create Experiment

http
POST /v1/experiments

Request:

json
{
  "key": "checkout-v2",
  "description": "Test new checkout flow",
  "variants": [
    { "key": "control", "weight": 50 },
    { "key": "variant-a", "weight": 50 }
  ],
  "metrics": ["conversion_rate"]
}

Start Experiment

http
POST /v1/experiments/:key/start

Stop Experiment

http
POST /v1/experiments/:key/stop

Get Variant

http
POST /v1/experiments/:key/variant

Request:

json
{
  "userId": "user-123"
}

Response:

json
{
  "data": {
    "variant": "variant-a",
    "experimentId": "exp_123"
  }
}

Built with VitePress