嵌入会话 API

POST /v1/embed/sessions——在终端用户的子工作区中为其打开可嵌入的编辑器;撤销会话。仅限服务端调用。

仅限合作伙伴模式(指南)。请在你的服务器上用你的 API 密钥调用。

POST https://api.dcision.io/v1/embed/sessions
字段类型
workspacestring 或 objectext:<external_id> / 子工作区 id,或 { "external_id", "name", … } 以即时创建它(字段与 POST /v1/workspaces 相同)
userobject必填。{ "id", "name"?, "email"? }——你的终端用户
permissionsstring[]默认:全部。decisions:read、decisions:write、decisions:deploy、decisions:delete、executions:read、agent
start_pathstring/decisions(默认)、/decisions/new 或 /decisions/{id}[/editor|builder|playground|deploy|executions]
originsstring[]你允许的来源的子集(默认:全部)。测试密钥的会话还可以使用本地开发来源
localestringen、pt、es、ru 或 zh
themestringlight、dark 或 system
ttl_secondsinteger300–43 200(默认 3 600)
201 Created
{
  "id": "emb_7Hq2Lm9Xc4Rv1Tz8Wn3B",
  "url": "https://app.dcision.io/embed/launch?ticket=emt_…",
  "launch_expires_at": "2026-10-09T12:01:00.000Z",
  "expires_at": "2026-10-09T13:00:00.000Z",
  "permissions": ["decisions:read", "decisions:write", "decisions:deploy", "decisions:delete", "executions:read", "agent"],
  "origins": ["https://app.example.com"],
  "workspace": { "id": "…", "external_id": "acme", "name": "Acme Inc", "created": false, "…": "…" }
}

请在 60 秒内将 url 加载到 iframe 中(它只能使用一次)——@dcision/embed 会替你完成。

错误:400 INVALID_REQUEST(来源不在你的允许列表中、start_path 或权限无效)、403 FORBIDDEN(partner_disabled、key_without_author)、404 WORKSPACE_NOT_FOUND。

撤销

请求
DELETE /v1/embed/sessions/{id}204:关闭一个会话
POST /v1/embed/sessions/revoke{ "workspace"?, "user_id"? } → { "revoked": 3 }:关闭某个子工作区和/或你的某个用户的有效会话

已关闭或已过期的会话会在 iframe 中显示“请从你的应用重新打开”;@dcision/embed 会通过你的后端打开一个新会话。

本页内容