Create agent task template¶
Create an agent task template for the workflow node to call. If the creation is successful, only the template will be saved and the agent task will not be executed.
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/agent-task-templates
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare personal access token, workspace ID and existing agent ID.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/agent-task-templates" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "'$AGENT_ID'",
"name": "摘要任务",
"message_template": {
"template": "请总结输入内容"
}
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Target workspace ID. |
|
string |
Yes |
Target agent ID. |
|
string |
Yes |
Template name. |
|
object |
Yes |
Task message template. |
|
string |
No |
Template description. |
|
object |
No |
Enter the structure definition. |
|
array |
No |
Default context reference. |
|
string |
No |
Run policy reference. |
|
object |
No |
Idempotent strategy. |
|
object |
No |
Output format convention. |
|
string |
No |
Template status. |
|
object |
No |
Tag key-value pairs. |
|
object |
No |
Annotation key-value pairs. |
|
string |
No |
Message role, user is used when omitted. |
|
string |
Conditional |
Non-empty message template text. and non-empty parts provide at least one item. |
|
array of objects or null |
Conditional |
Message components. Each item can be an object or null. |
|
object or null |
No |
Template variables. |
|
string |
Required when there is a citation |
Context resource type. |
|
string |
Conditional |
Resource ID. Provide at least one item with uri. |
|
string |
Conditional |
Resource address. Provide at least one item with id. |
|
string |
No |
Resource version. |
|
object or null |
No |
Resource allocation. |
|
string |
No |
none, workflow_case or custom. |
|
string |
Required when custom |
Non-empty idempotent key template. |
|
integer |
No |
Idempotent window seconds. Negative values are handled as 0. |
|
string |
No |
Template ID. Generated when omitted or empty. |
The type, ID, address, and version of the context reference cannot have leading or trailing whitespace, and the ID cannot contain path separators. The service only verifies the reference format and does not check whether each resource exists. Use workflow_case when the idempotent strategy is omitted. custom mode must provide a non-empty idempotent key template.
Use draft when status is omitted. The associated agent and non-empty run policy reference must exist in the current workspace. Successful creation only saves the template and does not check all context references or start tasks.
Successful response¶
{
"code": 0,
"data": {
"id": "template_01",
"workspace_id": "workspace_example",
"agent_id": "agent_01",
"name": "摘要任务",
"message_template": {
"role": "user",
"template": "请总结输入内容"
},
"idempotency_policy": {
"mode": "workflow_case"
},
"status": "draft",
"version": 1,
"created_at": "2026-10-14T00:00:00Z",
"updated_at": "2026-10-14T00:00:00Z"
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
object |
response data. |
|
string |
Object ID. |
|
string |
The workspace ID to which it belongs. |
|
string |
The associated agent ID. |
|
string |
Name. |
|
string |
Description. Can be omitted if not set. |
|
object |
Message template. |
|
object |
JSON Schema of the input parameters. Can be omitted if not set. |
|
array of object |
Default context resource reference. Can be omitted if not set. |
|
string |
Object ID. |
|
string |
Run policy reference. Can be omitted if not set. |
|
object |
Idempotent strategy. |
|
string |
Strategy or scope pattern. Values: |
|
string |
Custom idempotent key template. Can be omitted if not set. |
|
integer |
Idempotent window, in seconds. Can be omitted if not set. |
|
object |
Output convention. Can be omitted if not set. |
|
string |
Current status. Values: |
|
integer |
Current version number. |
|
object |
Tag key-value pairs. Can be omitted if not set. |
|
object |
Extended annotations. Can be omitted if not set. |
|
string |
Creator ID. Can be omitted if not set. |
|
string |
Last updated by identifier. Can be omitted if not set. |
|
string |
Creation time, in RFC 3339 format. |
|
string |
Last updated in RFC 3339 format. |
|
string |
Message role. |
|
string |
Message template text. Can be omitted when using parts. |
|
array or null |
Structured messages are composed of items, and the content is retained by the template. |
|
object or null |
Template variables. |
|
string |
Context resource type. |
|
string |
Resource address. Can be omitted when using id. |
|
string |
Resource version. Omitted if not set. |
|
object or null |
Resource allocation. Omitted if not set. |
Error response¶
{
"code": 2,
"message": "invalid agent task template"
}
Common HTTP errors
HTTP status code |
error code |
Description |
|---|---|---|
|
|
Common reasons: The request body or template reference is invalid. Recommended Action: Check the agent ID and message template. |
|
|
Common reasons: The template ID or workflow node association already exists. Recommended Action: Use a new identifier instead or query an existing resource. |