执行 Beta
运行工作流、通过 SSE 跟踪进度,并查询实例、运行结果与节点执行记录。
执行完整工作流
POST /workflow-orchestration/data-plane/execution-engine/execution/workflow
从草稿 FlowDefinition 或已发布的 FlowVersion 解析流程图,创建 FlowInstance,将执行委托给编排器,并持久化各步骤结果。测试草稿时提供 flow_definition_id,生产环境提供 flow_version_id。
认证: Bearer 令牌
请求体
-
organization_idstring 必填 -
flow_definition_idstring -
草稿流程定义 ID(用于测试)。
-
flow_version_idstring -
已发布的流程版本 ID(用于生产)。
-
inputobject -
工作流的输入数据。
响应
-
200工作流执行结果
curl -X POST https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/execution/workflow \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "<organization_id>"
}'const response = await fetch('https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/execution/workflow', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"organization_id": "<organization_id>"
}),
});
const { success, message, result } = await response.json();import os
import requests
response = requests.post(
"https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/execution/workflow",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
json={
"organization_id": "<organization_id>"
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "<organization_id>"
}
}按查询选择器获取流程实例结果。
GET /workflow-orchestration/data-plane/execution-engine/flow-instance-result/{queryselector}
返回与路由中指定的查询选择器和搜索条件匹配的流程实例结果信息。
认证: Bearer 令牌
参数
-
queryselectorenum 路径 必填 -
此查询可用的筛选条件
idorganization-idall -
searchstring 查询 -
用于搜索实体的关键字。
-
include_statusstring 查询 -
可选的状态参数,用于包含指定状态的流程实例结果。
-
exclude_statusstring 查询 -
可选的状态参数,用于排除指定状态的流程实例结果。
-
pageinteger 查询 -
页码,从 1 开始(默认 1)。
-
pageSizeinteger 查询 -
每页记录数(默认 25)。
-
hydrateboolean 查询 -
为“true”时,返回文档中的每个 `$payloadRef` 描述符都会在服务端解析,并替换为原先外置的内容,使调用方获得与 claim-check 优化之前相同的内联载荷。适用于需要在一次响应中获取完整内容的程序化调用方(Command Center 上下文、集成)。UI 读取时请保持关闭——Run Detail 界面会按 chip 懒加载外置内容。临时的 `_truncated` 标记无法还原(其内容从未被存储)。
响应
-
200成功。 -
500执行此操作时出错。
curl -X GET https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/flow-instance-result/id \
-H "Authorization: Bearer $SOMMATIC_TOKEN"const response = await fetch('https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/flow-instance-result/id', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/flow-instance-result/id",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "org_blackwood_stone_2319",
"flow_instance_id": "inst_91827",
"flow_version_id": "flow-def-email-routing:v1.3.0",
"flow_slug": "flow.email_classify_and_route",
"status": {
"id": 5,
"name": "completed",
"title": "Completed",
"color": null
},
"started_at": 1735692000000,
"completed_at": 1735692002450,
"duration_ms": 2450,
"correlation_id": "corr_f0c9e3b1",
"trigger_id": "trig_email_ingress",
"outcome_label": "success_billing_ticket_created",
"outcome_category": "success",
"final_output_envelope": {
"payload": {
"ticket_id": "TCK-392818",
"category": "billing",
"customer_id": "customer-123",
"status": "created"
}
},
"error_summary": null,
"metrics": {
"node_count_total": 4,
"node_count_succeeded": 4,
"node_count_failed": 0,
"node_count_retried": 1,
"retry_count_total": 1,
"max_concurrent_nodes": 2
}
}
}{
"status": 500,
"success": false,
"message": "Something was wrong while you make this action",
"result": null
}按查询选择器获取节点执行记录。
GET /workflow-orchestration/data-plane/execution-engine/node-execution/{queryselector}
返回与路由中指定的查询选择器和搜索条件匹配的节点执行信息。
认证: Bearer 令牌
参数
-
queryselectorenum 路径 必填 -
此查询可用的筛选条件
idorganization-idall -
searchstring 查询 -
用于搜索实体的关键字。
-
include_statusstring 查询 -
可选的状态参数,用于包含指定状态的节点执行记录。
-
exclude_statusstring 查询 -
可选的状态参数,用于排除指定状态的节点执行记录。
-
pageinteger 查询 -
页码,从 1 开始(默认 1)。
-
pageSizeinteger 查询 -
每页记录数(默认 25)。
响应
-
200成功。 -
500执行此操作时出错。
curl -X GET https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/node-execution/id \
-H "Authorization: Bearer $SOMMATIC_TOKEN"const response = await fetch('https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/node-execution/id', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/node-execution/id",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "org_1234",
"flow_instance_id": "inst_91827",
"node_id": "classify_email",
"attempt_number": 2,
"status": "success",
"started_at": 1735692000000,
"ended_at": 1735692001423,
"input_envelope": {
"node_id": "trigger_email",
"payload": {
"subject": "Invoice overdue",
"body": "I have not received payment confirmation..."
}
},
"output_envelope": {
"node_id": "classify_email",
"payload": {
"category": "billing",
"confidence": 0.87
}
},
"selected_port": "out",
"execution_result": {
"ai_decision": {
"label": "billing",
"confidence": 0.87
}
},
"error_details": null,
"metrics": {
"latency_ms": 423,
"token_usage": {
"prompt_tokens": 1123,
"completion_tokens": 64
}
},
"worker_id": "worker-west-02"
}
}{
"status": 500,
"success": false,
"message": "Something was wrong while you make this action",
"result": null
}按查询选择器获取流程实例。
GET /workflow-orchestration/data-plane/instance-runtime/flow-instance/{queryselector}
返回与路由中指定的查询选择器和搜索条件匹配的流程实例信息。
认证: Bearer 令牌
参数
-
queryselectorenum 路径 必填 -
此查询可用的筛选条件
idorganization-idall -
searchstring 查询 -
用于搜索实体的关键字。
-
include_statusstring 查询 -
可选的状态参数,用于包含指定状态的流程实例。
-
exclude_statusstring 查询 -
可选的状态参数,用于排除指定状态的流程实例。
-
pageinteger 查询 -
页码,从 1 开始(默认 1)。
-
pageSizeinteger 查询 -
每页记录数(默认 25)。
响应
-
200成功。 -
500执行此操作时出错。
curl -X GET https://api.sommatic.ai/workflow-orchestration/data-plane/instance-runtime/flow-instance/id \
-H "Authorization: Bearer $SOMMATIC_TOKEN"const response = await fetch('https://api.sommatic.ai/workflow-orchestration/data-plane/instance-runtime/flow-instance/id', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/workflow-orchestration/data-plane/instance-runtime/flow-instance/id",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "org_blackwood",
"flow_version_id": "flow-def-email-routing:v1.3.0",
"flow_slug": "flow.email_classify_and_route",
"status": "running",
"started_at": 1735689000000,
"completed_at": null,
"active_node_id": "classify_email",
"queued_node_ids": [
"create_ticket"
],
"variables": {
"email_subject": "Payment not received",
"email_body": "Hello, I have not received my invoice for December...",
"classification": {
"category": "billing",
"confidence": 0.92
}
},
"last_envelope": {
"node_id": "classify_email",
"payload": {
"category": "billing",
"confidence": 0.92
}
},
"pending_async_operations": [
{
"operation_key": "tool.openai_async_chat",
"status": "waiting-callback"
}
],
"linked_timer_ids": [
"timer_8ab233"
],
"execution_history_ids": [
"exec_123",
"exec_124"
],
"resume_strategy": "continue-node"
}
}{
"status": 500,
"success": false,
"message": "Something was wrong while you make this action",
"result": null
}工作流执行事件的实时 SSE 流
GET /workflow-orchestration/execution/stream
建立 Server-Sent Events 连接,实时接收指定工作流和用户的执行进度。
认证: Bearer 令牌
参数
-
flow_definition_idstring 查询 必填 -
要监听执行事件的工作流 ID。
-
user_identitystring 查询 必填 -
监听事件的用户身份。
响应
-
200SSE 流已成功建立。
curl -X GET https://api.sommatic.ai/workflow-orchestration/execution/stream?flow_definition_id=<flow_definition_id>&user_identity=<user_identity> \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-Nconst response = await fetch('https://api.sommatic.ai/workflow-orchestration/execution/stream?flow_definition_id=<flow_definition_id>&user_identity=<user_identity>', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/workflow-orchestration/execution/stream?flow_definition_id=<flow_definition_id>&user_identity=<user_identity>",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json()