Worker Template¶
Endpoints
GET /worker_templates
GET /worker_templates/:id
POST /worker_templates
PUT /worker_templates/:id
DELETE /worker_templates/:id
DELETE /worker_templates
A worker template is a reusable definition of a digital worker, including its source code, form inputs, form outputs, and runtime configuration. Worker templates are used to instantiate workers within workflows.
The worker template object¶
What a worker template object looks like?
{
"id": "wrkt_usrLm5nOpQrSt6UvWx7YzAb8C",
"name": "My Worker Template",
"description": "This is my first worker template",
"category": "ANALYTICS",
"visible": true,
"type": "BASIC",
"script_runtime": "python",
"script_entry_point": "main",
"run_locally": false,
"container_status": "SUCCESS",
"tags": ["first", "worker", "20210622"],
"created": 1625598288,
"updated": 1625598288
}
| Property | Description |
|---|---|
id string |
Unique identifier (UID) for the worker template. |
created timestamp |
Time at which the object was created. Measured in seconds since the Unix epoch. |
updated timestamp |
Time at which the object was updated. Measured in seconds since the Unix epoch. |
name string |
The name of the worker template. |
description string |
An arbitrary string attached to the worker template. Default is "". |
tags array |
A list of strings. Up to 32 tags. Use them to find the worker template with a query. |
category string |
The category this worker template belongs to. |
version string |
Indicates the worker template's current version. |
visible boolean |
Whether the worker template is visible to users in the workflow editor. |
type string |
The worker type: BASIC, STARTER, ENDER, FORKER, BARRIER, CONDITIONAL, BRIDGE, TRY or CATCH. |
script_runtime string |
The runtime used to execute the worker's script: python or ecmascript5. |
script_entry_point string |
The entry point function called when the worker executes. |
run_locally boolean |
Whether the worker runs in the local environment rather than a container. |
container_status string |
The deployment status of the worker container. It is BUILDING while the platform builds the container, then SUCCESS or ERROR. |
Retrieve and list return the worker template in the format of a workflow worker, ready to copy into the workers of a workflow. In this format, ports is in gui.orchestrator.ports, form_outputs is script_outputs, default_output is output_key, and the response also has status, trigger_type, trigger_enabled and trigger_config.
List all worker templates¶
Returns a list of worker templates. The worker templates are returned in sorted order, with the most recent appearing first. Each item has the same fields as retrieve.
To list all worker templates, run the following:
The above call returns the following JSON object:
{
"worker_templates": [
{
"id": "wrkt_usrLm5nOpQrSt6UvWx7YzAb8C",
"name": "My Worker Template",
"description": "This is my first worker template",
"category": "ANALYTICS",
"visible": true,
"type": "BASIC",
"script_runtime": "python",
"script_entry_point": "main",
"run_locally": false,
"container_status": "SUCCESS",
"tags": ["first", "worker", "20210622"],
"created": 1625598288,
"updated": 1625598288
},
...
],
"next_page_token": null
}
HTTP Request
GET /worker_templates
HTTP Parameters
| Parameter | Description |
|---|---|
query string |
optional, default is null Request a list of worker templates filtering it by name or tag. When using a tag to perform a query, each term must include a hashtag prefix. (e.g: query="#april #sample") See Filter with query. |
page_size integer |
optional, default is 10 Set the number of objects that will be listed per page. |
page_token string |
optional, default is null The next_page_token from the previous response. See the pagination guide. |
Retrieve a worker template¶
Retrieves the details of an existing worker template by supplying its id.
To retrieve a worker template, run the following:
The above call returns the following JSON object:
{
"worker_template": {
"id": "wrkt_usrLm5nOpQrSt6UvWx7YzAb8C",
"name": "My Worker Template",
"description": "This is my first worker template",
"category": "ANALYTICS",
"visible": true,
"type": "BASIC",
"form_inputs": [],
"script_runtime": "python",
"script_entry_point": "main",
"container_status": "SUCCESS",
"tags": ["first", "worker", "20210622"],
"created": 1625598288,
"updated": 1625598288
}
}
HTTP Request
GET /worker_templates/:id
HTTP Parameters
| Parameter | Description |
|---|---|
id string |
REQUIRED A unique identifier (UID) for a worker template. A worker template's id will always look like this: wrkt_usrLm5nOpQrSt6UvWx7YzAb8C. |
Create a worker template¶
Creates a worker template and then returns it. Unless the template runs locally, the platform then builds a container for it: container_status is BUILDING until the build ends with SUCCESS or ERROR.
To create a worker template, run the following:
curl https://api.everysk.com/v2/worker_templates \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-d '{
"name": "My Worker Template",
"description": "This is my first worker template",
"tags": ["first", "worker"],
"category": "miscellaneous",
"icon": "developers",
"type": "BASIC",
"sort_index": 0,
"default_output": "output",
"script_runtime": "python",
"script_entry_point": "main",
"script_source": "def main(args):\n return args\n"
}' \
-X POST
The above call returns the following JSON object:
{
"worker_template": {
"id": "wrkt_usrLm5nOpQrSt6UvWx7YzAb8C",
"name": "My Worker Template",
"description": "This is my first worker template",
"tags": ["first", "worker"],
"category": "miscellaneous",
"visible": false,
"type": "BASIC",
"script_runtime": "python",
"script_entry_point": "main",
"run_locally": false,
"container_status": "BUILDING",
...
}
}
HTTP Request
POST /worker_templates
HTTP Parameters
| Parameter | Description |
|---|---|
name string |
REQUIRED The name of the worker template. |
category string |
REQUIRED The category this worker template belongs to. |
icon string |
REQUIRED The icon of the worker in the workflow editor. |
type string |
REQUIRED The worker type: BASIC, STARTER, ENDER, FORKER, BARRIER, CONDITIONAL, BRIDGE, TRY or CATCH. |
sort_index integer |
REQUIRED The position of the worker template in its category. |
default_output string |
REQUIRED The name of the default output of the worker. |
script_runtime string |
REQUIRED The runtime of the script: python or ecmascript5. |
script_entry_point string |
REQUIRED The function called when the worker executes. |
script_source string |
REQUIRED The source code of the worker. The API stores it as main.py in a zip file. |
description string |
optional, default is "" An arbitrary string attached to the worker template. |
tags array |
optional, default is [] A list of strings. Up to 32 tags. |
visible boolean |
optional, default is False Whether the worker template is visible to users in the workflow editor. |
ports array |
optional, default is [] The input and output ports of the worker. |
form_inputs array |
optional, default is [] The form fields of the worker. Up to 100 items. |
form_outputs object |
optional, default is {} The outputs of the worker. |
form_functions object |
optional, default is {} The functions that the form of the worker calls. |
run_locally boolean |
optional, default is False Only some accounts can set it. For other accounts, true returns 401. |
Update a worker template¶
Updates a worker template and then returns it. Only the fields that you send change, with one exception: send path_name as null and script_source in every update. If you leave out path_name or script_source, the API returns 500. Unless the template runs locally, the platform then builds the container again and container_status goes back to BUILDING.
To update a worker template, run the following:
The call returns the updated worker template, in the same format as create.
HTTP Request
PUT /worker_templates/:id
HTTP Parameters
| Parameter | Description |
|---|---|
id string |
REQUIRED The worker template's unique identifier. |
path_name string |
REQUIRED Send null. The API then stores script_source again. |
script_source string |
REQUIRED The source code of the worker. |
| Others | optional The other fields of create. A field that you leave out keeps its current value. |
Delete a worker template¶
Permanently deletes a worker template. It cannot be undone. Returns an object with the worker template's id, its name and an attribute specifying whether the worker template was successfully deleted or not.
To delete a worker template, run the following:
The above call returns the following JSON object:
{
"worker_template": {
"deleted": true,
"id": "wrkt_usrLm5nOpQrSt6UvWx7YzAb8C",
"name": "My Worker Template"
}
}
To delete several worker templates in one call, use DELETE /worker_templates?ids=<id>,<id>. The response has a worker_templates array with one {"id", "name", "deleted"} object per deleted id, where name is BATCH_DELETE. An id that the API does not delete gives null.
HTTP Request
DELETE /worker_templates/:id
DELETE /worker_templates
HTTP Parameters
| Parameter | Description |
|---|---|
id string |
REQUIRED for one worker template. The worker template's unique identifier. |
ids string |
REQUIRED for several worker templates. The ids, separated by commas. |