Skip to main content

Conditions and Assertions

Conditions and assertions are rules attached to a monitor that determine whether each response is classified as a pass, warning, or failure. Without conditions, APIContext uses sensible defaults (2xx = pass, 4xx = warning, 5xx = error). With conditions, you define exactly what "correct" means for each endpoint.

You set a monitor's conditions in the Assertions section of its Edit tab (open it from Monitors). Conditions for the whole project are under Project Conditions: HTTP, Header, and Latency in the sidebar.

Conditions vs. assertions​

The terms are used interchangeably in parts of the UI, but they serve slightly different roles:

  • Conditions control flow: they decide what happens after a call completes, such as whether a workflow should stop on failure (for example, only run the next step if the previous response was successful)
  • Assertions verify data: they check that specific parts of the response match expected values (like the status code, headers, or even the full response body)

In practice, both are configured in the same place and both contribute to the pass/fail/warning verdict.

What you can check​

Check typeExample
HTTP status codeExpect 200; treat 500 as a pass for negative testing
Response headerContent-Type must equal application/json
Response body (string)Body must contain the word "success"
JSON pathuser.id must equal 5
Raw response (_raw)Full response body must match an exact string or contain a substring
Response size (bytes)Response must be less than 100 bytes, or exactly 0 for empty-body checks
LatencyTotal latency over 1000 ms triggers a "passed but slow" result

How conditions affect other features​

  • Alerts fire based on the verdict that conditions produce: a warning condition triggers warning alerts, an error condition triggers error alerts
  • CASC Quality Score uses the pass/fail ratio driven by conditions as its primary input
  • Workflows can stop at the first failing step, which is determined by that step's conditions

See also​