docs/devguide/how-tos/Tasks/creating-tasks.md
A task definition specifies a task’s general implementation details:
This definition applies to all instances of the task across workflows.
You can create task definitions using the Conductor UI or APIs for the following scenarios:
SIMPLE) must be registered to the Conductor server as a task definition before it can execute in a workflow.With the UI, you can create or update task definitions visually.
To create a task definition:
To update a task definition:
You can create task definitions using the Conductor CLI. Save your task definitions to a JSON file and run:
conductor task create tasks.json
The file should contain an array of task definitions. Refer to Task Definitions for a reference guide on the full parameters.
Refer to Task Definitions for a reference guide on the full parameters.
You can also create task definitions using the Create Task Definition API (POST api/metadata/taskdefs). The API accepts an array of task definitions, allowing you to create them in bulk.
??? note "Example using cURL"
shell curl '{{ server_host }}/api/metadata/taskdefs' \ -H 'accept: */*' \ -H 'content-type: application/json' \ --data-raw '[{"createdBy":"user","name":"sample_task_name_1","description":"This is a sample task for demo","responseTimeoutSeconds":10,"timeoutSeconds":30,"inputKeys":[],"outputKeys":[],"timeoutPolicy":"TIME_OUT_WF","retryCount":3,"retryLogic":"FIXED","retryDelaySeconds":5,"inputTemplate":{},"rateLimitPerFrequency":0,"rateLimitFrequencyInSeconds":1}]'
You can update task definitions using the Update Task Definition API (PUT api/metadata/taskdefs). This API can only be used to update a single task definition at a time.
??? note "Example using cURL"
shell curl '{{ server_host }}/api/metadata/taskdefs' \ -X 'PUT' \ -H 'accept: */*' \ -H 'content-type: application/json' \ --data-raw '{"createdBy":"user","name":"sample_task_name_1","description":"This is a sample task for demo","responseTimeoutSeconds":10,"timeoutSeconds":30,"inputKeys":[],"outputKeys":[],"timeoutPolicy":"TIME_OUT_WF","retryCount":3,"retryLogic":"FIXED","retryDelaySeconds":5,"inputTemplate":{},"rateLimitPerFrequency":0,"rateLimitFrequencyInSeconds":1}'
Conductor offers client SDKs for popular languages which have library methods for making the API call. Refer to the SDK documentation to configure a client in your selected language to create or update task definitions.
Refer to Task Definitions for a reference guide on the full parameters.
In this example, the JavaScript Fetch API is used to create the task definition sample_task_name_1.
fetch("{{ server_host }}/api/metadata/taskdefs", {
"headers": {
"accept": "*/*",
"content-type": "application/json",
},
"body": "[{\"createdBy\":\"user\",\"name\":\"sample_task_name_1\",\"description\":\"This is a sample task for demo\",\"responseTimeoutSeconds\":10,\"timeoutSeconds\":30,\"inputKeys\":[],\"outputKeys\":[],\"timeoutPolicy\":\"TIME_OUT_WF\",\"retryCount\":3,\"retryLogic\":\"FIXED\",\"retryDelaySeconds\":5,\"inputTemplate\":{},\"rateLimitPerFrequency\":0,\"rateLimitFrequencyInSeconds\":1}]",
"method": "POST"
});
In this example, the JavaScript Fetch API is used to update the task definition sample_task_name_1.
fetch("{{ server_host }}/api/metadata/taskdefs", {
"headers": {
"accept": "*/*",
"content-type": "application/json",
},
"body": "{\"createdBy\":\"user\",\"name\":\"sample_task_name_1\",\"description\":\"This is a sample task for demo\",\"responseTimeoutSeconds\":10,\"timeoutSeconds\":30,\"inputKeys\":[],\"outputKeys\":[],\"timeoutPolicy\":\"TIME_OUT_WF\",\"retryCount\":3,\"retryLogic\":\"FIXED\",\"retryDelaySeconds\":5,\"inputTemplate\":{},\"rateLimitPerFrequency\":0,\"rateLimitFrequencyInSeconds\":1}",
"method": "PUT"
});
Once a task is defined in Conductor, it can be reused numerous times:
When reusing tasks in a multi-tenant system, all work assigned to a task goes into the same queue by default. If a noisy neighbor causes polling delays, you can scale up the number of workers or use task-to-domain to route task load into separate queues.