Call an API & use its response
Sometimes a flow needs to talk to an API directly β to set up data before the UI test (create an account, seed a record), to read a value the UI never shows (an id, a token, a generated link), or to start from a URL the backend returns. An API request step calls an HTTP endpoint during replay, optionally pulls values out of the response into {{var.NAME}} variables, and the flow continues with them.
It runs server-side (Node fetch, not the page), so it isn't subject to the page's CORS rules and can run before any page has loaded β e.g. as step 1 to fetch the URL you then navigate to.
Add an API request stepβ
- On any session (including an empty one), open the Events tab and click οΌ Add step βΎ β β‘ API requestβ¦.
- Or right-click an event row β Insert API requestβ¦ to drop one at that position.
Either opens the request builder in the Edit drawer.
Build the requestβ
- Method + URL β choose the verb (GET / POST / PUT / PATCH / DELETE) and type the URL. The URL accepts
{{β¦}}templates. - Params / Headers β Postman-style rows: an enable checkbox, key, and value (each value templatable). Disabled rows are skipped; Params are appended to the URL as
?k=v. Use Bulk edit to paste many at once. - Body β a JSON or raw body (templatable), sent for POST/PUT/PATCH. Beautify pretty-prints JSON; + Template inserts a value.
- Send βΈ β fires the request once, right now, so you can see the real response while authoring (it doesn't touch your saved steps).
Import from cURLβ
Already have the request as a cURL command β DevTools β Copy β Copy as cURL, or straight from Postman/Insomnia? Click β€ Import cURL, paste it, and Import: the method, URL, query params, headers, and body are filled in automatically (the query string is lifted into Params, and -u user:pass becomes a Basic-auth header). Then tweak and Send.
Inspect the responseβ
After Send, the response panel shows a colored status pill (β 200 OK), the time and size, with tabs:
- Body β pretty-printed (Beautify) or raw; the text is selectable so you can copy it.
- Headers β the response headers, as a table.
- Extracted β the values your extract rules pulled out (next).
Extract values into variablesβ
The Extract tab maps a variable name to a location in the response, so later steps can reference it as {{var.NAME}}:
- JSON dot-path β e.g.
data.items[0].idreads that field out of a JSON body. /regex/β wrap a pattern in slashes to pull a substring from the raw body (capture group 1 if present, otherwise the whole match).
Extraction runs on every replay, so the variable always reflects the current run's data β just like a Capture step, but sourced from an API instead of the page. Reference the value anywhere {{β¦}} is accepted: a later input, a URL, a header, or an assertion.
Fail on errorβ
By default any HTTP status β₯ 400 fails the step, so a broken setup call stops the run loudly. Uncheck Fail on error to let the flow continue regardless (e.g. when you only care about extracting whatever came back).
Example β fetch a URL, then drive itβ
1. api-request GET https://api.example.com/sessions/new
extract: startUrl β data.url
2. navigate {{var.startUrl}}
3. click #continue
β¦
Step 1 calls the API with no page open, pulls data.url into startUrl, and step 2 navigates the browser to that run's real URL. (This is exactly why the Record Start URL can be left blank β the first step can produce it.)
API request steps run in Play, Resume, and Debug β same engine everywhere.