Skip to content

Response Validation

Assert on what the API actually returned.

Describe the response you expect — status, headers, body fields and response time — and curl-runner checks every one. Match exact values, regex patterns, numeric ranges, a list of allowed values, or just that a field exists.

user.yaml
request:
  name: Get user
  url: https://api.example.com/users/1
  expect:
    status: 200
    headers:
      content-type: application/json
    responseTime: "< 500"
    body:
      id: 1
      email: "^[^@]+@[^@]+$"
      role: [admin, editor]
      age: ">= 18"
      createdAt: "*"

Benefits

  • More than equality

    Regex patterns, ranges like ">= 18", one-of lists and "*" wildcards cover the values that change on every call.

  • Status, headers, body, time

    Check the whole response in one expect block, including nested objects, arrays and a response-time budget.

  • Failures that explain themselves

    Each failed check names the path, what was expected and what came back, so you fix the right thing first.

Good for

  1. Contract checks against a running API
  2. Catching a field that silently changed type
  3. Holding endpoints to a response-time budget
  4. Post-deploy smoke tests