Experiments API
Create, manage, and query A/B tests. The active experiments endpoint is public; all others require authentication.
List Experiments
GET
/api/experimentsList all experiments for the current project
Returns an array of experiment objects. Optionally filter by status.
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status: draft, running, paused, or completed |
curl https://your-instance.com/api/experiments?status=running \
-H "x-api-key: apex_key_abc123"
Create Experiment
POST
/api/experimentsCreate a new experiment in draft status
| Parameter | Type | Description |
|---|---|---|
namerequired | string | Display name for the experiment |
targetUrlrequired | string | URL pattern where the experiment runs |
variantsrequired | array | Array of variant objects with name and optional css/js modifications |
trafficSplit | number | Percentage of traffic included (0–100). Defaults to 100. |
beliefId | string | Link to a belief this experiment tests |
mode | string | Experiment mode: ab (default), multivariate, or bandit |
curl -X POST https://your-instance.com/api/experiments \
-H "Content-Type: application/json" \
-H "x-api-key: apex_key_abc123" \
-d '{
"name": "Pricing CTA Color Test",
"targetUrl": "/pricing",
"trafficSplit": 50,
"variants": [
{ "name": "Control" },
{ "name": "Green CTA", "css": ".cta-btn { background: #22c55e; }" }
]
}'
Update Experiment
PATCH
/api/experimentsUpdate an existing experiment
| Parameter | Type | Description |
|---|---|---|
idrequired | string | Experiment ID to update |
status | string | Transition status: draft, running, paused, or completed |
name | string | Updated display name |
trafficSplit | number | Updated traffic percentage |
variants | array | Updated variants array |
curl -X PATCH https://your-instance.com/api/experiments \
-H "Content-Type: application/json" \
-H "x-api-key: apex_key_abc123" \
-d '{ "id": "exp_abc123", "status": "running" }'
Get Active Experiments (Public)
GET
/api/experiments/activeFetch running experiments for a project — used by the snippet
| Parameter | Type | Description |
|---|---|---|
keyrequired | string | Project key (query parameter) |
Info
This endpoint is public and requires no authentication. It is called automatically by the Apex JavaScript snippet to apply experiment variants on page load.
Returns an array of active experiments with their variants and traffic allocation.
Experiment Object
| Field | Type | Description |
|---|---|---|
id | string | Unique experiment identifier |
name | string | Display name |
status | string | draft, running, paused, or completed |
targetUrl | string | URL pattern for targeting |
trafficSplit | number | Percentage of traffic included |
variants | array | Variant definitions |
results | object | Per-variant conversion counts and rates |
confidence | number | Statistical confidence level (0–1) |
beliefId | string | Linked belief ID, if any |
mode | string | ab, multivariate, or bandit |