Assertions
What are assertions?
Section titled “What are assertions?”An assertion is a condition your API response must meet. You add one or more assertions to a check, and when any of them is not met the check is marked failed and an alert is triggered.
Types of assertions
Section titled “Types of assertions”- Status code: compare the HTTP status code of the response with a number, for example Equals
200, or Less than400. - Response time: compare the total response time, in milliseconds, with a number, for example Less than
800. - Body: check that the response body Contains, or Does not contain, a piece of text. The match is a literal, case-sensitive substring; regular expressions are not supported, and an empty value always fails.
For status code and response time you can choose Equals, Not equals, Equals or Greater than, Equals or Less than, Greater than or Less than.
How to add an assertion
Section titled “How to add an assertion”- In the check form, find the Assertions section and click Add Assertion.
- Pick the type (Status code, Response time or Body).
- Pick the comparison and type the Value.
- Save the check.
Failed assertions and check details
Section titled “Failed assertions and check details”When an assertion fails, the check details page shows which assertion failed, so you can see why the check was marked failed.
Interaction with response time limits
Section titled “Interaction with response time limits”If a check is slower than its response time limit it is marked degraded. If it also has a failing assertion, the check is marked failed.
Practical use cases
Section titled “Practical use cases”- Performance: a Response time assertion with Less than sets a hard ceiling for your API.
- Error detection: a Status code assertion catches unexpected errors.
- Content: a Body assertion confirms that the response still contains the value you expect, for example a field name or a keyword.
Multistep checks support the same assertions on each step, see Multistep API Checks.
