§ API REFERENCE

创建执行

POST/executionsscope: executions:write

为某外部用户在某能力上创建一次执行(去 PII 解析主体 + 幂等 + 额度冻结)。

鉴权:Authorization: Bearer <access_token>。
§ 1

请求信息

POST https://api.lingxiguangnian.com/api/open/v1/executions

请求头

参数类型必填说明
AuthorizationstringBearer <access_token>。由 POST /token 换取,有效期 2 小时;api_secret 不得直连业务端点(→ 401)。
Idempotency-Keystring幂等键(16-256 字符)。同键返回同一 execution_id,不重复冻结。

请求体参数

参数类型必填说明
external_user_idstring调用方自有用户标识(业务键,非 PII)。
resource_typeenum来自 capabilities.resource_type。
resource_iduuid来自 capabilities.resource_id。
kindstring兼容字段;建议不传,由服务端按资源真源推导。
session_typeenum计费会话类型 assessment / game / consultation / none(默认 none)。
metadata_safeobject非 PII 辅助上下文(服务端二次校验)。
§ 2

调用示例

curl -X POST "https://api.lingxiguangnian.com/api/open/v1/executions" \
  -H "Authorization: Bearer oat_xxxxxxxxxxxxxxxx" \
  -H "Idempotency-Key: order-2026-0001" \
  -H "Content-Type: application/json" \
  -d '{ "external_user_id": "ext-u-912", "resource_type": "CAPABILITY_UNIT", "resource_id": "22222222-2222-4222-8222-222222222222" }'
§ 3

返回结果

返回字段

参数类型必填说明
execution_iduuid执行 ID。
replayedbooleantrue=幂等命中(200);false=新建(201)。
{ "success": true, "data": { "execution_id": "9b8e0c2a-3d4f-4a5b-8c6d-7e8f9a0b1c2d", "replayed": false } }
§ 4

端点错误码

通用鉴权、scope 与限流错误见「使用概述」;下表为本端点专属错误。

HTTPerror_code触发条件
422open_api.validation_error请求体字段缺失 / 类型错。
422open_api.pii_in_metadatametadata_safe 含明文个人信息。
400open_api.idempotency_key_required缺 Idempotency-Key 头。
410open_api.standalone_assessment_deprecated尝试创建独立认知评估执行。
402open_api.credit_freeze_failed额度不足 / 冻结失败。
使用说明
  • 创建成功后执行进入 RUNNING;冻结金额取目录当前有效价格。同一 Idempotency-Key 重放不重复冻结。

契约真源:apps/m-master/src/app/api/open/v1/executions/route.ts