取消工作流作业

取消一个可取消的工作流作业。接口同步尝试取消并返回当前详情。外部工作是否停止仍需核对。

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

调用前准备

先查询工作流作业详情,确认该作业当前可以取消。准备具有工作流运行权限的个人访问令牌和目标工作区 ID。

请求体

curl -X POST "https://api.moi.matrixorigin.cn/v5/workflow/v2/workflow-apps/$WORKFLOW_ID/executions/$EXECUTION_ID/cancel" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"

参数

类型

是否必填

说明

workflow_id

string

是

工作流 ID。

execution_id

string

是

作业 ID。

请求不读取 JSON 正文。

请求体

此接口不读取请求体,也不接受取消原因,无需提交 JSON 正文。

成功响应

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "execution": {
      "execution_id": "run-001",
      "workflow_id": "wf-001",
      "status": "running",
      "execution_mode": "one_shot"
    }
  }
}

字段

类型

说明

code

string

成功代码。

msg

string

响应信息。

data

object

本次操作返回的数据。

data.execution

object

执行方式。

data.execution.execution_id

string

作业 ID。

data.execution.workflow_id

string

工作流 ID。

data.execution.status

string

状态。取值为 preparing、waiting、pending、triggered、running、completed、failed、cancelled、submitted、scheduled、paused、canceled、success、succeeded、queued、cancelling、canceling

data.execution.available_actions

string(字符串数组)

当前状态对应的操作提示,不表示已通过当前用户的权限检查。

data.execution.execution_mode

string

运行方式。取值为 one_shot、volume_trigger、cron、dynamic_service、task_by_version

data.execution.cron_expression

string

Cron 表达式。

data.execution.moi_task_id

string

任务 ID。

data.execution.moi_case_id

string

运行案例 ID。

data.execution.moi_workflow_def_id

string

工作流定义 ID。

data.execution.moi_workflow_version_id

string

工作流版本 ID。

data.execution.dispatch_job_id

string

卷分发作业 ID。

data.execution.pause_scope

string

暂停范围。取值为 execution、workflow

data.execution.error

string

错误信息。

data.execution.started_at

string

开始时间。采用 RFC 3339 格式。

data.execution.ended_at

string

结束时间。采用 RFC 3339 格式。

data.execution.created_at

string

创建时间。采用 RFC 3339 格式。

data.execution.updated_at

string

最近更新时间。采用 RFC 3339 格式。

data.execution.input_payload

object

运行输入对象允许扩展键。

data.execution.vars_payload

object

运行变量对象允许扩展键。

错误响应

{
  "code": "ErrConflict",
  "msg": "当前状态不能取消"
}

字段

类型

说明

code

string

错误代码。

msg

string

可读错误信息。

常见 HTTP 错误

HTTP 状态码

错误代码

常见原因

建议操作

400

ErrParamInvalid、ErrWorkspaceRequired

请求字段、工作区或操作前置条件无效。

修正参数后再提交。

401

Unauthorized

认证凭据缺失或无效。

检查凭据类型、有效期及认证头。

403

ErrForbidden

当前身份或有效角色无执行该操作的权限。

使用有权限的身份,或联系管理员授权。

404

ErrNotFound

目标对象或所需引用未找到。

核对对象标识、所属工作区和当前状态。

409

ErrConflict

资源状态、请求内容或并发条件冲突。

重新读取当前状态和版本,按实际结果处理。

500

ErrServer

内部处理失败;写操作可能已有部分效果。

保留请求和追踪信息,先核对当前结果。

503

ErrServiceUnavailable

业务、运行时或授权依赖暂不可用。

恢复依赖后先核对已有结果,不自动重复写入。

最后更新于