# Bulk Restart Workflows from DLQ

> Restart multiple failed workflow runs from the DLQ. Each workflow will start from the beginning.

## Endpoint

`POST https://qstash-{region}.upstash.io/v2/workflows/dlq/restart`

Restart multiple failed workflow runs from the DLQ. Each workflow will start from the beginning.

Unlike resume, which continues from where workflows failed, restart executes the entire workflows
from the first step. New workflow run IDs are generated and all steps will be executed again.

A maximum of 50 workflow runs can be restarted per request. If more runs are available, a cursor is returned, which can be used in subsequent requests to continue the operation. When no cursor is returned, all entries have been processed.
Each restarted workflow run is assigned a new random Run ID.


## Parameters

- `dlqIds` (query, string[]): List of specific DLQ IDs to restart. If provided, other filters are ignored.
- `cursor` (query, string): Pagination cursor for restarting workflows in batches.
- `count` (query, integer): Maximum number of workflows to restart. If not provided, all matching workflows will be restarted.
- `fromDate` (query, integer): Filter workflows by starting date, in milliseconds (Unix timestamp). This is inclusive.
- `toDate` (query, integer): Filter workflows by ending date, in milliseconds (Unix timestamp). This is inclusive.
- `workflowUrl` (query, string[]): Filter workflows by workflow URL. Supports multiple values.
- `workflowRunId` (query, string): Filter workflows by workflow run ID.
- `workflowCreatedAt` (query, integer): Filter workflows by creation timestamp in milliseconds (Unix timestamp).
- `label` (query, string[]): Filter workflows by label. Supports multiple values. You can pass multiple values to match workflows with any of the given labels (OR logic).

Examples:
- `label=my_label`
- `label=label_1&label=label_2`
- `label=label_1,label_2`

- `failureFunctionState` (query, string[]): Filter workflows by failure function state. Supports multiple values.

| State | Description |
|--------|--------------|
| CALLBACK_INPROGRESS | The failure function is in progress. |
| CALLBACK_SUCCESS | The failure function run successfully. |
| CALLBACK_FAIL | The failure function failed to run. |
| CALLBACK_CANCELED | The failure function was manually canceled |

- `callerIp` (query, string[]): Filter workflows by IP address of the publisher. Supports multiple values.
- `flowControlKey` (query, string[]): Filter workflows by Flow Control Key. Supports multiple values.
- `Upstash-Retries` (header, integer): Override the number of retries for the workflow steps.
- `Upstash-Delay` (header, string): Override the delay before executing the workflows. Format is `<value><unit>` (e.g., "10s", "5m").
- `Upstash-Retry-Delay` (header, string): Override the retry delay expression for the workflow steps.
- `Upstash-Flow-Control-Key` (header, string): Override the flow control key for the workflows.
- `Upstash-Flow-Control-Value` (header, string): Override the flow control configuration in the format `parallelism=<value>, rate=<value>, period=<value>`.
- `Upstash-Label` (header, string): Override the label(s) for the workflows.

You can assign multiple labels by providing a comma-separated list.

Example: `label_1,label_2`

- `Upstash-Failure-Callback` (header, string): Override the failure callback URL for the workflows.

## Responses

### 200 - Workflows restarted successfully

- `workflowRuns` (object[]): Array of restarted workflow runs.
  - `workflowRunId` (string): The ID of the restarted workflow run (a new ID is generated for each restarted run).
  - `workflowCreatedAt` (integer): The timestamp when the restarted workflow run was created (Unix timestamp in milliseconds).
- `cursor` (string): Pagination cursor to use in subsequent requests. If empty, all matching workflows have been processed.

### 400 - Bad Request

- `error` (string, required): Error message

### 401 - Unauthorized

- `error` (string, required): Error message

### 404 - Some DLQ messages were not found

- `error` (string, required): Error message

### 500 - Internal Server Error

- `error` (string, required): Error message

## cURL

```bash
curl --request POST \
  --url https://qstash-{region}.upstash.io/v2/workflows/dlq/restart \
  --header 'Authorization: Bearer <token>'
```
