# View workflow job results

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

Read the execution results, node status and currently available actions of a workflow job. The result may still be in a non-final state; check the response for the result status rather than just relying on the HTTP status to determine success.

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

## 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 "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID/executions/$EXECUTION_ID/result" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::
::::

## Successful response

Returns `200` on success. Determine the current status of the result based on `data.result.status`.

::::{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.result.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.result.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.result.moi_task_id</code><span class="mo-api-field__type">string</span></dt><dd>Task ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.moi_case_id</code><span class="mo-api-field__type">string</span></dt><dd>Case ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.status</code><span class="mo-api-field__type">string</span></dt><dd>Current or final execution status.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.case_result</code><span class="mo-api-field__type">string</span></dt><dd>Execution result provided by the server; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.case_error</code><span class="mo-api-field__type">string</span></dt><dd>Execution error provided by the server; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.node_states</code><span class="mo-api-field__type">object[]</span></dt><dd>Node tracking status list. Each item may contain `span_id`, `parent_span_id`, `node_id`, `node_name`, `workitem_id`, Z XQPROTECT30TOKEN, `kind`, `status`, `error`, time, `duration_ms` and `attrs_json`. where `node_name` is the trace name, not the separate `node_key` field.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.available_actions</code><span class="mo-api-field__type">string[]</span></dt><dd>Operations allowed in the current state.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.trace</code><span class="mo-api-field__type">object</span></dt><dd>Trace data; return if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.trace_error</code><span class="mo-api-field__type">string</span></dt><dd>Trace read error; return if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.job_summary</code><span class="mo-api-field__type">object</span></dt><dd>The job summary returned when available, which can contain input, output, and step summaries.</dd></div>
  <div class="mo-api-field"><dt><code>data.result.rerun_context</code><span class="mo-api-field__type">object</span></dt><dd>This job is the source execution, node and status information returned when re-running.</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": {
    "result": {
      "execution_id": "exec-001",
      "workflow_id": "wf-001",
      "moi_task_id": "task-001",
      "moi_case_id": "case-001",
      "status": "completed",
      "case_result": "{}",
      "node_states": [
        {
          "span_id": "span-001",
          "node_name": "load",
          "status": "completed",
          "duration_ms": 1200
        }
      ],
      "available_actions": [],
      "job_summary": {
        "steps": [
          {
            "name": "load",
            "display_name": "加载数据",
            "status": "completed"
          }
        ]
      }
    }
  }
}
```

:::
::::

## 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 obtaining the node key from the workflow DSL, [query the workflow job node](get-workflow-job-node.md). In the current tracking data, the `node_name` of the node status is often displayed as `node:<NODE_KEY>`, but the actual node key in the DSL should still be passed when calling, instead of treating the display string as `node_key`.
