Async API: how to test a status that doesn’t change right away
The order is created, but the warehouse assembles it in a background job that takes from 5 seconds to a minute. A check right after creation sees in_progress and fails, and a one-minute pause makes every check slow. In a Microkoi Bench request chain, a step repeats while the order is in progress and checks the outcome as soon as it arrives: complete means the step passed, failed means it fails right away, without waiting out the limit.
Why a pause or waiting for the final status doesn’t work
In a marketplace app, POST /orders responds immediately. Then a queue takes over: reserving the item in the warehouse, assembling the order, estimating delivery. Until the queue is done, GET /orders/{id} responds with progress: in_progress, and then with complete or failed.
A check without waiting sees in_progress and fails. A 10-second pause passes during the day and fails in the evening, when the queue is longer. A one-minute pause always passes, but waits a full minute even when the order was assembled in three seconds.
Waiting specifically for complete is no better. If the warehouse answered failed, the status won’t change anymore, yet the check keeps asking until the limit. Two minutes later it fails with “gave up waiting”, and the real cause — the order wasn’t assembled — gets lost.
You need a different condition: repeat the request while the order is in progress, and once the work is done, check right away how it ended.
A two-step chain
- Step 1, “Create order” — POST
{{baseUrl}}/orders. An “After response” rule takesdata.idinto theorderIdvariable. - Step 2, “Order status” — GET
{{baseUrl}}/orders/. While the order is being assembled, the server responds with status 202 and this body:{{orderId}}
{
"data": {
"id": "ord-48213",
"progress": "in_progress",
"updatedAt": "2026-11-28T12:04:11+03:00"
}
}Step 1. Describe a successful outcome
Select the “Order status” step. In the properties on the right, in the “Expect” section, click “Add condition” and fill in the row:
| Field | What to choose or type |
|---|---|
| What to check | “JSON value” |
| “Path or header” | data.progress |
| Comparison | “equals” |
| “Value” | complete |
Without conditions, a step expects only a status code from 200 to 299, and a 202 response with in_progress would pass the check.
Step 2. Repeat while the order is in progress
- In the “Before the step” section, turn on “Repeat”.
- Under “Repeat kind”, choose “While the response…”.
- Click “Add condition” and set the repeat condition: “JSON value”,
data.progress, “equals”,in_progress. - Enter 2 in the “Every” field and 120 in the “up to” field.
- Save the chain: ⌘S (Ctrl+S).
The arrow before the step shows “Every 2 s, up to 2 min”. While the response matches the repeat condition, Bench asks again. As soon as something else arrives, the repeat ends and the step’s expectations are checked right away.
| Response | What the step does |
|---|---|
progress: in_progress | Repeats the request in 2 seconds |
| progress: complete | Checks the expectations and passes |
| progress: failed | Checks the expectations and fails right away: data.progress = failed, expected complete |
in_progress for over 2 minutes | Fails: the response still matches the repeat condition |
Step 3. Run it and watch the attempts
Click “Run”. While the step repeats, a blue bar above the steps says “Repeating step 2 of 2…”, and the step block shows the state of the attempt:
| Step status line | What’s happening |
|---|---|
| “202 · Attempt 3 in 2.0 s” | The order is still in progress, the actual value is below the line: data.progress = in_progress |
| “Attempt 4… 0.1 s” | The request is sent, no response yet |
| “200 OK · 118 ms · 7 attempts” | The order is assembled, the step passed |
The number of attempts is a metric in itself. Yesterday the order took 2 attempts, today it takes 20: the queue has slowed down, even though the check is still green.
Which repeat to choose
“Repeat” has two kinds. The choice depends on which status you know in advance.
| What you know | What to use |
|---|---|
An intermediate status: in_progress, pending, processing | “While the response…” with that status |
| Only the successful outcome, the operation has no failed one | “Until the expectations pass” |
| Readiness isn’t visible in the response | “Pause” for a known time |
A pause can be up to 10 minutes. A repeat runs no more often than every 0.1 seconds and for no longer than 10 minutes, the same for both kinds. “Stop” ends the run immediately, even in the middle of a pause.
The same check on a schedule
Click “Add to monitoring” in the chain header: Bench creates a monitor that runs the chain every 5 minutes. The monitor repeats the step the same way. If the order gets stuck in in_progress, the check’s cause names the step and the actual value.
A monitor run is limited to 5 minutes, pauses and repeats included. If they might not fit, a “Doesn’t fit a monitor run” bar appears above the steps.
Update Bench for the whole team
A chain is a file in the workspace folder, and anyone who has the workspace runs it. Earlier Bench versions don’t know the “While the response…” repeat: if they save such a chain, they silently drop it. Update Bench for everyone who works with a shared workspace.
What you get
A check of a long-running operation takes exactly as long as the server works. A failed outcome shows up right away with the real cause, not after two minutes of waiting. The number of attempts tells you background processing has slowed down before users write about it.
Build a chain for your own long-running operation in beta 0.9.6 and write to beta@microkoi.com about the conditions you were missing for the repeat. We read every email.