New: Terraform Provider & Linux Private Checkpoints. See more.

  1. Support
  2. Knowledge base
  3. Synthetic Monitoring
  4. API Monitoring
  5. Multi-step monitoring
  6. Multi-step API predefined variables

Multi-step API predefined variables

If you’re new to the concept of variables, we recommend that you read the Variables article to have an overview of how it works. This article provides an overview of predefined variables and how you can use and set them up in a Multi-step API monitor.

Predefined variables

Predefined variables allow you to either capture and store values from HTTP responses or specify your own values at the start of an API scenario. Below the step editor, you’ll find an additional section where you can specify these variables.

Predefined variables

As shown in the image, the {{BaseUrl}} variable holds the value https://galacticresorts.com. Instead of repeatedly defining URLs for each step, you can easily use the variable to target different endpoints for each step, such as {{BaseUrl}}/Products and {{BaseUrl}}/Status. You can also switch from one environment to another by just updating the value of the variable to https://test-galacticresorts.com.

Using BaseUrl as a predefined variable

Another common use case for predefined variables is storing your API key for authentication. By defining your credentials as a variable, you can securely manage sensitive information and update the value in a single place whenever needed. You can also retrieve and Use vault credentials as predefined variables.

Set up predefined variables

To add a predefined variable, do the following:

  1. Below the Visual step editor, go to Predefined variables.
  2. Click Add variable.
  3. Specify the variable name in the Name field. For example, BaseUrl.
  4. Click and select a value. This can be a plain text or a vault credential.
  5. Specify the value of the variable. For example https://test.yourapi.com.

Once created, you can now use the variable to your API steps using the syntax: {{VariableName}}. If you want to reference it as the base URL for each API step, you can use: {{BaseURL}}/UserService/GetUserInfo or {{BaseURL}}/UserService/GetProductInfo. In this way, you can easily update the value of the variable to point to a different environment like staging and production environment, without needing to edit each step.

Use vault credentials as predefined variables

Predefined variables can also store sensitive information and use it anywhere in the API scenario. If your API requires authentication, such as logging in or retrieving an access token, you can use a variable to store your credentials and use it in your requests.

Uptrends features the Vault, where you can safely store any sensitive data within your Uptrends account.

To use vault credentials as a predefined variable, do the following:

  1. Ensure that you’ve added your credentials in the Uptrends Vault.
  2. Set up a predefined variable.
  3. Click .
  4. Select Vault credentials.
  5. Select a credential set along with its value. For example, selecting a username and password credential set.

Using username and password credential set as predefined variables

  1. Click Select.

Once created, you can use the variable to your API steps. In the example, the credential set were used in the Response headers. Looking at the Check details monitor results, the values are masked to keep the sensitive data hidden.

Predefined variables as shown in the Check details result

By using the Uptrends website, you consent to the use of cookies in accordance with our Cookie Policy.