# Get Campaign A/B Result

> GET /campaigns/:id/ab — retrieve the A/B winner evaluation for a campaign.

`GET /campaigns/:id/ab`

Returns the A/B winner evaluation for a campaign that has A/B testing enabled. SendDart runs a **two-proportion z-test** over the per-variant open, click, or reply outcomes recorded in the tracking tables, and returns which variant won, how confident the result is, and detailed per-variant metrics.

The `metric` field reflects the `ab_metric` set on the campaign (`open`, `click`, or `reply`). The `confidence` field is `low` when the sample is too small to trust, `medium` when the winner leads but it is not conclusive, and `high` when the result is statistically significant (p < 0.05 with at least 20 sends per arm).

If the variants are tied or one arm has no sends, the winner defaults to `A` and `fallback` is `true`.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The campaign ID. |

**Node.js**

```js
import { SendDart } from 'senddart';

const mb = new SendDart('mb_xxxxxxxxx');

const { data, error } = await mb.campaigns.ab('8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90');
console.log({ data, error });
```

**Ruby**

```ruby
require "senddart"

SendDart.api_key = "mb_xxxxxxxxx"

SendDart::Campaigns.ab("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendDart\SendDart;

$senddart = SendDart::client('mb_xxxxxxxxx');

$senddart->campaigns->ab('8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90');
```

**Python**

```python
import senddart

senddart.api_key = "mb_xxxxxxxxx"

senddart.Campaigns.ab("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90")
```

**Go**

```go
import "github.com/shekhu10/senddart-sdks/senddart-go"

client := senddart.NewClient("mb_xxxxxxxxx")

result, err := client.Campaigns.Ab("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90")
```

**Rust**

```rust
use senddart::SendDart;

let mb = SendDart::new("mb_xxxxxxxxx");

let _result = mb.campaigns.ab("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90").await?;
```

**Java**

```java
import com.senddart.SendDart;
import com.senddart.SendDartResponse;

SendDart senddart = new SendDart("mb_xxxxxxxxx");

SendDartResponse response = senddart.campaigns().ab("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90");
```

**.NET**

```csharp
using SendDart;

ISendDart senddart = SendDartClient.Create("mb_xxxxxxxxx");

var resp = await senddart.CampaignRetrieveAbResultAsync("8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90");
```

**cURL**

```bash
curl -X GET 'https://www.senddart.com/api/campaigns/8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90/ab' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
senddart campaigns ab 8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90
```

### Response

```json
{
  "object": "campaign_ab",
  "campaign_id": "8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90",
  "metric": "open",
  "a": {
    "variant": "A",
    "sent": 120,
    "conversions": 36,
    "rate": 0.3
  },
  "b": {
    "variant": "B",
    "sent": 118,
    "conversions": 47,
    "rate": 0.3983050847457627
  },
  "winner": "B",
  "fallback": false,
  "lift": 0.3276785714285714,
  "zScore": 2.14,
  "pValue": 0.0162,
  "confidence": "high",
  "reason": "variant B wins on open (p=0.016)"
}
```

> **Note:** Errors: `not_found` if the campaign does not exist or is not yours; `validation_error` if the campaign does not have A/B testing enabled.
