Multiple API checks can target the same server/service. In this case, your checks might need the same configuration item like an authentication token, a specific user name or even just some specific part of the URL. You can use global variables to ‘DRY’ up your checks and store these variables in just one place.
You can add variables on the Variables tab in the Account section. The variables stored here are globally accessible throughout Checkly, hence the “Global environment variables” title*.
All variables are stored as string values. You can click the lock icon to encrypt the values and hide the value from all users that do not have write access.
Accessing variables in API checks
Environment variables are exposed to your API checks using the common Handlebars/Moustache templating delimiters, i.e.
Variables can be used in the following API checks fields:
- Header values
- Query parameters values
- Basic authentication username and password
When typing in most of the variable-enabled fields we show a small helper popup to help with selecting of the right variable.
Note, just the Body input field does not show this helper popup.
We are working on a “Group” feature, where we will allow variables per group of checks for finer grained control. This is why the variables in the account section are explicitly named “Global”
Last updated on June 13, 2019