# Rerun from specified node

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

Creates a rerun branch from the specified node where the job has been executed. Successful creation does not mean that the branch is completed; please check the re-run details to confirm the status.

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

## Preparation before calling

First [View node rerun plan](get-node-rerun-plan.md), and save its `rerun_contract_hash` and node execution ID if needed. 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></dt><dd>Workflow ID.</dd></div>
<div class="mo-api-field"><dt><code>execution_id</code><span class="mo-api-field__type">string</span></dt><dd>Source job ID.</dd></div>
<div class="mo-api-field"><dt><code>node_key</code><span class="mo-api-field__type">string</span></dt><dd>The node key to start the rerun from.</dd></div>
<div class="mo-api-field"><dt><code>mode</code><span class="mo-api-field__type">string</span></dt><dd>Rerun mode; must be taken from planned `available_modes`.</dd></div>
<div class="mo-api-field"><dt><code>source_node_execution_id</code><span class="mo-api-field__type">string</span></dt><dd>The selected source node execution ID.</dd></div>
<div class="mo-api-field"><dt><code>expected_rerun_contract_hash</code><span class="mo-api-field__type">string</span></dt><dd>The contract hash returned by the plan, used to avoid using expired plans.</dd></div>
<div class="mo-api-field"><dt><code>values</code><span class="mo-api-field__type">object</span></dt><dd>Runtime input override value.</dd></div>
<div class="mo-api-field"><dt><code>config_override</code><span class="mo-api-field__type">object</span></dt><dd>Node configuration override value.</dd></div>
<div class="mo-api-field"><dt><code>reason</code><span class="mo-api-field__type">string</span></dt><dd>Reason for rerun.</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/nodes/$NODE_KEY/reruns" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "mode": "continue_from_node",
    "expected_rerun_contract_hash": "'"$RERUN_CONTRACT_HASH"'"
  }'
```

:::
::::

## Successful 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>`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.rerun.rerun_id</code><span class="mo-api-field__type">string</span></dt><dd>Rerun ID.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.branch_id</code><span class="mo-api-field__type">string</span></dt><dd>New branch ID.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.case_id</code><span class="mo-api-field__type">string</span></dt><dd>The case ID of the new branch.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.source_execution_id</code><span class="mo-api-field__type">string</span></dt><dd>Source job ID.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.node_key</code><span class="mo-api-field__type">string</span></dt><dd>The node key of the rerun starting point.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.source_node_execution_id</code><span class="mo-api-field__type">string</span></dt><dd>Source node execution ID.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.mode</code><span class="mo-api-field__type">string</span></dt><dd>The actual rerun mode used.</dd></div>
<div class="mo-api-field"><dt><code>data.rerun.status</code><span class="mo-api-field__type">string</span></dt><dd>New branch status.</dd></div>
<div class="mo-api-field"><dt><code>data.start_error</code><span class="mo-api-field__type">string</span></dt><dd>Error message when starting; only returned if there is a value.</dd></div>
<div class="mo-api-field"><dt><code>data.refresh_error</code><span class="mo-api-field__type">string</span></dt><dd>Error message when refreshing; only returned if there is a value.</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": {
    "rerun": {
      "rerun_id": "rerun-001",
      "branch_id": "branch-001",
      "case_id": "case-001",
      "source_execution_id": "exec-001",
      "node_key": "root.load",
      "source_node_execution_id": "node-exec-001",
      "mode": "continue_from_node",
      "status": "running"
    }
  }
}
```

:::
::::

## 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": "contract_drift_detected",
  "msg": "重新运行计划已变化",
  "data": null
}
```

:::
::::

## Follow-up operations

[View workflow rerun details](get-workflow-rerun.md) confirms branch status.
