Cancel workflow job

Requests cancellation of a specified workflow job. HTTP success does not mean that the job has been terminated; please read the return status or query the job details to confirm the final status.

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

Preparation before calling

First query job details and check whether available_actions contains cancellation. Prepare a personal access token and target workspace ID that has access to the target workspace.

The request body cannot contain runtime_context.

Request body

workflow_idstringRequired
Workflow ID.
execution_idstringRequired
Job ID.
reasonstring
Compatible field; currently does not affect cancellation processing.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID/executions/$EXECUTION_ID/cancel" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "reason": "<REASON>"
  }'

Successful response

Returns 200 when the service accepts the cancellation request and returns the job details at that time. The returned status can still be the current running status; query the job details to confirm the final cancellation status.

codestring
`OK` when successful.
msgstring
`OK` when successful.
data.execution.execution_idstring
Execution ID.
data.execution.workflow_idstring
Workflow ID.
data.execution.statusstring
Execution status when the cancellation request is accepted; this response alone does not confirm final cancellation.
data.execution.available_actionsstring[]
Currently allowed operations.
data.execution.execution_modestring
Execution mode.
data.execution.cron_expressionstring
Cron expression; only returned in timing mode.
data.execution.input_payloadobject
Expanded run input.
data.execution.vars_payloadobject
Expanded run variable.
data.execution.moi_task_idstring
Task ID; returned when the server has assigned it.
data.execution.moi_case_idstring
Case ID; returned when the server has assigned it.
data.execution.moi_workflow_def_idstring
Workflow definition identifier; returned when the server has assigned it.
data.execution.moi_workflow_version_idstring
Workflow version identifier; returned when the server has assigned it.
data.execution.pause_scopestring
Pause range; returned when there is a value.
data.execution.errorstring
Error message; returned if there is a value.
data.execution.started_atstring
Start time; may be omitted if not generated.
data.execution.ended_atstring
End time; may be omitted if not generated.
data.execution.created_atstring
Creation time; returned when provided by the server.
data.execution.updated_atstring
Last update time; returned when provided by the server.

Successful response example

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "execution": {
      "execution_id": "exec-001",
      "workflow_id": "wf-001",
      "status": "running",
      "available_actions": [],
      "execution_mode": "one_shot",
      "input_payload": {},
      "vars_payload": {}
    }
  }
}

Error response

codestring
Error code.
msgstring
Readable error message.
datanull
`null` in an error response.

Error response example

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

Follow-up operations

Use the same job ID query workflow job details to confirm the final status.

Last updated on