# 读取动作修订 (/docs/api/native/automation/getActionRevision)





读取指定修订的完整实现及回滚兼容判定；修订不存在时返回 VERSION_NOT_FOUND。 详情始终返回完整源码。

`GET /automation/v1/actions/{ns}/{name}/revisions/{revision}`

## 鉴权 [#鉴权]

`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;。 |
| path: revision | `string` | 必填；动作修订 ID（actr_）；查询参数用于筛选调用记录。 |

## 示例 [#示例]

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

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

| 变量 | 来源 |
| --- | --- |
| ACTION_NAME | [创建动作返回的 name](/docs/api/native/automation/createAction) |
| REVISION_ID | [已有动作修订 id](/docs/api/native/automation/listActionRevisions) |

```bash
: "${ACTION_NAME:?Set ACTION_NAME}"
: "${REVISION_ID:?Set REVISION_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/revisions/${REVISION_ID}" \
  -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.revisions.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME"),
    "revision": env("REVISION_ID")
  }
});
console.log(result);
```

## 响应 [#响应]

### HTTP 200 [#http-200]

Success

`application/json`

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| current | `boolean` | 必填 / 必有；true 表示这是动作当前生效的修订。 |
| rollback | `object` | 必填 / 必有；回滚到该修订是否可行，由服务端对当前修订做兼容判定。 不接受额外字段。 |
| rollback.allowed | `boolean` | 必填 / 必有；true 表示可以回滚到此修订；false 时 issues 说明原因。 |
| rollback.issues | `object[]` | 必填 / 必有；回滚会产生的不兼容项，每项含 pointer 与 reason；allowed 为 true 时为空数组。 |
| rollback.issues[].pointer | `string` | 必填 / 必有；不兼容位置的 JSON Pointer（RFC 6901），相对于动作的 input_schema 或 output_schema。 |
| rollback.issues[].reason | `string` | 必填 / 必有；该位置为何与历史修订不兼容（输入应放宽、输出应收紧）。 |
| id | `string` | 必填 / 必有；修订 ID，前缀 actr_；仅用于展示与回滚（rollback 的 revision），不能被脚本直接引用。 |
| digest | `string` | 必填 / 必有；契约与实现的内容摘要；内容相同的更新不会产生新修订。 |
| input_schema | `object` | 必填 / 必有；任意 JSON 对象（键为字符串，值为任意 JSON 值）。 |
| input_schema.*（分支5) | `object` | 递归 JSON 值。 |
| input_schema.*（分支6)[] | `null` / `string` / `number` / `boolean` / `object` / `JSON[]` | 递归 JSON 值。 |
| output_schema | `object` | 必填 / 必有；任意 JSON 对象（键为字符串，值为任意 JSON 值）。 |
| output_schema.*（分支5) | `object` | 递归 JSON 值。 |
| output_schema.*（分支6)[] | `null` / `string` / `number` / `boolean` / `object` / `JSON[]` | 递归 JSON 值。 |
| errors | `object[]` | 必填 / 必有；动作声明的可能错误列表，每项含 type、code、description。 |
| errors[].type | `string` | 必填 / 必有；错误类型：稳定的 URI，或 Open Workflow 标准类型（如 validation、timeout、communication、runtime）。 |
| errors[].code | `string` | 可选；可选的稳定错误码，供调用方按码分支处理。 |
| errors[].description | `string` | 必填 / 必有；该错误的含义与触发条件，面向调用方阅读。 |
| annotations | `object` | 必填 / 必有；动作行为声明 &#123;read_only, idempotent&#125;；创建时未给出的键默认为 false。 不接受额外字段。 |
| annotations.read_only | `boolean` | 必填 / 必有；true 表示动作不修改外部状态，只读取数据。 |
| annotations.idempotent | `boolean` | 必填 / 必有；true 表示同一输入重复调用与调用一次效果相同；此类动作的重试使用同一幂等键（run_id 加步骤路径，不含尝试次数）。 |
| timeout_ms | `number` | 必填 / 必有；单次执行的超时毫秒数；创建时未给出，code 实现默认 30000，容器或 shell 实现默认 600000。 |
| implementation | `object` / `object` / `object` | 必填 / 必有；code 使用 language=ts 与 source。container 和 shell 暂未开放，创建时返回 OPERATION_NOT_SUPPORTED。 |
| implementation（分支1).kind | `"code"` | 必填 / 必有；固定为 code：以源码实现。 |
| implementation（分支1).language | `"ts"` | 必填 / 必有；源码语言，目前只支持 ts（TypeScript）。 |
| implementation（分支1).source | `string` | 必填 / 必有；动作的完整 TypeScript 源码；内置动作为空。 |
| implementation（分支2).kind | `"container"` | 必填 / 必有；固定为 container：以容器镜像实现（暂未开放）。 |
| implementation（分支2).image | `string` | 必填 / 必有；容器镜像引用。 |
| implementation（分支2).command | `string[]` | 必填 / 必有；在容器中执行的命令及参数列表。 |
| implementation（分支3).kind | `"shell"` | 必填 / 必有；固定为 shell：以 shell 脚本实现（暂未开放）。 |
| implementation（分支3).script | `string` | 必填 / 必有；要执行的 shell 脚本全文。 |
| host | `"builtin"` / `"isolate"` / `"sandbox"` | 必填 / 必有；动作运行位置，发布时计算。builtin 为平台内置动作；isolate 为在隔离的 Worker isolate 中运行用户代码；sandbox 为在沙箱中运行（container 与 shell 实现）。 |
| platform_apis | `string[]` | 必填 / 必有；从代码推导出的平台 API 集合，同时是该动作运行令牌的权限范围（最小权限）。 |
| created_by | `object` | 必填 / 必有；网关注入的主体 &#123;type, id&#125;，表示谁发起或操作；本服务不解析名字，名字由控制台批量解析。 不接受额外字段。 |
| created_by.type | `"user"` / `"api_key"` / `"agent"` / `"run"` / `"trigger"` | 必填 / 必有；主体类型。user 为登录用户；api_key 为平台 API Key；agent 为智能体；run 为由运行本身（例如父运行）执行的操作；trigger 为触发器。 |
| created_by.id | `string` | 必填 / 必有；主体标识，含义随 type 而定：用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID；按不透明字符串处理。 |
| message | `null` / `string` | 必填 / 必有；创建该修订时附带的说明；未提供为 null。 |
| created_at | `string` | 必填 / 必有；该修订的创建时间（RFC 3339 UTC）。 |

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

HTTP 200

```json
{
  "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
  "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ],
    "additionalProperties": false
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ],
    "additionalProperties": false
  },
  "errors": [],
  "annotations": {
    "read_only": false,
    "idempotent": false
  },
  "timeout_ms": 30000,
  "implementation": {
    "kind": "code",
    "language": "ts",
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  },
  "host": "isolate",
  "platform_apis": [],
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "message": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "current": false,
  "rollback": {
    "allowed": true,
    "issues": []
  }
}
```

## 错误码 [#错误码]

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

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