> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rerun a Workflow Run

> Start an existing workflow run again from its trigger input or from the failed step

Starts an existing run again. It does the same as **Rerun from start** and **Rerun from failure** on a failed run in the builder. A completed (`COMPLETED`) run is included only when the request asks, and only from the start.

## Base URL

```
https://api.langdock.com/workflows/v1/rerun
```

> [!WARNING]
>
> **Dedicated deployments**
>
> Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.

## Required scopes

This endpoint requires the `WORKFLOW_WRITE_API` scope (**Workflow Write API**) and editor access. The call runs as the key's user.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `workflowId` | string | Yes | UUID of the workflow. |
| `runId` | string | Yes | UUID of the run to start again. It must belong to the workflow. |
| `mode` | string | No | `fromStart` (default) or `fromFailure`. |
| `allowCompleted` | boolean | No | Set to `true` to also start a `COMPLETED` run again. Only with `fromStart`. Default: `false`. |

## Modes

* `fromStart` starts a new run with the source run's trigger input. Failed runs and runs a limit stopped before they started (`BLOCKED`) qualify. With `allowCompleted: true`, a `COMPLETED` run qualifies too.
* `fromFailure` keeps the completed steps and continues at the failed step. It accepts a failed run with one failed path. A `BLOCKED` run requested this way starts from the beginning, and the response reports `fromStart`. `allowCompleted` with `fromFailure` is rejected.

The new run uses the published version, or the draft when nothing is published. A private run uses the version its owner's setup runs, and only that owner can start it again. A meeting payload stays with the meeting owner. The call returns not found for anyone else.

A rerun repeats every step that runs again, including actions in connected services. A `BLOCKED` run can be started again only once. A failed integration trigger that still has its event has to be replayed from the start.

## Limits and audit log

A workflow starts at most 20 reruns per minute through the API, across keys. Further requests return `429` with `WORKFLOW_RERUN_RATE_LIMITED`. Rejected requests don't count. The workflow's own run limits still apply.

Each started rerun is recorded in the [audit log](https://docs.langdock.com/en/developer/audit-logs-api/intro-to-audit-logs-api.md) as `workflow_run.rerun`, with the API key as the actor.

## Example

```javascript theme={null}
const axios = require("axios");

async function rerunWorkflowRun(workflowId, runId) {
  const response = await axios.post(
    "https://api.langdock.com/workflows/v1/rerun",
    {
      workflowId,
      runId,
      mode: "fromStart"
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log("New run:", response.data.runId);
}

rerunWorkflowRun(
  "550e8400-e29b-41d4-a716-446655440000",
  "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
);
```

## Response format

### Success response (202 Accepted)

```typescript theme={null}
{
  status: "success";
  message: "Workflow rerun started";
  runId: string; // the new run
  sourceRunId: string;
  mode: "fromStart" | "fromFailure";
}
```

`mode` is the mode the rerun actually used. The new run starts in the background. Read its results with [List Workflow Runs](https://docs.langdock.com/en/developer/workflow-api/list-workflow-runs.md) and `runId`. That call needs the `WORKFLOW_API` scope.

## Error handling

| Status code | Description |
| - | - |
| 400 | Invalid body, a status this mode cannot start again, a completed run without `allowCompleted`, `allowCompleted` with `fromFailure`, a run without trigger data, a failed step that is no longer in the workflow, a run without exactly one failed path, a failed integration trigger that must be replayed from the start, or a template workflow |
| 401 | Invalid or missing API key |
| 403 | Missing `WORKFLOW_WRITE_API` scope or editor access. A missing workflow or a workflow in another workspace also returns this status. |
| 404 | The run doesn't exist in this workflow, or a meeting payload belongs to someone else |
| 409 | `WORKFLOW_BLOCKED_RUN_ALREADY_RERUN`: this blocked run was already started again |
| 429 | Rate limit exceeded, `WORKFLOW_RERUN_RATE_LIMITED`, or a workflow run limit (`WORKFLOW_LIMIT_EXCEEDED`, `WORKFLOW_MONTHLY_LIMIT`, `WORKFLOWS_MONTHLY_CAP_REACHED`, `WORKSPACE_SPEND_CAP`, `TRIAL_BUDGET`, `PREPAID_CREDITS`) |
| 500 | Internal server error |

> [!NOTE]
>
> Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](https://docs.langdock.com/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.