1. Reference
  2. Assertions

Reference

Assertions reference

Assertions verify that response data is correct. If any assertion fails, the check is marked as DOWN.

API monitoring assertions in OnlineOrNot

Assertion types

JSON body

Assert on values in JSON responses using JSONPath.

Field Description
Property JSONPath expression (e.g., $.data.user.name)
Expected value Value to match

Use the JSONPath online sandbox to test expressions.

Text body

Assert on text content anywhere in the response body.

Field Description
Property Not used; text body assertions check the whole response body
Expected value Text to match (for comparisons such as Contains or Equals)

Response headers

Assert on HTTP response headers.

Field Description
Property Header name (e.g., Content-Type)
Expected value Expected header value

HTML body

Assert on HTML elements using CSS selectors.

Field Description
Property CSS selector (e.g., meta[name="viewport"])
Expected value Expected element content

Notes:

  • Commented-out elements (<!-- ... -->) are not found
  • Supports all CSS selectors
  • HTML assertions check the selected element's text content, except meta tags where they check the content attribute
  • Empty elements like <link> can be checked for existence with Not null, but Not empty will fail because they have no text content
  • To check a <link> attribute such as href, include it in the selector, for example link[rel="canonical"][href="https://example.com/page"] with Not null

Common CSS selector patterns:

Selector Matches
meta[name="viewport"] Exact attribute match
link[rel="canonical"] Canonical link tag exists
link[rel="canonical"][href="https://example.com/page"] Canonical link with exact URL exists
script[src*="analytics"] Attribute contains substring
[property^="og:"] Attribute starts with
[href$=".pdf"] Attribute ends with
.cookie-banner Class name
#main-content ID

Comparisons

Comparison Description
Equals Exact match
Not equals Does not match
Greater than Numeric comparison
Less than Numeric comparison
Null Value is null
Not null Value exists
Empty Value is empty string
Not empty Value has content
Contains Substring match
Not contains Substring not present
True Boolean true
False Boolean false