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 https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-task-templates
Before you call¶
Prepare your personal access token, workspace ID, and existing agent ID.
The example below uses:
$AI_STUDIO_API_KEY: Actual personal access token.$WORKSPACE_ID: Target workspace ID.$AGENT_ID: The agent ID to be called by the template.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-task-templates" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "'$AGENT_ID'",
"name": "摘要任务",
"message_template": {"template": "请总结输入内容"}
}'
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The target workspace ID. |
Request body¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Target agent ID. |
|
string |
Yes |
Template name. |
|
object |
Yes |
Task message template. |
|
string |
No |
Template description. |
|
object |
No |
Input structure definition. |
|
array |
No |
Default context reference. |
|
string |
No |
Run policy reference. |
|
object |
No |
Idempotent policy. |
|
object |
No |
Output contract. |
|
string |
No |
Template status. |
|
object |
No |
Tag key-value pair. |
|
object |
No |
Annotation key-value pair. |
Successful response¶
Returns 201 and a new template on success.
{"code": 0, "data": {"id": "template_01", "agent_id": "agent_01", "name": "摘要任务"}}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
New template ID. |
|
string |
Associated agent ID. |
|
string |
Template name. |
Error response¶
{"code": 2, "message": "invalid agent task template"}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body or template reference is invalid. |
Check agent ID and message template. |
|
|
The template ID or workflow node association already exists. |
Use a new identity instead or query an existing resource. |
Follow-up operations¶
Save data.id, and then Create agent workflow binding.