Workflows - Multi-step API calls
A workflow is a series of back-to-back API call that execute one after another. You can extract variables from the output of earlier calls and use them as part of the input to later ones. This helps you monitor real world business processes that involve multiple linked API calls.
Key Concepts
A workflow is a sequence of API calls that execute one after another. The calls can be completely independent or use variables extracted from an earlier call and passed to a later one in the sequence. Just like a plain API call, workflows are deployed to be run periodically from agents in the same way as individual API calls.
Example Workflow
- Make an API call to create a user in a particular system
- Extract the user ID from the returned payload
- Make an API call to create a record associated with the user account for the user ID
- Extract the record ID from the returned payload
- Make an API call to obtain the record associated with the user account for the user ID and the record ID
- Validate the returned payload using API Conditions to demonstrate that the record was created successfully
- Make an API call to delete the record associated with the user account for the user ID and the record ID
- Make an API call to obtain the record associated with the user account for the user ID and the record ID
- Validate the returned payload using API Conditions to demonstrate that the record was deleted successfully (trying to obtain a deleted record should lead to the returned payload containing an error message)
- Make an API call to delete the user account associated with the user ID
Variables in workflows
A variable used in a workflow only persists for use in that workflow. We provide pre-set variables for services like DATE and TIME, and global variables that can be used to handle externally generated tokens and IDs.
Creating a Workflow
Clicking on the Workflows item on the left-hand menu invokes the Workflow page.
If you already have created some workflows, they will be listed on the page.
Clicking on the +Create New Workflow button invokes the Edit Workflow dialog.
You can enter a more memorable name for the workflow. You can choose an API call from the dropdown or click +New API Call to create the API call from scratch in the usual way.
Variables and Conditions
Variables can then be added to calls and conditions added to allow you to stop workflows in the event of a failure.
See the section on assertions and conditions for more details on how to handle these situations.
Using a Variable
Once you have set your variable - in this case, ID - you can use that variable in later calls in the workflow either as part of the URI or as a parameter using the following notations:
%%ID%%
__ID__
For instance, if a URI or parameter contained a hardwired ID such as 113231459, this could be substituted for the variable extracted from an earlier call in the workflow by replacing 113231459 by %%ID%% or ID (two underscores before and after the name as escape characters). Similarly, if you had extracted a token with the name TOKEN from a call in the workflow, this would be substituted into the URI as %%TOKEN%% or TOKEN.
Scheduling Workflows
A workflow can be scheduled in exactly the same way as an individual API call.
Workflow Results
You can examine a list of workflow results.
Clicking on View brings up a summary of the results for each of the components for that particular invocation of the workflow. You can drill down further by clicking on View Results or View API Call to see details of the API call and the result of the call in that workflow invocation.
Updated 3 months ago