Prerequisites
Prerequisites
Before creating API Checks, ensure you have:
- An initialized Checkly CLI project
- URLs or HTTP endpoints you want to monitor
- Understanding of HTTP status codes and response behavior
- Network access to the URLs you want to monitor
Configuration
The API Check configuration consists of specific API Check options and inherited general check options.- API Check
- General Check
ApiCheck Options
The HTTP request configuration that defines the API endpoint to monitor. This is the core component of any API Check.Usage:Parameters:Use cases: HTTP endpoint monitoring, REST API testing, GraphQL API validation, authentication testing.
Examples:
Response time threshold in milliseconds for marking the check as degraded. This provides an early warning before the check fails completely.Usage:Use cases: Performance alerting, SLA monitoring, gradual degradation detection.
Maximum response time in milliseconds before marking the check as failed. This sets the absolute threshold for check failure based on response time.Usage:Use cases: Performance monitoring, SLA compliance, timeout management.
Whether a failure should count as a pass. When set to Examples:Use cases: Negative testing, error handling validation, security testing.
true, HTTP status codes 400 and above are reported as passed instead of failed.Usage:Script to run before the API Check execution. Useful for setting up test data or authentication tokens.Usage:Parameters:Use cases: Test data setup, authentication preparation, environment configuration.
You must provide either
entrypoint or content, but not both.Script to run after the API Check execution. Useful for cleaning up test data or resources.Usage:Parameters:Use cases: Test data cleanup, resource cleanup, logging and reporting.
You must provide either
entrypoint or content, but not both.ApiCheck Assertions
To define assertions for the request of an ApiCheck you should use the AssertionBuilder. The following sources are available for API check assertions:
statusCode(): Assert the HTTP status code for the HTTP request, e.g. 200 or 404jsonBody(property?): Assert the JSON response body. The property argument accepts a JSON path expressiontextBody(): Assert the body as raw textheaders(propery?, regex?): Assert a set of response headers, takes the header name as the property argument and a regex to tease out a string from the header valueresponseTime(): Assert the total response time of the HTTP request
- Asserting an HTTP status code
- Asserting a part of a JSON response body using a JSON path expression
- Asserting the value of a part of an HTTP response header. Note that you can pass in a regex as the second argument