# Pause workflow job

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

Requests to pause the specified workflow job. Acceptance of the request does not mean that execution has stopped in all run units; please read the return status or query the details again to confirm.

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

## Preparation before calling

First [query job details](get-workflow-job.md) and check whether `available_actions` contains pause. 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/pause" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::
::::

## Successful response

Returns `200` on success. `data.execution` returns the current execution information processed by the server.

::::{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.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 execution status; use this to confirm whether it has been paused.</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.pause_scope</code><span class="mo-api-field__type">string</span></dt><dd>The pause range provided by the server; returned when there is a value.</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.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; returned if there is a value.</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; returned if there is a value.</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; returned if there is a value.</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; 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": {
    "execution": {
      "execution_id": "exec-001",
      "workflow_id": "wf-001",
      "status": "paused",
      "available_actions": ["resume", "cancel"],
      "execution_mode": "one_shot",
      "pause_scope": "workflow",
      "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": "ErrConflict",
  "msg": "资源状态冲突",
  "data": null
}
```

:::
::::

## Follow-up operations

[Resume workflow job](resume-workflow-job.md) when you need to continue. Use the same job ID [View workflow job details](get-workflow-job.md) to confirm the status.
