DocumentationA/B testing
A/B testing
Test two versions of a template in a campaign and pick the winner by open rate.
An A/B test splits a campaign's sends between two versions of the same template and measures which performs better. MailingCore attributes opens and clicks per variant and picks the winner when you close it.
Model
| Entity | What it is |
|---|---|
| AbTest | The test: template, status, trafficSplit and the winning variant |
| AbVariant | Each version (versionId) with its sentCount, openCount, clickCount counters |
Statuses: DRAFT → RUNNING → COMPLETED (or CANCELLED).
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /ab-tests | List tests with the template name and each variant's subject |
POST | /ab-tests | Create a test (starts in DRAFT with two variants) |
POST | /ab-tests/:id/start | DRAFT → RUNNING |
POST | /ab-tests/:id/complete | RUNNING → COMPLETED, sets the winner |
Guards: JwtAuthGuard + TenantGuard (dashboard authentication).
Create a test
POST /ab-tests
Authorization: Bearer <accessToken>
X-Tenant-Id: {tenantId}
Content-Type: application/json
{
"name": "Onboarding subject",
"templateId": "tmpl_123",
"variantAId": "ver_a",
"variantBId": "ver_b"
}
| Field | Required | Notes |
|---|---|---|
name | Yes | Test name |
templateId | Yes | Template under test (must belong to your tenant) |
variantAId / variantBId | Yes | The two versions to compare |
trafficSplit | No | Stored; today both variants are created at weight 50/50 |
How it runs
- Start the test (
/start) to move it toRUNNING. - Send a campaign with that template. For each recipient, MailingCore picks a variant with a weighted split (cryptographic RNG) and increments its
sentCount. - Tracking attributes the first open and the first click of each email to the matching variant (
openCount/clickCount). - Complete the test (
/complete): the winner is the variant with the highest open rate (openCount / sentCount); ties go to the first variant.