Skip to main content

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.

Add an API request step from the Events tab via + Add step β†’ API request

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).

The API request builder β€” method, URL, Send, Import cURL, and the Body editor

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].id reads 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).

API request response panel and the Extract tab β€” map response values into variables, with the status pill, time, size, and Fail-on-error

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.