Build a Workflow
Create a workflow, add a trigger and steps, set them up, test, publish and run it, all through the API.
Every endpoint below links to its reference page, which lists each field it takes and answers. The values a step reads from earlier in the run are on Workflow References.
How changes are saved
A workflow has a draft, which you change, and published versions, which run. Every change below goes to the draft, so nothing runs until you publish.
Each change to the draft takes the draft's revision in the If-Match header and answers the new one in meta.revision. Send the revision you read last. When someone else changed the draft first, the change is refused with 412 and error.details.revision holds the current revision: read the draft again, then retry. Read the first revision from Get Workflow Definition.
Build it in one call
After creating the workflow, the fastest way to build it, and the one to use from an agent, is Set Workflow Definition: send every trigger and step at once, nested as they run, each with its configuration. Give each new step a ref of your own and reference it by that ref anywhere in the same body, such as {{ steps.users.output[0].id }}; the answer maps each ref to the id it got. Everything is applied in one change, all or nothing, and every problem comes back at once with its JSON Pointer into your body. To change the workflow later, read it with Get Workflow Definition, edit what you read and send it back: a step you leave out is removed. Check a body first, without saving it, with Validate Workflow Definition.
One thing takes a second call: a Map step's code reads each input by a key that ends in the last four characters of that step's id, in capitals, such as input['slackListUsers7K2Q'], and a step created in the same call has no id until the call answers. Add the Map step with its inputs and no code in the definition (it is saved, and shows as not set up yet), then set code that reads a new step with Update Workflow Step Configuration, using the key the answer gives in inputKeys.
The sections below build the same workflow one call at a time, which suits small edits and shows what each part takes.
1. Create the workflow
Create Workflow makes an empty, disabled workflow. Send "type": "function" for one other workflows call.
2. Add a trigger
Add Workflow Trigger takes schedule, webhook, runWorkflow or an app slug. A webhook trigger's address is in its configuration: read it with Get Workflow Trigger Configuration. Set a schedule or an app event with Update Workflow Trigger Configuration. To capture a sample call to a webhook, use Listen Workflow Trigger.
3. Add steps
Find the app and action with List Universal Apps (includeBuiltins=true adds If/Else, Loop, Map and the other built-in steps, which Built-in Steps describes) and List Universal Actions. Then add the step with Add Workflow Step. Its position puts it inside a loop or an If/Else lane; the slots are on Workflow References. Move steps later with Set Workflow Step Order.
4. Set each step up
Get Workflow Step Schema lists what a step takes: its arguments, options, the connection it needs and the output fields later steps can read. Set them with Update Workflow Step Configuration; its reference page shows the connection object. To check values first without saving them, send the same body to Validate Workflow Step Configuration. Choose from an app's own lists with Run Workflow Step Lookup. An app step that lists records reads only its first page, at the action's default page size (Get Workflow Step Schema's size.default), unless you set its pagination option: "mode": "all" reads every page, except on an action that pages by size only, which takes "mode": "single" with a larger size (Get Workflow Step Schema lists the modes an action takes). Paging, building a list argument from earlier records, and condition rules are on Workflow References.
5. Test
Test Workflow Step runs one step for real, with its saved connection: a step that creates a record creates it. Its output becomes the sample later steps read. To save a sample without running the step, use Update Workflow Step Output. A Loop is not tested on its own and takes no sample of its own: give the step it loops over a sample, and the Loop's sample is that sample's first record. A sample keeps at most a fixed number of records; truncated says when the rest were left out.
6. Publish and turn it on
Validate Workflow lists what would block publishing. Publish Workflow makes the draft the version that runs. Then turn the workflow on with "isActive": true in Update Workflow.
7. Run it
Call the trigger, or start a run with Run Workflow and follow it with Get Run. List Run Steps and Get a Run Step show what each step received and returned.