Hurl Captures and Asserts: Chain and Verify Responses
Hurl [Captures] pull values like tokens out of a response and [Asserts] check that response fields match expectations.
Captures and asserts turn a list of requests into a real test: capture a token from a login response, reuse it in the next request, and assert the final response looks right.
What it does
A [Captures] section binds a name to a value extracted with a query such as jsonpath "$.token", a header, or a regex; captured names become variables usable in later entries. An [Asserts] section checks queried values against predicates like == 200, contains, exists, or count == 3. Response status and headers can also be asserted implicitly.
Common usage
POST https://example.com/login
{ "user": "bot", "pass": "secret" }
HTTP 200
[Captures]
token: jsonpath "$.access_token"
GET https://example.com/api/profile
Authorization: Bearer {{token}}
HTTP 200
[Asserts]
jsonpath "$.role" == "admin"
jsonpath "$.items" count == 3Options
| Construct | What it does |
|---|---|
| [Captures] | Extract values into variables for later entries |
| jsonpath "$.x" | Query a JSON body by JSONPath |
| header "Name" | Capture or assert a response header |
| [Asserts] | Verify queried values against predicates |
| == / contains / exists / count | Assertion predicates |
In CI
Run these files with hurl --test so failed asserts fail the build. Captures let a single file cover a full login-then-act flow without wiring a token through the command line, keeping the whole scenario in one reviewable file.
Common errors in CI
A capture that yields nothing prints error: Undefined variable when the name is used later, which usually means the JSONPath did not match the response shape. error: Assert failure shows the actual versus expected value. error: Invalid JSONPath flags a malformed query expression.