A/B Tests
A/B testing lets you compare message variants to optimize engagement.
List A/B Tests
GET /api/workspaces/{workspaceId}/abtests
Returns all A/B tests across campaigns.
Auth: Session required
Response:
[
{
"id": "ab_abc123",
"name": "Subject Line Test",
"campaignId": "cmp_1",
"winnerMetric": "OPEN_RATE",
"testEndAt": "2026-02-01T00:00:00.000Z",
"campaign": { "id": "cmp_1", "name": "Welcome Series" },
"variants": [
{ "id": "var_1", "name": "Friendly", "weight": 50, "config": { "subject": "Hey there!" } },
{ "id": "var_2", "name": "Professional", "weight": 50, "config": { "subject": "Welcome aboard" } }
]
}
]Create A/B Test
POST /api/workspaces/{workspaceId}/abtests
Auth: Session required
Request Body:
{
"campaignId": "cmp_abc123",
"name": "Subject Line Test",
"winnerMetric": "OPEN_RATE",
"testEndAt": "2026-02-01T00:00:00.000Z",
"variants": [
{ "name": "Friendly", "weight": 50, "config": { "subject": "Hey there!" } },
{ "name": "Professional", "weight": 50, "config": { "subject": "Welcome aboard" } }
]
}| Field | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | Campaign to test |
name | string | Yes | Test name |
winnerMetric | string | Yes | OPEN_RATE, CLICK_RATE, CONVERSION, REVENUE |
testEndAt | string | No | When the test ends and winner is selected |
variants | array | Yes | 2–5 variants, weights must total 100 |
Variant Structure
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Variant name |
weight | number | Yes | Traffic percentage (all must sum to 100) |
config | object | Yes | Variant-specific configuration |
What You Can Test
| Dimension | Config Key | Example |
|---|---|---|
| Subject lines | subject | Different email subjects |
| Message body | body | Different content/layouts |
| Send time | sendAt | Morning vs. evening |
| Channel | channel | Email vs. push vs. Telegram |
| Template | templateId | Different templates |
Winner Selection
The winner is automatically selected based on the chosen metric after testEndAt:
- OPEN_RATE — Highest open rate wins
- CLICK_RATE — Highest click-through rate wins
- CONVERSION — Highest conversion event count wins
- REVENUE — Highest attributed revenue wins (if revenue events are tracked)
Last updated on