api should
Assert last API response status, body, or JSON path
Assertions against the last HTTP response on the Platform: api session.
Forms
| Form | Meaning |
|---|---|
api should status "<code>" | Status code equals |
api should body contain "<fragment>" | Response body contains substring |
api should json path "<path>" exist | gjson path exists |
api should json path "<path>" be "<value>" | gjson path string equals expected |
Requirements
| Item | Contract |
|---|---|
| Element / control shape | None — HTTP session (Platform: api) |
| How the label binds | Path / body / headers are payloads ($ENV, slots expand) |
| Qualifiers that change resolve | See this command’s Qualifiers table |
| Platform | Platform: api only — requires $API_BASE_URL (and auth env as needed) |
| Wrong shape → use instead | UI XHR wait → wait for response. Browser UI → web commands |
See also UI contracts and Platform: api.
Examples
Then I api should status "201"
And I api should body contain "book"
And I api should json path "$.id" exist
And I api should json path "$.item" be "book"
And I api should json path "$.id" be "@order-id"Qualifiers
| Qualifier | Role |
|---|---|
status | Expected HTTP status code |
body contain | Substring in response body |
json path | gjson-style path ($.id, …) |
exist | Path must be present |
be | Path string equals expected (resolved) |
Notes
- JSON paths use gjson dialect.
- Expected values in
be/body contain/statusgo through shared resolve (whole-string@slot,$ENV, …).
Related
- api wait (poll until path matches)
- store (
from api json) - Platform: api
- UI contracts