# Retry run

`opensend.runs.retry(id, input)`

Lets a run that failed go on from the step it failed at, on the version it entered with. An email it failed to send is really sent this time. It is refused for a run that did not fail.

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.
- `automationId` (string, required): The id of the automation. Up to 64 characters.

## 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.runs.retry('run_03', {
  automationId: 'auto_receipt',
})
```

CLI:

```bash
opensend runs retry run_03 --automation-id auto_receipt
```

Answer:

```json
{
  "object": "automation_run",
  "id": "run_03",
  "automationId": "auto_receipt",
  "version": 1,
  "email": "katherine@example.com",
  "contactId": null,
  "status": "waiting",
  "stepId": "wait_review",
  "source": "order.paid",
  "test": false,
  "reason": null,
  "detail": "",
  "wakeAt": "2026-11-30T09:30:00.000Z",
  "startedAt": "2026-11-27T04:30:00.000Z",
  "finishedAt": null,
  "data": {
    "order_id": "1038"
  },
  "steps": [
    {
      "id": "receipt",
      "kind": "send_email",
      "name": "Receipt",
      "outcome": "failed",
      "detail": "No value for total. Send it in the data of the event, or set it on the step.",
      "emailId": null,
      "at": "2026-11-27T04:30:00.000Z"
    },
    {
      "id": "receipt",
      "kind": "send_email",
      "name": "Receipt",
      "outcome": "sent",
      "detail": "",
      "emailId": "em_10",
      "at": "2026-11-27T09:30:00.000Z"
    },
    {
      "id": "wait_review",
      "kind": "delay",
      "name": "Delay",
      "outcome": "waiting",
      "detail": "Until 2026-11-30T09:30:00.000Z.",
      "emailId": null,
      "at": "2026-11-27T09:30:00.000Z"
    }
  ]
}
```
