/

Add blocks to a workflow (API)

Add data and processing blocks to a workflow using the API.


Get data and processing blocks

In this guide, you will learn how to search for data and processing blocks. After selecting the blocks, you can add them one by one to the previously created workflow. Blocks are added as workflow tasks.

In this example, you will populate the empty workflow with blocks used to compute the Normalized Difference Vegetation Index from a Pléiades satellite image. The following data and processing blocks are used:

Do not confuse workflow tasks (also defined as blocks) with job tasks (also defined as job steps that generate individual outputs).

Get blocks IDs and block names

First, get the block names (both docker names and display names) together with their corresponding block ID (see examples in the tables below).

curl -s GET -H "Authorization: Bearer $PTOKEN" https://api.up42.com/blocks \
| jq -r '.data[] | .displayName + " : " + .id'
Display names (human-readable)Block IDs
SPOT 6/7 Display (Streaming)045019bb-06fc-4fa1-b703-318725b4d8af
Raster Tiling3e146dd6-2b67-4d6e-a422-bb3d973e32ff
SPOT 6/7 Reflectance (Download)63a69b97-1765-474e-b465-0b319b8d3b2d
Pléiades Display (Streaming)18d09f1a-3197-4c27-a15a-54d099c31435
Pléiades Reflectance (Download)defb134b-ca00-4e16-afa0-639c6dc0c5fe
NDVId0da4ac9-94c6-4905-80f5-c95e702ca878
Docker names (machine-readable)Block IDs
oneatlas-spot-aoiclipped045019bb-06fc-4fa1-b703-318725b4d8af
tiling3e146dd6-2b67-4d6e-a422-bb3d973e32ff
oneatlas-spot-fullscene63a69b97-1765-474e-b465-0b319b8d3b2d
oneatlas-pleiades-aoiclipped18d09f1a-3197-4c27-a15a-54d099c31435
oneatlas-pleiades-fullscenedefb134b-ca00-4e16-afa0-639c6dc0c5fe
ndvid0da4ac9-94c6-4905-80f5-c95e702ca878

Filter block IDs by name

Alternatively, get the block ID depending on the display name (change it according to your selected block):

curl -s GET -H "Authorization: Bearer $PTOKEN" https://api.up42.com/blocks \
| jq -r '.data[] | select(.displayName=="Pléiades Reflectance (Download)") | .id'

Add workflow tasks

Add first block

Create a file containing the request body with the first workflow task (task1_request.json). A task is associated with a block. The request body contains an array with one object that has the properties of the first block: the block name, the name of the parent block and the previously extracted block ID. By default, the first block has no parent. We strongly recommend using block names without spaces.

[{
 "name":"block1",
 "parentName":null,
 "blockId": "defb134b-ca00-4e16-afa0-639c6dc0c5fe"
 }]

Add the first task to the workflow by using the request body:

curl -s POST -H "Authorization: Bearer $PTOKEN" -H 'Content-Type: application/json' \
https://api.up42.com/projects/$PROJ/workflows/$NEW_WORKFLOW/tasks \
-d @task1_request.json | jq '.'

Get compatible blocks

Use the same request body to get the blocks compatible with the first block and extract their name and IDs. The block name has to be identical with the name specified as a query parameter (e.g. block1).

curl -s POST -H "Authorization: Bearer $PTOKEN" -H 'Content-Type: application/json' \
https://api.up42.com/projects/$PROJ/workflows/compatible-blocks?parentTaskName=block1 \
-d @task1_request.json | jq '.data.blocks[] | .name,.blockId'

Add second block

To add the second task to the workflow, you need to first create a file containing the request body that includes all the tasks you previously added, along with the task you want to add next (task2_request.json):

[{
 "name":"block1",
 "parentName":null,
 "blockId": "defb134b-ca00-4e16-afa0-639c6dc0c5fe"
 },
 {
 "name":"block2",
 "parentName":"block1",
 "blockId": "903f0435-d638-475e-bbe9-53b5664a22a8"
 }]

Add the second task to the workflow by using the request body:

curl -s POST -H "Authorization: Bearer $PTOKEN" -H 'Content-Type: application/json' \
https://api.up42.com/projects/$PROJ/workflows/$NEW_WORKFLOW/tasks \
-d @task2_request.json | jq '.'

Get compatible blocks

Use the same request body to get the blocks compatible with the second block. The block name has to be identical with the name specified as a query parameter (e.g. block2).

curl -s POST -H "Authorization: Bearer $PTOKEN" -H 'Content-Type: application/json' \
https://api.up42.com/projects/$PROJ/workflows/compatible-blocks?parentTaskName=block2 \
-d @task2_request.json | jq '.data.blocks[] | .name,.blockId'

Add third block

To add the third task to the workflow, you need to first create a file containing the request body that includes all the tasks you previously added, along with the task you want to add next (task3_request.json):

[{
 "name":"block1",
 "parentName":null,
 "blockId": "defb134b-ca00-4e16-afa0-639c6dc0c5fe"
 },
 {
 "name":"block2",
 "parentName":"block1",
 "blockId": "903f0435-d638-475e-bbe9-53b5664a22a8"
 },
 {
 "name":"block3",
 "parentName":"block2",
 "blockId": "d0da4ac9-94c6-4905-80f5-c95e702ca878"
 }]

Add the third task to the workflow by using the request body:

curl -s POST -H "Authorization: Bearer $PTOKEN" -H 'Content-Type: application/json' \
https://api.up42.com/projects/$PROJ/workflows/$NEW_WORKFLOW/tasks \
-d @task3_request.json | jq '.'

You can also get the blocks compatible with the third block and add another task to the workflow. In this guide, we will only add 3 tasks to the workflow and then continue with configuring the job of the newly-created workflow.

Learn more

For more CRUD workflow operations (e.g. update, delete or view workflow tasks), please refer to Workflow operations (API).

Next steps

To proceed, please go to Configure job (API).