# Test automation

`opensend.automations.test(id, input)`

Walks the copy you edit once, now, for one address. Its emails are really sent, with "[Test]" before the subject. Waits are skipped, a wait for an event takes its `no` path, and steps that change contacts or call webhooks are skipped. Nothing is counted.

Needs the scope: `automations:write`

## Input

`id` goes first, on its own, and the rest in one object. One object that holds `id` works too.

- `id` (string, required): The id of the item. Up to 64 characters.
- `email` (string, required): Where the emails of the test go. Up to 120 characters.
- `data` (Record<string, unknown>): Data to run it with, as an event would carry.

## Returns

The call resolves to the answer, already parsed. A call the API refuses throws `OpenSendError` with the code and the message of the answer. [SDK](https://opensend.sh/docs/sdk) lists the errors of the client itself.

- `object` ("automation_run"): Always `automation_run`.
- `id` (string): The id of the run.
- `automationId` (string): The id of the automation.
- `version` (integer): The version of the automation the run follows.
- `email` (string): The address of the person.
- `contactId` (string | null): The id of their contact, or `null` for a bare address.
- `status` (string): Where the run stands: `running`, `waiting`, `completed`, `exited`, `failed` or `canceled`. One of: `running`, `waiting`, `completed`, `exited`, `failed`, `canceled`.
- `stepId` (string | null): The id of the step it is at, or `null` once it has ended.
- `source` (string): What started it: the name of the event, or `schedule`, `date`, `manual` or `test`.
- `test` (boolean): `true` for a test run.
- `reason` (string | null): Why it ended before the end of its path, or `null`. One of: `exit_step`, `goal`, `unsubscribed`, `contact_deleted`, `automation_deleted`, `automation_stopped`, `missing_variable`, `send_refused`, `step_failed`, `canceled`.
- `detail` (string): More about how it ended. Empty while it is going on.
- `wakeAt` (string | null): When a waiting run goes on, or `null`.
- `startedAt` (string): When the run started.
- `finishedAt` (string | null): When it ended, or `null`.
- `data` (Record<string, unknown>): The data of what started it.
- `steps` (object[]): What each step did, oldest first.
- `steps[].id` (string): The id of the step.
- `steps[].kind` (string): What the step does. One of: `send_email`, `delay`, `wait_until`, `wait_for_event`, `condition`, `branch`, `split`, `update_contact`, `delete_contact`, `add_to_audience`, `remove_from_audience`, `webhook`, `send_event`, `exit`.
- `steps[].name` (string): The name of the step.
- `steps[].outcome` (string): What happened: `sent`, `done`, `waiting`, `waited`, `yes`, `no`, `skipped` or `failed`. One of: `sent`, `done`, `waiting`, `waited`, `yes`, `no`, `skipped`, `failed`.
- `steps[].detail` (string): More about it, such as why it failed. Often empty.
- `steps[].emailId` (string | null): The id of the email it sent, or `null`.
- `steps[].at` (string): When it happened.

## Example

TypeScript:

```ts
await opensend.automations.test('auto_teams', {
  email: 'ada@example.com',
})
```

CLI:

```bash
opensend automations test auto_teams --email ada@example.com
```

Answer:

```json
{
  "object": "automation_run",
  "id": "run_04",
  "automationId": "auto_teams",
  "version": 0,
  "email": "ada@example.com",
  "contactId": "con_486cf92a1e02a43d335e2ff1",
  "status": "completed",
  "stepId": null,
  "source": "test",
  "test": true,
  "reason": null,
  "detail": "",
  "wakeAt": null,
  "startedAt": "2026-11-27T09:30:00.000Z",
  "finishedAt": "2026-11-27T09:30:00.000Z",
  "data": {},
  "steps": [
    {
      "id": "hello",
      "kind": "send_email",
      "name": "Your team is set up",
      "outcome": "sent",
      "detail": "",
      "emailId": "em_10",
      "at": "2026-11-27T09:30:00.000Z"
    },
    {
      "id": "wait_day",
      "kind": "delay",
      "name": "Delay",
      "outcome": "skipped",
      "detail": "Skipped in a test run.",
      "emailId": null,
      "at": "2026-11-27T09:30:00.000Z"
    },
    {
      "id": "tips",
      "kind": "send_email",
      "name": "Tips for teams",
      "outcome": "sent",
      "detail": "",
      "emailId": "em_11",
      "at": "2026-11-27T09:30:00.000Z"
    }
  ]
}
```
