> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sequenzy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add A/B Test Variant

> Add a variant to a draft campaign or sequence A/B test

Add a variant to a draft campaign or sequence A/B test. The next variant label (B, C, ...) is assigned automatically. A test can have at most 5 variants, and variants cannot be added after the test has started. Sequence variants receive their own editable email template; when the parent sequence is active, pass `confirmLiveChange: true` because the new variant immediately enters the live rotation.

## Request

<ParamField path="abTestId" type="string" required>
  A/B test ID.
</ParamField>

<ParamField body="subject" type="string" required>
  Variant subject line.
</ParamField>

<ParamField body="previewText" type="string">
  Variant preview text.
</ParamField>

<ParamField body="blocks" type="array">
  Variant body blocks. Defaults to the campaign or sequence control email blocks when omitted.
</ParamField>

<ParamField body="confirmLiveChange" type="boolean">
  Required as `true` when the A/B test belongs to an active sequence.
</ParamField>

```bash theme={null}
curl -X POST "https://api.sequenzy.com/api/v1/ab-tests/ab_abc123/variants" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Third subject idea"}'
```

## Responses

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "abTest": {
      "id": "ab_abc123",
      "campaignId": "camp_abc123",
      "status": "draft",
      "variants": [
        { "id": "var_a", "label": "A", "subject": "A quick update" },
        { "id": "var_b", "label": "B", "subject": "Alternative subject line" },
        { "id": "var_c", "label": "C", "subject": "Third subject idea" }
      ]
    }
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Cannot add variants after test has started"
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Adding a variant to an A/B test in an active sequence requires confirmLiveChange=true"
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Maximum of 5 variants allowed"
  }
  ```

  ```json 401 theme={null}
  {
    "success": false,
    "error": "Unauthorized"
  }
  ```

  ```json 404 theme={null}
  {
    "success": false,
    "error": "A/B test not found"
  }
  ```

  ```json 500 theme={null}
  {
    "success": false,
    "error": "Failed to create A/B test variant"
  }
  ```
</ResponseExample>
