# A/B tests

> The store's A/B tests (D148), each as its page reads it: worked out by the store, read-only.

| Operation | Method and path | Scope |
|---|---|---|
| [List A/B tests](https://docs.kaizenaflow.com/reference/admin-api/a-b-tests#experiments-list) | `GET /experiments` | [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read) |
| [Get an A/B test](https://docs.kaizenaflow.com/reference/admin-api/a-b-tests#experiments-get) | `GET /experiments/{id}` | [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read) |

## List A/B tests {#experiments-list}

`GET https://kaizenaflow.com/api/admin/v1/experiments`

The store's A/B tests, newest first, each as its page reads it: the stage, how far along, the next step and, once it has an answer, each version against the original. Worked out by the store; nothing is written.

- **Operation:** `experiments.list`
- **Scope:** [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read)
- **Answers:** `200`, the answer under `data`.

### Answer {#experiments-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].name` | string |   |
| `data[].status` | one of `draft`, `scheduled`, `running`, `stopped`, `applied`, `discarded` |   |
| `data[].stage` | one of `draft`, `scheduled`, `learning`, `answer`, `broken`, `applied`, `discarded` | As the test's page shows it: a running test is learning until it has an answer, or broken when the visitors are not divided as planned. |
| `data[].next` | one of `start`, `wait`, `use`, `keep_original`, `start_again`, `done` | The one next step the page offers. |
| `data[].best` | string or null | For next = use: the version to use. |
| `data[].goal` | one of `orders`, `revenue`, `cart`, `checkout`, `click`, `form`, `signup`, `page` | signup: a sign-up to Kaizena Flow, a goal only Kaizena Flow's own store has. page: going on to a chosen page of the store. |
| `data[].target` | object |   |
| `data[].target.kind` | one of `page`, `layout`, `header`, `footer`, `role` |   |
| `data[].target.title` | string |   |
| `data[].target.slug` | string |   |
| `data[].target.part` | string or null |   |
| `data[].versions` | list of objects |   |
| `data[].versions[].key` | string | a is the original. |
| `data[].versions[].name` | string |   |
| `data[].versions[].share` | number |   |
| `data[].progress` | object |   |
| `data[].progress.days` | integer |   |
| `data[].progress.min_days` | integer |   |
| `data[].progress.visitors` | integer | Visitors of the version with the fewest. |
| `data[].progress.min_visitors` | integer |   |
| `data[].progress.share` | number | How far along, 0 to 1: the lesser of days and visitors. |
| `data[].progress.reached` | boolean |   |
| `data[].progress.ready_around` | string or null | The day (YYYY-MM-DD) it is likely ready at today's pace; null when reached or nothing to go on. |
| `data[].comparisons` | list of objects | Only once the test has an answer: empty while it is too early, so no one reads a peek as a result. |
| `data[].comparisons[].key` | string |   |
| `data[].comparisons[].original` | number | The original's rate (a share) or revenue per visitor (minor units). |
| `data[].comparisons[].version` | number |   |
| `data[].comparisons[].relative` | number or null | The change as a share of the original. |
| `data[].comparisons[].low` | number or null | The likely range's low end, at the verdict's level. |
| `data[].comparisons[].high` | number or null |   |
| `data[].comparisons[].side` | one of `better`, `worse`, `unsure` | Where the range lies: wholly above no change, wholly below, or across it. |
| `data[].impact` | object or null | If everyone saw the better version: how many more visitors a week would do the thing, with its likely range. |
| `data[].impact.key` | string |   |
| `data[].impact.per_week` | integer |   |
| `data[].impact.low` | integer |   |
| `data[].impact.high` | integer |   |
| `data[].learning` | string or null | What the owner wrote the test taught. |
| `data[].started_at` | string (date-time) or null |   |
| `data[].stopped_at` | string (date-time) or null |   |
| `data[].answered_at` | string (date-time) or null |   |
| `data[].applied_version` | string or null |   |
| `data[].created_at` | string (date-time) |   |

### Errors {#experiments-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#experiments-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/experiments' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/experiments", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/experiments",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get an A/B test {#experiments-get}

`GET https://kaizenaflow.com/api/admin/v1/experiments/{id}`

One A/B test as its page reads it.

- **Operation:** `experiments.get`
- **Scope:** [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read)
- **Answers:** `200`, the answer under `data`.

### Path parameters {#experiments-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#experiments-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.name` | string |   |
| `data.status` | one of `draft`, `scheduled`, `running`, `stopped`, `applied`, `discarded` |   |
| `data.stage` | one of `draft`, `scheduled`, `learning`, `answer`, `broken`, `applied`, `discarded` | As the test's page shows it: a running test is learning until it has an answer, or broken when the visitors are not divided as planned. |
| `data.next` | one of `start`, `wait`, `use`, `keep_original`, `start_again`, `done` | The one next step the page offers. |
| `data.best` | string or null | For next = use: the version to use. |
| `data.goal` | one of `orders`, `revenue`, `cart`, `checkout`, `click`, `form`, `signup`, `page` | signup: a sign-up to Kaizena Flow, a goal only Kaizena Flow's own store has. page: going on to a chosen page of the store. |
| `data.target` | object |   |
| `data.target.kind` | one of `page`, `layout`, `header`, `footer`, `role` |   |
| `data.target.title` | string |   |
| `data.target.slug` | string |   |
| `data.target.part` | string or null |   |
| `data.versions` | list of objects |   |
| `data.versions[].key` | string | a is the original. |
| `data.versions[].name` | string |   |
| `data.versions[].share` | number |   |
| `data.progress` | object |   |
| `data.progress.days` | integer |   |
| `data.progress.min_days` | integer |   |
| `data.progress.visitors` | integer | Visitors of the version with the fewest. |
| `data.progress.min_visitors` | integer |   |
| `data.progress.share` | number | How far along, 0 to 1: the lesser of days and visitors. |
| `data.progress.reached` | boolean |   |
| `data.progress.ready_around` | string or null | The day (YYYY-MM-DD) it is likely ready at today's pace; null when reached or nothing to go on. |
| `data.comparisons` | list of objects | Only once the test has an answer: empty while it is too early, so no one reads a peek as a result. |
| `data.comparisons[].key` | string |   |
| `data.comparisons[].original` | number | The original's rate (a share) or revenue per visitor (minor units). |
| `data.comparisons[].version` | number |   |
| `data.comparisons[].relative` | number or null | The change as a share of the original. |
| `data.comparisons[].low` | number or null | The likely range's low end, at the verdict's level. |
| `data.comparisons[].high` | number or null |   |
| `data.comparisons[].side` | one of `better`, `worse`, `unsure` | Where the range lies: wholly above no change, wholly below, or across it. |
| `data.impact` | object or null | If everyone saw the better version: how many more visitors a week would do the thing, with its likely range. |
| `data.impact.key` | string |   |
| `data.impact.per_week` | integer |   |
| `data.impact.low` | integer |   |
| `data.impact.high` | integer |   |
| `data.learning` | string or null | What the owner wrote the test taught. |
| `data.started_at` | string (date-time) or null |   |
| `data.stopped_at` | string (date-time) or null |   |
| `data.answered_at` | string (date-time) or null |   |
| `data.applied_version` | string or null |   |
| `data.created_at` | string (date-time) |   |

### Errors {#experiments-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#experiments-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/experiments/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/experiments/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/experiments/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/a-b-tests · made from the API contract 1.57
