Skip to main content
Learn more about API Checks in the API Checks overview.
Use API Checks to monitor HTTP endpoints, REST APIs, GraphQL APIs, and other HTTP-based services. The examples below show how to configure monitoring for different types of API endpoints.
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
For additional setup information, see CLI overview.

Configuration

The API Check configuration consists of specific API Check options and inherited general check options.

ApiCheck Options

request
object
required
The HTTP request configuration that defines the API endpoint to monitor. This is the core component of any API Check.Usage:
Parameters:Examples:
Use cases: HTTP endpoint monitoring, REST API testing, GraphQL API validation, authentication testing.
degradedResponseTime
number
default:"10000"
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.
maxResponseTime
number
default:"20000"
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.
shouldFail
boolean
Whether a failure should count as a pass. When set to true, HTTP status codes 400 and above are reported as passed instead of failed.Usage:
Examples:
Use cases: Negative testing, error handling validation, security testing.
setupScript
object
Script to run before the API Check execution. Useful for setting up test data or authentication tokens.Usage:
Parameters:
You must provide either entrypoint or content, but not both.
Learn more about writing setup and teardown scripts in the setup and teardown scripts documentation.
Use cases: Test data setup, authentication preparation, environment configuration.
tearDownScript
object
Script to run after the API Check execution. Useful for cleaning up test data or resources.Usage:
Parameters:
You must provide either entrypoint or content, but not both.
Learn more about writing setup and teardown scripts in the setup and teardown scripts documentation.
Use cases: Test data cleanup, resource cleanup, logging and reporting.

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 404
  • jsonBody(property?): Assert the JSON response body. The property argument accepts a JSON path expression
  • textBody(): Assert the body as raw text
  • headers(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 value
  • responseTime(): Assert the total response time of the HTTP request
Learn more in our docs on Assertions. Assertion Examples
  • 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

Examples

When using environment variables in your requests (like {{API_TOKEN}}), make sure they are properly configured in your project or check group settings.