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.

HTTP
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

Shell
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

workspace_id

string

Yes

Target workspace ID.

agent_id

string

Yes

Target agent ID.

name

string

Yes

Template name.

message_template

object

Yes

Task message template.

description

string

No

Template description.

input_schema

object

No

Enter the structure definition.

default_context_refs

array

No

Default context reference.

runtime_policy_ref

string

No

Run policy reference.

idempotency_policy

object

No

Idempotent strategy.

output_contract

object

No

Output format convention.

status

string

No

Template status.

labels

object

No

Tag key-value pairs.

annotations

object

No

Annotation key-value pairs.

message_template.role

string

No

Message role, user is used when omitted.

message_template.template

string

Conditional

Non-empty message template text. and non-empty parts provide at least one item.

message_template.parts

array of objects or null

Conditional

Message components. Each item can be an object or null.

message_template.variables

object or null

No

Template variables.

default_context_refs[].type

string

Required when there is a citation

Context resource type.

default_context_refs[].id

string

Conditional

Resource ID. Provide at least one item with uri.

default_context_refs[].uri

string

Conditional

Resource address. Provide at least one item with id.

default_context_refs[].version

string

No

Resource version.

default_context_refs[].config

object or null

No

Resource allocation.

idempotency_policy.mode

string

No

none, workflow_case or custom.

idempotency_policy.key_template

string

Required when custom

Non-empty idempotent key template.

idempotency_policy.window_seconds

integer

No

Idempotent window seconds. Negative values ​​are handled as 0.

id

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

JSON
{
  "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

code

integer

0 when the request is processed successfully.

data

object

response data.

data.id

string

Object ID.

data.workspace_id

string

The workspace ID to which it belongs.

data.agent_id

string

The associated agent ID.

data.name

string

Name.

data.description

string

Description. Can be omitted if not set.

data.message_template

object

Message template.

data.input_schema

object

JSON Schema of the input parameters. Can be omitted if not set.

data.default_context_refs

array of object

Default context resource reference. Can be omitted if not set.

data.default_context_refs[].id

string

Object ID.

data.runtime_policy_ref

string

Run policy reference. Can be omitted if not set.

data.idempotency_policy

object

Idempotent strategy.

data.idempotency_policy.mode

string

Strategy or scope pattern. Values: none, workflow_case, custom.

data.idempotency_policy.key_template

string

Custom idempotent key template. Can be omitted if not set.

data.idempotency_policy.window_seconds

integer

Idempotent window, in seconds. Can be omitted if not set.

data.output_contract

object

Output convention. Can be omitted if not set.

data.status

string

Current status. Values: draft, active, disabled, archived.

data.version

integer

Current version number.

data.labels

object

Tag key-value pairs. Can be omitted if not set.

data.annotations

object

Extended annotations. Can be omitted if not set.

data.created_by

string

Creator ID. Can be omitted if not set.

data.updated_by

string

Last updated by identifier. Can be omitted if not set.

data.created_at

string

Creation time, in RFC 3339 format.

data.updated_at

string

Last updated in RFC 3339 format.

data.message_template.role

string

Message role.

data.message_template.template

string

Message template text. Can be omitted when using parts.

data.message_template.parts

array or null

Structured messages are composed of items, and the content is retained by the template.

data.message_template.variables

object or null

Template variables.

data.default_context_refs[].type

string

Context resource type.

data.default_context_refs[].uri

string

Resource address. Can be omitted when using id.

data.default_context_refs[].version

string

Resource version. Omitted if not set.

data.default_context_refs[].config

object or null

Resource allocation. Omitted if not set.

Error response

JSON
{
  "code": 2,
  "message": "invalid agent task template"
}

Common HTTP errors

HTTP status code

error code

Description

400

2

Common reasons: The request body or template reference is invalid. Recommended Action: Check the agent ID and message template.

409

4

Common reasons: The template ID or workflow node association already exists. Recommended Action: Use a new identifier instead or query an existing resource.

Last updated on