API tests
HTTP checks with assertions, extraction and chained requests.
syntheticapihttpassertions
API tests
API tests send HTTP requests and assert on the response. Use them for high-frequency health checks and for validating contracts (status, schema, latency, specific values).
Configuration
- Method and URL, headers, query params, and a request body.
- Auth — bearer token, basic, or a custom header (store the token as a secret).
- Assertions — status code, response time, header values, and JSON body values via a dot/JSONPath.
- Extraction — pull a value from the response into a variable to use in a later chained request.
Example: create-then-read contract test
# Step 1 — create
POST https://api.example.com/v1/orders
Headers: Authorization: Bearer {{API_TOKEN}}
Body: { "sku": "ABC-123", "qty": 2 }
Assert: status == 201
Extract: orderId = body.id
# Step 2 — read back what we created
GET https://api.example.com/v1/orders/{{orderId}}
Assert: status == 200
Assert: body.status == "confirmed"
Assert: responseTimeMs < 800
Multiple cases
- Smoke health: a single GET asserting
status == 200, run every 30s. - Contract: assert response JSON shape and key values after a deploy.
- Auth-protected: obtain a token in step 1, reuse it via
{{token}}. - SLA latency: assert
responseTimeMs < Nto catch slow regressions.
Need to also confirm the database row was actually written, not just that the API said 201? Use a Workbook that runs the API test and then a DB Collector query.