pex

Experiments API

Create, manage, and query A/B tests. The active experiments endpoint is public; all others require authentication.

List Experiments

GET/api/experiments

List all experiments for the current project

Returns an array of experiment objects. Optionally filter by status.

ParameterTypeDescription
statusstringFilter 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/experiments

Create a new experiment in draft status

ParameterTypeDescription
namerequiredstringDisplay name for the experiment
targetUrlrequiredstringURL pattern where the experiment runs
variantsrequiredarrayArray of variant objects with name and optional css/js modifications
trafficSplitnumberPercentage of traffic included (0–100). Defaults to 100.
beliefIdstringLink to a belief this experiment tests
modestringExperiment 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/experiments

Update an existing experiment

ParameterTypeDescription
idrequiredstringExperiment ID to update
statusstringTransition status: draft, running, paused, or completed
namestringUpdated display name
trafficSplitnumberUpdated traffic percentage
variantsarrayUpdated 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/active

Fetch running experiments for a project — used by the snippet

ParameterTypeDescription
keyrequiredstringProject 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

FieldTypeDescription
idstringUnique experiment identifier
namestringDisplay name
statusstringdraft, running, paused, or completed
targetUrlstringURL pattern for targeting
trafficSplitnumberPercentage of traffic included
variantsarrayVariant definitions
resultsobjectPer-variant conversion counts and rates
confidencenumberStatistical confidence level (0–1)
beliefIdstringLinked belief ID, if any
modestringab, multivariate, or bandit