# POST /ab-tests

**Resource:** [AB_TESTS](./ab-tests.md)  
**MCP tool:** `create_ab_test`  
**Scopes:** `ab-tests:write`  
**Write operation:** yes

Create an A/B test, with two or more versions (labelled A, B, C), for anything that talks to leads or visitors: an agent, a nurture sequence or one automation email, an email blast, a website or landing page, a form, a lead magnet, a booking page, a quote or proposal template, invoice reminders or review requests. It starts as a draft; start it with update_ab_test status "running". Once running, each person is put into one version at random and keeps it. Results (replies, bookings, sales, new leads, opens, clicks, payments, reviews, signatures, opt-outs) are read from the CRM, so nothing has to report them. Only one test per thing can run at a time.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `name` | body | string | yes | What is being tested, e.g. "Reawakening opener: price vs no price". |
| `description` | body | string | no | Optional notes on the idea behind the test. |
| `goal` | body | string | no | What decides the winner. replied (an inbound email, text or call), booked (a booking), won (an opportunity won), became_lead (a new opportunity; for a website visitor, one carrying their visitor id), opened (an email blast opened, or an email an automation or Auto Sequence in the test sent through TrustPager Email), clicked (a link in an email blast), paid (an invoice paid in full), reviewed (a review from their email address), signed (a document signed). Default depends on what is tested: booked for agents and sequences, clicked for blasts, became_lead for websites, forms and lead magnets, signed for quote templates, paid for invoice reminders, reviewed for review requests. |
| `winner_mode` | body | string | no | "approval" (default): the winner is shown and a person promotes it. "auto": the winner takes over by itself once it is clear. |
| `min_leads_per_version` | body | number | no | Leads every version needs before a winner can be called. Default 30. |
| `confidence_needed` | body | number | no | How sure (0.5 to 0.999) the test must be before calling a winner. Default 0.95. |
| `attribution_days` | body | number | no | Days after a lead is put into a version during which their reply, booking, sale or opt-out counts. Default 30. |
| `subject_type` | body | string | yes | What is being tested: outreach_agent, auto_responder (a text or email reply agent), voice_agent, workflow_agent, auto_queue (an Auto Sequence, e.g. a nurture sequence), automation (one automation, e.g. one email step), email_blast, website, website_page (one page, e.g. a landing page), form, lead_magnet, booking_page, document_template (a quote or proposal template), invoice_reminder, review_request or other. |
| `subject_id` | body | string | no | The id of the thing being tested (its agent, auto responder, voice agent, sequence, automation, email blast, website, website page, form, lead magnet, booking page or document template id). Optional only for invoice_reminder, review_request and other. |
| `unit` | body | string | no | Who is split: "contact" (known leads) or "visitor" (anonymous website visitors, linked to the lead when they fill in a form, book or chat). Default: visitor for website, website_page, form and lead_magnet; contact for everything else. |
| `versions` | body | array | yes | Two or more versions. They are labelled A, B, C in this order. |
| `require_approval` | body | boolean | no | Optional. Set true to route this write into the approval queue for human review instead of executing it immediately (returns 202 + an approval_id). Works even when your key/token has permission to execute directly. |

## Request example

```bash
curl -X POST   "https://api.trustpager.com/functions/v1/api/v1/ab-tests"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"name":"...","description":"...","goal":"..."}'
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`