04 / Testing / api-assertions

API Assertions

Assert status, body text and JSONPath values of API responses.

ReadyLocal processing
04 · Workspace

How to use

  1. 01Enter the response Status code, for example 200 or 404.
  2. 02Add response headers in the Headers box, one key: value pair per line.
  3. 03Paste the response body into the Response body field.
  4. 04In the Assertions panel, pick an assertion type from the dropdown, fill in the target (a JSONPath or header name) and the expected value, or press + Add assertion for more rows.
  5. 05Read the PASS or FAIL result and message next to each assertion, plus the overall passed count, which update as you edit.

What is this tool?

A scratchpad for designing API test assertions against a response you paste in, without sending any request. It checks status codes, body text, response headers and JSONPath values, and explains each pass or failure with the actual value it found. It uses the same assertion engine as the API Testing Workbench, and everything runs locally in your browser.

Assertion types and how each one evaluates

Status equals compares the status code to a single number, and Status is one of accepts a comma-separated list such as 200, 201, 204. Body contains and Body does not contain do a case-sensitive substring search on the raw body text. Header equals looks up a header by name, case-insensitively, and compares its value exactly, so content-type must equal application/json; charset=utf-8 if that is what the server sent.

The JSONPath assertions parse the body as JSON first and fail with Response body is not valid JSON if it is not. JSONPath exists passes when the path matches anything. JSONPath equals, JSONPath > and JSONPath < compare the first match. For equals, the expected value is parsed as JSON when possible, so 42, true, null and {"id":1} are compared by value, and anything else is compared as text. Response time below (ms) is listed too, but it only passes in the API Testing Workbench, where a real response time exists.

Writing API assertions that catch real regressions

A status check alone misses most bugs: an endpoint can return 200 with an error object or an empty list. Pair the status with structure and value checks. For a user lookup, a useful set is Status is one of 200, JSONPath exists $.user.id, JSONPath equals $.user.name John, JSONPath > $.items.length 0 and Body does not contain error.

Avoid asserting on values that change every run, such as timestamps, generated IDs or tokens. Assert that they exist instead, and assert exact values only on fields your test controls. Because every failure message shows the actual value, you can paste a failing response from a CI log here and see exactly which expectation drifted.

Translating assertions into Postman, REST Assured and Playwright

The checks here map directly onto common frameworks. Status is one of corresponds to pm.expect(pm.response.code).to.be.oneOf([200, 201]) in Postman or statusCode(anyOf(is(200), is(201))) in REST Assured. JSONPath equals on $.user.name matches body("user.name", equalTo("John")) in REST Assured or expect(json.user.name).toBe("John") after response.json() in Playwright.

Prototyping here first lets you confirm the path and expected value against a real payload before you commit them to a test suite.

Common use cases

  • Designing assertions for a new endpoint before writing Postman or REST Assured tests
  • Reproducing a failed CI assertion against the response captured in the log
  • Checking a JSON contract field by field during manual exploratory testing
  • Showing developers exactly which response field broke a test
  • Teaching new QA engineers what makes a meaningful API assertion

FAQ

How do I assert a JSON value in an API response?

Choose JSONPath equals, enter a path such as $.user.name as the target and the expected value, for example John. The result shows the actual value found at that path.

Does this tool send API requests?

No. It evaluates assertions against a status, headers and body you paste in. To run assertions against a live response, use the Assertions tab in the API Testing Workbench.

Are body contains checks case-sensitive?

Yes. Body contains and Body does not contain perform an exact, case-sensitive substring match on the raw body.

Why does my Response time below assertion always fail here?

There is no real request in this tool, so no response time is available. That assertion is meant for the API Testing Workbench.

Are header names case-sensitive?

No. Header names are matched case-insensitively, but the header value must match exactly.

Is my response data uploaded?

No. All assertions run locally in your browser.