# capture_response

The `capture_response` step.

Waits for a network response matching `url` (and `method`), observed since the step started, and stores its parsed JSON body in a variable. Bodies are limited to 2 MB.

Type: `object`

## Keys

| Key | Type | Description |
|---|---|---|
| `capture_response.into` | `string` | The variable that receives the value, written `vars.<name>`. |
| `capture_response.json` | `string` | A JSONPath into the response body; the result is stored instead of the whole body. |
| `capture_response.method` | `string` | The HTTP method the response's request must have, such as `GET` or `POST`. Without it, any method matches. |
| `capture_response.timeout_ms` | `integer` | How long to wait for the response in milliseconds, up to `120000`. Defaults to `15000`. |
| `capture_response.url` | `string` | A glob the response URL must match, such as `**/api/orders*`. An invalid glob is lint `E009`. |

Every step also takes the [common step keys](https://docs.kaab.ist/reference/dsl/steps#common-keys): `expect`, `id`, `if`, `name`, `on_error`, `optional`, `retry`, `side_effect`, `timeout_ms`, `x_kaab`.

## Example

```json
{
  "capture_response": {
    "url": "**/api/products*",
    "method": "GET",
    "json": "$.items[*].price",
    "into": "vars.prices",
    "timeout_ms": 15000
  }
}
```

From the contract fixture `capture-response`, a program the test suite validates.
