# Refresh workflow job status

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

Requests the service to read the latest execution status of the specified job. What is returned is the status read this time and does not represent a forced change to the job execution status.

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

## Preparation before calling

First [query the workflow job list](list-workflow-jobs.md) to obtain the workflow ID and execution ID. Prepare a personal access token and target workspace ID that has access to the target workspace.

## Path parameters

::::{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>Job ID.</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/refresh" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::
::::

## Successful response

Returns `200` on success. `data.execution` is consistent with the job object in [View workflow job details](get-workflow-job.md).

::::{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.execution</code><span class="mo-api-field__type">object</span></dt><dd>The execution details read after refreshing.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.execution_id</code><span class="mo-api-field__type">string</span></dt><dd>Execution ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.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.execution.status</code><span class="mo-api-field__type">string</span></dt><dd>Current status.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.available_actions</code><span class="mo-api-field__type">string[]</span></dt><dd>Currently allowed operations.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.execution_mode</code><span class="mo-api-field__type">string</span></dt><dd>Execution mode.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.cron_expression</code><span class="mo-api-field__type">string</span></dt><dd>Cron expression; only returned in timing mode.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.input_payload</code><span class="mo-api-field__type">object</span></dt><dd>Expanded run input.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.vars_payload</code><span class="mo-api-field__type">object</span></dt><dd>Expanded run variable.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.moi_task_id</code><span class="mo-api-field__type">string</span></dt><dd>Task ID; returned when the server has assigned it.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.moi_case_id</code><span class="mo-api-field__type">string</span></dt><dd>Case ID; returned when the server has assigned it.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.moi_workflow_def_id</code><span class="mo-api-field__type">string</span></dt><dd>Workflow definition identifier; returned when the server has assigned it.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.moi_workflow_version_id</code><span class="mo-api-field__type">string</span></dt><dd>Workflow version identifier; returned when the server has assigned it.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.pause_scope</code><span class="mo-api-field__type">string</span></dt><dd>Pause range; returned when there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.error</code><span class="mo-api-field__type">string</span></dt><dd>Error message; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.started_at</code><span class="mo-api-field__type">string</span></dt><dd>Start time; may be omitted if not generated.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.ended_at</code><span class="mo-api-field__type">string</span></dt><dd>End time; may be omitted if not generated.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.created_at</code><span class="mo-api-field__type">string</span></dt><dd>Creation time; may be omitted if not generated.</dd></div>
  <div class="mo-api-field"><dt><code>data.execution.updated_at</code><span class="mo-api-field__type">string</span></dt><dd>Last updated time; may be omitted if not generated.</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": {
    "execution": {
      "execution_id": "exec-001",
      "workflow_id": "wf-001",
      "status": "running",
      "available_actions": ["pause", "cancel"],
      "execution_mode": "one_shot",
      "input_payload": {},
      "vars_payload": {}
    }
  }
}
```

:::
::::

## 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": "ErrNotFound",
  "msg": "资源不存在",
  "data": null
}
```

:::
::::

## Follow-up operations

After the status is updated, when output is required [query workflow job results](get-workflow-job-result.md).
