Stateful API flows
Mock APIs that actually have state
Real APIs don't return the same response every time. Mockra's stateful sequences let you define ordered steps — so your mock behaves like the real thing across sequential calls.
The problem
- ✕Static mocks always return the same response — real APIs don't
- ✕Can't test an OAuth flow where the token expires after one use
- ✕Can't simulate a payment that succeeds then fails on retry
- ✕Can't test inventory depletion across sequential purchase calls
- ✕Multi-step flows require real API sandboxes that are slow and unreliable
With Mockra
- ✓Define ordered steps: each call advances the sequence automatically
- ✓Set repeat counts per step — serve a response N times before advancing
- ✓Terminal steps are sticky — once reached, they repeat forever
- ✓State is tracked atomically per endpoint and per namespace
- ✓Reset state between test runs with a single API call or dashboard button
Example stateful sequences
OAuth token flow
POST /auth/token
1
200Token issued
repeat: 12
401Token expired
repeat: 33
200Refresh succeeds
stickyPayment processing
POST /payments
1
200Payment pending
repeat: 12
200Payment processing
repeat: 23
200Payment confirmed
stickyInventory depletion
GET /products/SKU-001
1
200In stock: 5 units
repeat: 32
200Low stock: 1 unit
repeat: 23
404Out of stock
stickyConfigure a sequence via API
Common stateful patterns
OAuth flowsPayment sequencesInventory depletionRate limit simulationToken refresh cyclesRetry logic testingWebhook delivery statesAsync job polling
Stateful mock sequences are available on the Starter plan and above.
Test the flows that matter most
Define sequences, test multi-step flows, reset state between runs.
Get started for free