A request chain from traffic: an API scenario without manual setup
The “find a product → cart → order” scenario takes a minute in the app. Building it from requests by hand takes half an hour: copy each one, find where the product id came from, type in the variables. Microkoi Bench builds the chain from recorded traffic by itself and shows which value each step passes on.
Why an API scenario takes so long to build
A user path is five to ten requests tied together by values. The token from the sign-in response goes into headers. The product id from search goes into the cart request body. The cart id goes into the order.
While you hunt for these links by eye, one gets missed. The chain passes on staging once, because the request still holds the recorded id, and fails the next day when the product sells out.
Step 1. Go through the scenario in the app
Start the proxy in “Traffic” with the “Start” button and go through the whole path in the marketplace app: sign in, search, product page, cart, checkout. How to route phone traffic through Bench is in “How to inspect your app’s HTTPS traffic on iPhone and Android”.
No need to avoid images, fonts and analytics. Bench sets them aside by itself.
Step 2. Select the scenario’s exchanges
| Action | What it selects |
|---|---|
| Click the first row, Shift-click the last | The whole range |
| ⌘-click (Ctrl-click) | Adds or removes a single row |
| Shift+↑, Shift+↓ | Extends or shrinks the selection by a row |
New exchanges appear at the top, so sign-in ends up at the bottom of the range and the order at the top. Bench restores the order by recording time. If a request from another browser tab got in the middle, remove it with ⌘-click.
Right-click the selection. Above the menu items is the number of exchanges, for example “11 exchanges”. Choose “Create request chain…”.
Step 3. Review the links it found
The “Create request chain” window looks for links in memory, across the selected exchanges. Nothing goes over the network: “Bench doesn’t send anything until you run the chain.” At the top is a summary, for example “11 exchanges · 4 steps · 2 links found”.
Under each step are links with checkboxes. The search step shows “After response data.items[0].id → productId · used by steps 2–3”. The cart step shows “Body productId: {{productId}} ← step 1 · was 48213”. Clearing a checkbox keeps the recorded value in the request.
Matches that Bench chose not to link appear as gray rows with a reason. They’re worth reading: sometimes the link is needed, and you add it by hand with an “After response” rule.
| Reason | What it means |
|---|---|
| “value too short” | page=1, 20, ok: such a match is almost always accidental |
| “common value” | A language code, an enum value, or a value from three or more endpoints |
| “dates aren’t linked” | A date or time outside the URL path |
“ambiguous: data.id, data.items[0].id” | The value is in several fields, and it’s unclear which one is meant |
| “already in the environment as “region”” | An environment variable already holds this value |
At the bottom of the list is a collapsed “Service requests” group, for example “7 excluded — images 3, fonts 2, analytics 2”. A row’s checkbox puts that exchange back into the steps.
Step 4. Give the steps clear names
A new request gets a default name from the method and the last path segment: GET products/{{productId}}. Replace it with “Product by id”, “Add to cart”, “Place order”: everyone who opens the collection will see these names.
If the collection already has a request with the same method and path, the step is labeled “Uses …” with its name. The chain will point to that request instead of creating a copy.
Step 5. Keep the address and secrets out of the files
- “Environment”: choose the staging environment. The address
https://stage.example.combecomes{{baseUrl}}if the environment has a variable with that address. - Tokens and cookies from responses aren’t stored anywhere: “Linked secrets aren’t saved anywhere: each run takes them from responses.”
- The password in the sign-in body has no source among the steps. Bench puts it into the selected environment as a secret, not into the request file.
- If the selection includes a sign-in with a refresh token, the “Make sign-in and refresh an “Authorization” block” switch is already on. The block signs in once, keeps the token between runs and refreshes it with
refresh_token.
Click “Create chain”. The “Requests” section opens with a tab for the new chain, and a “From traffic” folder with the new requests appears in the tree.
Step 6. Check the expectations and run it
Above the chain is a green bar: “Chain created from 11 exchanges.” and a reminder, “Expectations are the recorded status codes — check them before the first run.” If the cart returned 409 during recording, the step will expect 409. Select the step and fix the code under “Expect”.
Click “Run”. The arrows between steps show the values received, for example productId = 48213, and if the chain breaks, a red bar names the step and the reason.
The chain places a real order. Run it on staging as a test user, not in production.
What you get
A scenario the tester walked through by hand turns into an API check in a couple of minutes, one you can repeat after every backend release. The chain is a file in the workspace next to the collection, so you can put it in git and check it on a schedule in “Monitoring”.
Build a chain from your longest scenario in beta 0.9.6 and write to beta@microkoi.com about which links Bench found and which it missed. We read every email.