A Multi-step API monitor is made up of steps. For each step, you can configure both the HTTP request and response components. This article provides you with an overview of how an API response works in a Multi-step API monitor. You will learn which HTTP response definitions are available and how to set them up.
Response
Within a step, you will see the Response tab. This is where you can set up checks and validations to verify the behavior of the API response.
Assertions
Assertions are the specific conditions that you can set to validate the API response. An assertion checks if the API returns the correct data, status codes, headers, response time, and others.
For each step, you can define a number of assertions depending on your monitoring requirements. Defining an assertion involves the following components:
To learn more, refer to Multi-step API Assertions.
Variables
When setting up multi-step API scenarios, you may need to capture specific data from previous steps and pass it on to the subsequent steps. For example, in step one, your API performs a GET
request to retrieve an ID
. In step two, you need to use that same ID
as a query parameter for the API call.
In such scenarios, variables allow you to extract values from HTTP responses and store them for reuse throughout the entire API scenario. By capturing that value, storing it temporarily and taking it across to the next steps, you’re creating a natural progression of connected steps, without the need to write any code.
For each step, you can create variables. These can be values retrieved from a JSON or XML data, response headers, or data from a
redirect, and more. Once defined, you can use it as part of your multi-step setup using the syntax {{my-variable}}
.
To know more information, refer to Multi-step API Variables.
Maximum number of attempts
There are cases when an API request may require additional time to complete its process before returning a successful response. Examples include: waiting for a file to upload, a payment transaction to succeed, or an email verification to arrive. There are also cases when an API request or an assertion may fail due to external issues like poor network connection or unexpected downtime. In these situations, you can enable the Maximum number of attempts to automatically retry executing the same step.
By repeatedly retrying the same step, this signals the monitor that the step is in a waiting state and must be checked again, not treated as an error. This also helps measure how long it took for the background process to run.
You can configure between 2 and 50 retry attempts and specify the delay between each attempt in milliseconds. For more information, refer to Maximum number of attempts.
Custom scripting
Both the request and response parts of a step can optionally be extended using Custom scripting in the Pre-Request and Post-Response tabs. This lets you execute scripts written in JavaScript language to perform custom logic and do in-depth functional tests. Aside from the full range of capabilities the standard JavaScript offers, you can also use Snippets, which are Uptrends pre-defined scripts to verify the correct functionality and behavior of your APIs.