# Query automation task running events

Query the life cycle events of an automated task running record.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-automation-runs/{run_id}/events
```

## Preparation before calling

Prepare to run the record ID, personal access token with access to the target workspace, and the target workspace ID.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through the `X-Workspace-ID` Header and also as `workspace_id` in the path.
- `$RUN_ID`: To query the running record ID of the event, use it as `run_id` in the path.

## Request example

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

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Workspace ID. |
| `run_id` | string | Yes | Run record ID. |

## Query parameters

When `limit` or `offset` is not provided, the service returns 50 records by default and starts from record 0; the maximum value for `limit` is 200.

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `limit` | integer | No | Return the quantity. |
| `offset` | integer | No | Returns the starting position of the list. |

## Successful response

Returns `200` on success. `data.items` is the event list, `data.total` is the total number of matches.

```json
{
  "code": 0,
  "data": {
    "items": [
      {
        "id": "event_01",
        "workspace_id": "ws_01",
        "run_id": "run_01",
        "automation_task_id": "task_01",
        "type": "status_changed",
        "status": "running",
        "message": "运行已开始。",
        "created_at": "2026-08-18T04:00:00Z"
      }
    ],
    "total": 1,
    "limit": 50,
    "offset": 0
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.items` | array | Run life cycle events. |
| `data.items[].id` | string | Event, workspace, run, and task identifiers. |
| `data.items[].workspace_id` | string | Event, workspace, run, and task identifiers. |
| `data.items[].run_id` | string | Event, workspace, run, and task identifiers. |
| `data.items[].automation_task_id` | string | Event, workspace, run, and task identifiers. |
| `data.items[].type` | string | Event type, optional status, and description. |
| `data.items[].status` | string | Event type, optional status, and description. |
| `data.items[].message` | string | Event type, optional status, and description. |
| `data.items[].created_at` | string | Event creation time, using RFC 3339 format. |
| `data.total` | integer | Total number of matches, current page size, and offset. |
| `data.limit` | integer | Total number of matches, current page size, and offset. |
| `data.offset` | integer | Total number of matches, current page size, and offset. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Error response

```json
{
  "code": 3,
  "message": "<错误信息>"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter is invalid.
  - Check workspace and run ID.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `404`
  - `3`（`NOT_FOUND`）
  - The running record does not exist.
  - Query the running list first.
* - `503`
  - `15`（`UNAVAILABLE`）
  - The automated task service is unavailable.
  - Try again later.
```

## Follow-up operations

The status in the event is used to assist diagnosis; for the final output, please [Query the results of automated task execution](get-run-result.md).
