# molted experiments

Source: https://molted.email/docs/cli/experiments

Run A/B or holdout experiments on journey steps

| Command | Description |
| - | - |
| [`molted experiments create`](#molted-experiments-create) | Create a new experiment |
| [`molted experiments list`](#molted-experiments-list) | List experiments |
| [`molted experiments get`](#molted-experiments-get) | Get an experiment by ID |
| [`molted experiments start`](#molted-experiments-start) | Start an experiment (only from draft) |
| [`molted experiments stop`](#molted-experiments-stop) | Stop an experiment (only from running) |
| [`molted experiments results`](#molted-experiments-results) | Get experiment results by variant |

## Agent context

Experiments compare template variants (or a holdout) on a journey step. Reachable with a Bearer API key (despite older docs implying cookie-only).

An experiment only actually runs when a journey step's stepId matches its journeyStepId exactly (journey-step-processor.ts) -- `--journey-step` is optional on the API, but an experiment with none attached to a real step never fires. Pass real journey/step UUIDs, e.g. from `molted journeys get`.

### Create an experiment

```bash
molted experiments create --name "Subject line test" \
  --journey 3fa2c1e0-8b8e-4c1a-9e5a-6f6e2b6e6a11 \
  --journey-step 7c9c0d3a-2f5b-4a49-9b2e-1d3f9a7c6e02 --type ab \
  --variants '[
    {"id":"v1","name":"Control","weight":50,"templateVersionId":"<version-uuid-1>","isControl":true,"isHoldout":false},
    {"id":"v2","name":"Casual","weight":50,"templateVersionId":"<version-uuid-2>","isControl":false,"isHoldout":false}
  ]'
# → --variants also accepts @path/to/variants.json
```

Variant fields: id, name, weight (positive number, relative), templateVersionId (or null), subjectOverride (or null), timingDelayMinutes (leave it null: a variant cannot delay its send yet, and the API refuses a delay), isHoldout (the contact gets no send), isControl (the baseline that results compare the other variants against). Note: "templateId" is NOT a variant field -- the API ignores it, so the CLI rejects it; use "templateVersionId" (from `templates create`/`add-version`).

A variant's templateVersionId is the template version that variant sends (subject and body come from it; the send records that version). It must be a version UUID of a template in your workspace: a malformed id is a 400 and an unknown one a 404. subjectOverride, if set, replaces the subject.

### Run it

```bash
molted experiments start <id>   # only from draft
molted experiments stop <id>    # only from running
molted experiments results <id>
```

### List / inspect

```bash
molted experiments list [--journey <journeyId>]
molted experiments get <id>
```

Related: [`molted journeys`](https://molted.email/docs/cli/journeys.md), [`molted templates`](https://molted.email/docs/cli/templates.md)

## Commands

### molted experiments create

Create a new experiment

```bash
molted experiments create [options]
```

| Option | Description | Default |
| - | - | - |
| `--name <name>` | Experiment name (required) (required) | |
| `--variants <json-or-@file>` | JSON array of variants, or @path/to/file.json (required) (required) | |
| `--journey <id>` | Journey ID | |
| `--journey-step <id>` | Journey step ID -- required in practice: an experiment only runs when this matches the step being processed | |
| `--type <type>` | Experiment type (server default: ab) (one of: ab, holdout) | |
| `--segment <id>` | Segment ID to scope the experiment to | |

### molted experiments list

List experiments

```bash
molted experiments list [options]
```

| Option | Description | Default |
| - | - | - |
| `--journey <id>` | Filter by journey ID | |

### molted experiments get

Get an experiment by ID

```bash
molted experiments get <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

### molted experiments start

Start an experiment (only from draft)

```bash
molted experiments start <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

### molted experiments stop

Stop an experiment (only from running)

```bash
molted experiments stop <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

### molted experiments results

Get experiment results by variant

```bash
molted experiments results <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

See [CLI overview](https://molted.email/docs/cli.md) for global options, credentials and output format.
