API check defaults
Using a set of shared defaults for API checks helps you manage checks that go to the same basic endpoint, share headers and other settings.
HTTP request defaults
You can set defaults for many aspects of an API request, see the separate paragraphs below. The following properties are still controlled at the check level:
- HTTP method & body
- response time limits
Base URL
Use the base url to define the shared protocol, domain and path for URLs in your group’s API checks. This works as follows:
- Set the base URL, i.e.
https://api.example.com/v1
- The base URL is now available in the
{{GROUP_BASE_URL}}
variable - In your API check, append path and query params, i.e.
{{GROUP_BASE_URL}}/customers?page=1
Headers & query parameters
Any headers and query parameters defined in the API check defaults are injected into each API check.
An example:
- At the group level, you define the header
X-Custom:
with value123
- At the API check level, you define the same header
X-Custom
just with the valueabc
- Checkly will call your API with the
X-Custom: abc
header
Basic Auth
Use the basic auth username and password to inject it into each API check in the group.
Assertions
Any assertions are injected into each API check’s assertion list. Use this to always assert common response codes or headers for your API checks.
Setup & teardown scripts
You can add setup and teardown scripts at the group level as well as the individual group level.
This is the execution flow:
- Group level setup script
- Check level setup script
- Execute your API check
- Check level teardown script
- Group level teardown script
A common scenario for having two levels of setup scripts is the following:
- Group level setup: Fetch a token from a common authentication endpoint.
- Check level: prep some specific test data for this individual check.
Last updated on November 25, 2024. You can contribute to this documentation by editing this page on Github