查询自动化任务运行事件

分页读取一条自动化运行的生命周期事件。接口先检查运行记录,未找到时返回404;存在的运行也可能暂时没有事件。

GET https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-automation-runs/{run_id}/events

调用前准备

准备可读取目标工作区的个人访问令牌、工作区ID和运行ID。run_id取自运行回执或运行历史的id,不是自动化任务定义的ID。请求头X-Workspace-ID须与路径工作区一致。ID不得为空或有首尾空白,不得包含斜线或反斜线,长度不能超过128字节。

请求参数

curl "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agent-automation-runs/$RUN_ID/events?limit=2&offset=0" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"

需要下一页时,保留相同运行ID,按返回的offset + limit更新偏移。例如下一偏移为2时:

curl "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agent-automation-runs/$RUN_ID/events?limit=2&offset=2" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"

路径

参数

类型

是否必填

说明

workspace_id

string

是

目标工作区ID,与请求头一致。

run_id

string

是

要读取的运行ID。

请求头

参数

类型

是否必填

说明

X-API-Key

string

是

本页示例采用的个人访问令牌。

X-Workspace-ID

string

是

目标工作区ID。

查询参数

参数

类型

是否必填

说明

limit

integer

否

默认50,最大200;0或负值使用默认值。

offset

integer

否

默认0,负值归0。

按返回的生效值继续分页,不依赖非法整数的容错结果。

成功响应

{
  "code": 0,
  "data": {
    "items": [
      {
        "id": "event_01",
        "workspace_id": "ws_01",
        "run_id": "run_01",
        "automation_task_id": "task_01",
        "type": "workflow_submitted",
        "status": "queued",
        "message": "automation run submitted to Workflow",
        "created_at": "2026-11-11T06:59:59Z"
      },
      {
        "id": "event_02",
        "workspace_id": "ws_01",
        "run_id": "run_01",
        "automation_task_id": "task_01",
        "type": "run_running",
        "status": "running",
        "message": "automation run execution started",
        "created_at": "2026-11-11T07:00:00Z"
      }
    ],
    "total": 3,
    "limit": 2,
    "offset": 0
  }
}

字段

类型

说明

code

integer

成功为0。

data

object

本次读取结果。

data.items

object(对象数组)

当前页事件,空页返回[]。

data.total

integer

该运行的事件总数,不是当前页条数。

data.limit

integer

本次生效的页大小。

data.offset

integer

本次生效的零基偏移。

data.items[].id

string

事件ID。

data.items[].workspace_id

string

事件所属工作区ID。

data.items[].run_id

string

事件所属运行ID。

data.items[].automation_task_id

string

事件所属任务定义ID。

data.items[].type

string

事件类型。按返回值处理,不将示例当完整枚举。

data.items[].status

string

事件发生时的运行状态。未设置时不返回,不代替当前详情状态。

data.items[].message

string

事件说明。为空时不返回。

data.items[].created_at

string

事件创建时间,RFC 3339格式。

事件按created_at升序、同时间id升序返回;不返回内部事件data字段。按返回的offset + limit请求下一页,达到total或得到空页时停止。空事件页不代表运行已结束,应以运行当前状态判断;并发新增事件时,当前页不是固定的全量快照。

错误响应

运行未找到时的HTTP 404:

{
  "code": 3,
  "message": "agent automation run not found"
}

身份校验阶段的HTTP 401示例:

{
  "code": "Unauthorized",
  "msg": "Unauthorized"
}

错误字段

字段

类型

说明

code

integer 或 string

业务handler使用数字;认证阶段可返回字符串代码。

message

string

业务handler的错误说明。

msg

string

部分认证错误使用此字段。

常见 HTTP 错误

HTTP

code

说明

400

2

路径、工作区或参数不合法。

401

取决于认证阶段

未通过身份校验;不要假设所有401都是数字6。

403

5

没有读取权限。

404

3

目标工作区中未找到运行记录。

500

1

内部读取失败,消息为internal error。

503

15

鉴权或自动化运行服务依赖不可用。

最后更新于