# 列出动作调用 (/docs/api/native/automation/listActionInvocations)





列出该动作的调用记录，可按状态、修订、调用方编排和时间筛选；结果包含所属运行与调用位置。

`GET /automation/v1/actions/{ns}/{name}/invocations`

## 鉴权 [#鉴权]

`Authorization: Bearer $PRAXIS_API_KEY`

## 请求字段 [#请求字段]

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| path: ns | `string` | 必填；命名空间，存储前转为小写，格式 [a-z0-9][a-z0-9._-]&#123;0,63&#125;；praxis 只读。 |
| path: name | `string` | 必填；名称，存储前转为小写，格式 [a-z0-9][a-z0-9._-]&#123;0,63&#125;。 |
| query: limit | `integer` | 可选；每页条数，整数 1–100，默认 20。 minimum: 1；maximum: 100 |
| query: cursor | `string` | 可选；上一页返回的 next_cursor，不透明字符串；保持原查询条件继续翻页。 |
| query: status | `"running"` / `"completed"` / `"faulted"` / `"cancelled"[]` | 可选；逗号分隔的状态，可选 running、completed、faulted、cancelled；省略不过滤。 |
| query: revision | `string` | 可选；动作修订 ID（actr_）；查询参数用于筛选调用记录。 |
| query: caller | `string` | 可选；调用方脚本或工作流的精确名称，格式 ns/name。 |
| query: run_kind | `"script"` / `"workflow"` | 可选；调用方运行类型：script 或 workflow。 |
| query: created_at[gte] | `string` | 可选；创建时间下界（包含），RFC 3339 且带时区，如 2026-10-01T00:00:00Z。 format: "date-time" |

## 示例 [#示例]

[SDK 安装与示例环境](/docs/api/native/automation)

先设置以下环境变量，使用你自己的资源：

| 变量 | 来源 |
| --- | --- |
| ACTION_NAME | [创建动作返回的 name](/docs/api/native/automation/createAction) |

```bash
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/invocations" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
```

```typescript
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.invocations.list({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  }
});
console.log(result);
```

## 响应 [#响应]

### HTTP 200 [#http-200]

Success

`application/json`

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| data | `object[]` | 必填 / 必有；本页的动作调用记录，按 created_at 倒序、id 倒序排列。 |
| data[].id | `string` | 必填 / 必有；调用标识，无独立 inv_ 前缀：脚本为 run_id:seq（运行 ID 与调用序号）；工作流为任务执行键加尝试次数。请按不透明字符串保存。 |
| data[].created_at | `string` | 必填 / 必有；调用记录的创建时间（RFC 3339 UTC）。 |
| data[].started_at | `null` / `string` | 必填 / 必有；动作开始执行的时间；尚未开始为 null。 |
| data[].ended_at | `null` / `string` | 必填 / 必有；动作结束的时间；仍在执行为 null。 |
| data[].status | `"running"` / `"completed"` / `"faulted"` / `"cancelled"` | 必填 / 必有；调用状态。running 执行中；completed 已正常返回；faulted 失败，error 给出原因；cancelled 因运行被取消而中止。 |
| data[].duration_ms | `null` / `number` | 必填 / 必有；执行耗时毫秒数；未结束为 null。 |
| data[].revision | `string` | 必填 / 必有；本次执行使用的动作修订 ID（actr_ 前缀）。 |
| data[].run | `object` | 必填 / 必有；发起这次调用的运行：&#123;id, kind, definition, number, source_digest&#125;。 不接受额外字段。 |
| data[].run.id | `string` | 必填 / 必有；发起调用的运行 ID（run_ 前缀），可用于读取该运行。 |
| data[].run.kind | `"script"` / `"workflow"` | 必填 / 必有；编排类型。script 为 TypeScript 脚本，一次执行；workflow 为 YAML 工作流，由步骤组成，可等待事件、定时器或子运行并可暂停。 |
| data[].run.definition | `null` / `object` | 必填 / 必有；该运行所属的脚本或工作流 &#123;namespace, name&#125;；临时运行为 null。 |
| data[].run.definition（分支2).namespace | `string` | 必填 / 必有；脚本或工作流的命名空间。 |
| data[].run.definition（分支2).name | `string` | 必填 / 必有；脚本或工作流的名字。 |
| data[].run.number | `null` / `number` | 必填 / 必有；运行在其脚本或工作流内的序号；临时运行为 null。 |
| data[].run.source_digest | `null` / `string` | 必填 / 必有；临时运行的源码摘要；由已发布定义启动的运行为 null。 |
| data[].site | `object` / `object` | 必填 / 必有；调用发生的位置：脚本中的一次调用（kind=call，带 seq），或工作流的一个步骤（kind=task，带 reference 与 iteration）。 |
| data[].site（分支1).kind | `"call"` | 必填 / 必有；固定为 call：来自脚本中的调用。 |
| data[].site（分支1).seq | `number` | 必填 / 必有；该调用在脚本运行中的序号，与 Call.seq 对应。 |
| data[].site（分支2).kind | `"task"` | 必填 / 必有；固定为 task：来自工作流步骤。 |
| data[].site（分支2).reference | `string` | 必填 / 必有；工作流文档内该步骤的 JSON Pointer，与 Task.reference 对应。 |
| data[].site（分支2).iteration | `number[]` | 必填 / 必有；外层 for 循环的当前迭代下标，由外到内；不在循环中为空数组。 |
| data[].error | `null` / `object` | 必填 / 必有；失败时的 &#123;code, message&#125;；成功或仍在执行为 null。 |
| data[].error（分支2).code | `string` | 必填 / 必有；错误码，例如动作声明的 code 或平台错误码。 |
| data[].error（分支2).message | `string` | 必填 / 必有；错误说明文字。 |
| data[].result_preview | `null` / `string` | 必填 / 必有；返回值的单行预览，由服务端截断；未结束或失败为 null。 |
| data[].request_id | `string` / `null` | 必填 / 必有；下游响应的 X-Request-Id；响应未提供该头时为 null，可用于追查失败调用。 |
| next_cursor | `null` / `string` | 必填 / 必有；下一页游标，原样传给 cursor 参数并保持原查询条件；没有更多页为 null。接口不返回总数。 |

### 实测响应 [#实测响应]

HTTP 200

```json
{
  "data": [],
  "next_cursor": null
}
```

## 错误码 [#错误码]

| HTTP | 错误码与说明 |
| --- | --- |
| 400 | INVALID_PARAMS：请求参数、路径、游标或请求体格式无效。 |
| 404 | ACTION_NOT_FOUND：动作不存在或当前租户不可见；同名脚本/工作流存在时，hint 指向相应接口。 |
| default | RFC 9457 automation problem. 429 includes Retry-After. |

[鉴权错误与通用错误](/docs/api/errors) · 排查时保留响应头 `X-Request-Id`。
