# Retry workflow job

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Retry a workflow job. A successful request does not mean that the retry has been completed; please check the details of the new job to confirm the status.

```text
POST https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/{workflow_id}/executions/{execution_id}/retry
```

## Preparation before calling

First [query job details](../workflow-jobs/get-workflow-job.md) to confirm that the current status of the job supports retry. Prepare a personal access token and target workspace ID that has access to the target workspace.


## Request body

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>workflow_id</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Workflow ID.</dd></div>
  <div class="mo-api-field"><dt><code>execution_id</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>The job ID to retry.</dd></div>
  <div class="mo-api-field"><dt><code>values</code><span class="mo-api-field__type">object</span></dt><dd>Runtime input value to use when retrying.</dd></div>
  <div class="mo-api-field"><dt><code>trigger_now</code><span class="mo-api-field__type">boolean</span></dt><dd>Whether to trigger retry immediately.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Request example</p>
```

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID/executions/$EXECUTION_ID/retry" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "trigger_now": true
  }'
```

:::
::::

## Successful response

Returns `200` on success. `data.workflow_run` returns the execution information corresponding to the retry request; saves the new execution ID for querying the status of the retry job.


The response fields are as follows.

In field paths, `[]` denotes each item in an array. For example, `items[].name` is the `name` field of each item in the `items` array. After a type, `[]` denotes an array; for example, `string[]` is an array of strings.

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">string</span></dt><dd>OK when successful.</dd></div>
  <div class="mo-api-field"><dt><code>msg</code><span class="mo-api-field__type">string</span></dt><dd>OK when successful.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.execution_id</code><span class="mo-api-field__type">string</span></dt><dd>New job ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.workflow_id</code><span class="mo-api-field__type">string</span></dt><dd>Workflow ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.status</code><span class="mo-api-field__type">string</span></dt><dd>The current status of the new job.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.execution_mode</code><span class="mo-api-field__type">string</span></dt><dd>Workflow execution mode.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.available_actions</code><span class="mo-api-field__type">string[]</span></dt><dd>Currently available operations; only returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.workflow_run.error</code><span class="mo-api-field__type">string</span></dt><dd>Job error message; only returned if there is an error.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Successful response example</p>
```

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "workflow_run": {
      "execution_id": "exec-002",
      "workflow_id": "wf-001",
      "status": "submitted",
      "execution_mode": "one_shot"
    }
  }
}
```

:::
::::

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">string</span></dt><dd>Error code.</dd></div>
  <div class="mo-api-field"><dt><code>msg</code><span class="mo-api-field__type">string</span></dt><dd>Readable error message.</dd></div>
  <div class="mo-api-field"><dt><code>data</code><span class="mo-api-field__type">null</span></dt><dd>`null` in an error response.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Error response example</p>
```

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

:::
::::

## Follow-up operations

Use new execution ID [query workflow job details](../workflow-jobs/get-workflow-job.md).
