模板
模板 Console API 参考。
如果你还不了解项目模板,可以先 了解项目模板。
列出模板
列出当前 API key 用户所在当前工作区里已保存的项目模板。通过返回的 template id 和 node id 可以继续调用通过模板创建项目接口。
GET /api/console/v1/templates?index=0&pageSize=50Authorization: Bearer <api_key>返回
{ "templates": [ { "id": "<template_id>", "workspaceId": "<workspace_id>", "createdByUserId": "<user_id>", "name": "Launch checklist", "graph": { "version": "1.0.0", "name": "Launch checklist", "description": "A reusable launch checklist workflow.", "icon": "planning", "background": "#EFF1F5", "nodes": [ { "id": "<node_id>", "position": { "x": 0, "y": 0 }, "data": { "type": "task", "icon": "planning", "background": "#EFF1F5", "title": "Plan", "instructions": "Draft the launch checklist." } } ], "edges": [] }, "createdAt": "2026-05-17T00:00:00.000Z", "updatedAt": "2026-05-17T00:00:00.000Z" } ]}示例
TypeScript
const BASE_URL = "https://api.syncless.ai"const API_KEY = "<api_key>"const response = await fetch(BASE_URL + "/api/console/v1/templates?index=0&pageSize=50", { headers: { "Authorization": "Bearer " + API_KEY, },})if (!response.ok) { throw new Error(await response.text())}console.log(await response.json())Python
import requestsBASE_URL = "https://api.syncless.ai"API_KEY = "<api_key>"response = requests.get( BASE_URL + "/api/console/v1/templates?index=0&pageSize=50", headers={ "Authorization": "Bearer " + API_KEY, },)response.raise_for_status()print(response.json())cURL
curl "https://api.syncless.ai/api/console/v1/templates?index=0&pageSize=50" \ -H "Authorization: Bearer <api_key>"通过模板创建项目
通过模板创建一个项目。每个模板节点都必须用用户 ID 指定负责人。
POST /api/console/v1/templates/<template_id>/projectsAuthorization: Bearer <api_key>Content-Type: application/json请求体
| 字段 | 类型 | 必填 |
|---|---|---|
| name | string | yes |
| nodes | object | yes |
{ "name": "Launch checklist", "nodes": { "<node_id>": "<owner_id>" }}返回
{ "ok": true, "project_id": "<project_id>", "status": "setting_up", "nodes": [ { "node_id": "<node_id>", "task_id": "<task_id>", "title": "Plan", "owner_id": "<owner_id>" } ]}示例
TypeScript
const BASE_URL = "https://api.syncless.ai"const API_KEY = "<api_key>"const TEMPLATE_ID = "<template_id>"const response = await fetch(BASE_URL + "/api/console/v1/templates/" + TEMPLATE_ID + "/projects", { method: "POST", headers: { "Authorization": "Bearer " + API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ name: "Launch checklist", nodes: { "<node_id>": "<owner_id>", }, }),})if (!response.ok) { throw new Error(await response.text())}const created = await response.json()console.log(created)let status = created.statuswhile (status !== "ready" && status !== "failed") { const check = await fetch(BASE_URL + "/api/console/v1/projects/" + created.project_id + "/template-status?wait_seconds=5", { headers: { "Authorization": "Bearer " + API_KEY, }, }) if (!check.ok) { throw new Error(await check.text()) } status = (await check.json()).status}Python
import jsonimport requestsBASE_URL = "https://api.syncless.ai"API_KEY = "<api_key>"TEMPLATE_ID = "<template_id>"body = json.dumps({ "name": "Launch checklist", "nodes": { "<node_id>": "<owner_id>", },}).encode("utf-8")response = requests.post( BASE_URL + "/api/console/v1/templates/" + TEMPLATE_ID + "/projects", data=body, headers={ "Authorization": "Bearer " + API_KEY, "Content-Type": "application/json", },)response.raise_for_status()created = response.json()print(created)status = created["status"]while status not in ("ready", "failed"): check = requests.get( BASE_URL + "/api/console/v1/projects/" + created["project_id"] + "/template-status?wait_seconds=5", headers={ "Authorization": "Bearer " + API_KEY, }, ) check.raise_for_status() status = check.json()["status"]cURL
curl -X POST "https://api.syncless.ai/api/console/v1/templates/<template_id>/projects" \ -H "Authorization: Bearer <api_key>" \ -H "Content-Type: application/json" \ -d '{ "name": "Launch checklist", "nodes": { "<node_id>": "<owner_id>" } }'curl "https://api.syncless.ai/api/console/v1/projects/<project_id>/template-status?wait_seconds=5" \ -H "Authorization: Bearer <api_key>"