CreateJobTemplate
Creates a task template.
Try it now
Test
RAM authorization
Request syntax
POST /api/v1/jobtemplates HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body |
object |
No |
The request body parameters. |
|
| TemplateName |
string |
Yes |
The name of the task template. |
job-template-example-1778047**** |
| Description |
string |
No |
The description of the task template. |
Template description |
| WorkspaceId |
string |
Yes |
The ID of the workspace to which the template belongs. |
15****05 |
| Metadata |
object |
No |
The custom key-value pair metadata. |
{} |
| Content |
string |
Yes |
The configuration content of the task template, including job configuration parameters, passed as a JSON string. |
{\"WorkspaceId\":\"15****05\",\"JobType\":\"PyTorchJob\",\"UserCommand\":\"echo hello\",\"JobSpecs\":[{\"Type\":\"Worker\",\"PodCount\":1,\"Image\":\"dsw-registry-vpc.cn-hangzhou.cr.aliyuncs.com/pai/pytorch:2.8.0-gpu-py313-cu129-ubuntu22.04-3995b779-1764361782\",\"EcsSpec\":\"ecs.gn7i-c8g1.2xlarge\"}],\"ResourceType\":\"ECS\",\"_ResourcePaymentType\":\"PostPaid\",\"CredentialConfig\":{\"EnableCredentialInject\":false},\"Accessibility\":\"PRIVATE\",\"Settings\":{\"JobReservedMinutes\":0,\"Tags\":{}}} |
| Constraints |
object |
No |
The field constraint rules. The key is a JSONPath expression, and the value is the constraint type: locked (locked and cannot be overridden), overridable (can be overridden), or required (required). |
{"JobSpecs[0].Image":"locked","UserCommand":"locked","JobType":"locked"} |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| TemplateId |
string |
The unique identifier of the task template. |
tplmceolmf2**** |
| TemplateName |
string |
The name of the task template. |
job-template-example-1778047**** |
| Description |
string |
The description of the task template. |
Template description |
| Metadata |
object |
The user-defined key-value pair metadata. |
{} |
| WorkspaceId |
string |
The ID of the workspace to which the template belongs. |
15****05 |
| UserId |
string |
The ID of the user who created the template. |
20**************02 |
| TenantId |
string |
The ID of the tenant to which the template belongs. |
10**************14 |
| DefaultVersion |
integer |
The default version number currently in use. |
1 |
| Version |
integer |
The version number returned in the current response. |
1 |
| GmtCreateTime |
string |
The time when the template was created. |
2025-12-31T02:18:09Z |
| GmtModifyTime |
string |
The time when the template was last modified. |
2026-01-12T14:36:00Z |
| LastUsedTime |
string |
The time when the template was last used. |
2026-09-03T11:30:00Z |
| RequestId |
string |
The ID of the request, which is used for diagnostics and troubleshooting. |
8762921A-911C-515F-A3A4-********* |
Examples
Success response
JSON format
{
"TemplateId": "tplmceolmf2****",
"TemplateName": "job-template-example-1778047****\t",
"Description": "Template description\n",
"Metadata": {},
"WorkspaceId": "15****05",
"UserId": "20**************02",
"TenantId": "10**************14",
"DefaultVersion": 1,
"Version": 1,
"GmtCreateTime": "2025-12-31T02:18:09Z",
"GmtModifyTime": "2026-01-12T14:36:00Z",
"LastUsedTime": "2026-09-03T11:30:00Z",
"RequestId": "8762921A-911C-515F-A3A4-*********"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.