# retry()

Canonical URL: https://developers.iagenify.com/sdk/ref/workflow-run/retry/
Language: en

`run.retry(stepId?) → Promise<WorkflowRun>`

Runs the chain again from a step — the failed one by default. Everything before it is kept, and the replaced attempt is kept too.

Status: from the failure · earlier outputs kept · attempts are recorded

```javascript
await run.retry();            // from whichever step failed
await run.retry("transform");  // from a chosen step
```

## What is kept {#kept}

- Every step before the one you restart from, with its output — nothing is recomputed.
- The replaced attempt, moved into that step's `attempts`.
- The run's identifier: it is the same run, continued.

> **Not recomputing the earlier steps is the point**
>
> A chain that failed at step five has already paid for four. Re-running the whole thing would pay again and could repeat an effect — a second message, a second write.

## What it is for {#when}

- A transient failure — a service that was briefly down.
- A fixed configuration: change the workflow, then retry the run against the new definition.
- A step whose input was wrong, once whatever produced it is corrected.

## When it is refused {#errors}

| Code | When |
| --- | --- |
| run_not_retryable | The run is still going, or a step before the one chosen did not succeed. |

The second half of that is the useful guard: restarting from step five when step four failed would run five on something that never happened.

## Effects are repeated, not resumed {#effects}

> **A retried step does its work again**
>
> If a storage write succeeded and a later step failed, retrying from the write writes twice. Choose the step to restart from with that in mind — the default, the failed one, is usually right for exactly this reason.

- [data](/sdk/ref/workflow-run/data): Where attempts are kept.
- [runStep()](/sdk/ref/workflow/run-step): Trying a step without touching the run.

```python
run.retry()               # from whichever step failed
run.retry("transform")    # from a chosen step
```
