Route Behavior

Counters

Counters are named, mock-wide integers you can bump from one route and read back from any other — the smallest way to give a mock actual memory across requests, without the full Stateful CRUD machinery.

Free — this is not a Pro feature.

Incrementing a counter

In a route's Advanced section, set Increment counter to a name (e.g. hits). Every request that hits this route bumps that counter by 1. The counter belongs to the mock, not the route — any other route on the same mock can read it, or increment it too under the same name.

Reading a counter from a template

Enable Dynamic template on any route (it doesn't need to be the one that increments it) and reference it in the response body:

counters.<name>              → the counter's current value

A counter that has never been incremented is undefined in the template, which renders as an empty string — use Jinja's |default(0) filter if you want a plain 0 instead, as in the example below.

Example: a hit counter with no real backend

Two routes on the same mock:

  • POST /hits — Increment counter: hits, template enabled, response body:
json
{ "hits": "{{ counters.hits }}" }
  • GET /hits — template enabled (no increment), response body:
json
{ "hits": "{{ counters.hits|default(0) }}" }

Each POST /hits call returns the new total; GET /hits reports whatever the count currently is, without changing it. No stateful CRUD collection involved — the whole "database" is one number.

Resetting a counter

Open the mock's Counters panel to see every counter's current value and reset one back to zero — useful for rerunning a test scenario from scratch without recreating the mock or its routes.

Scope

A counter belongs to the mock it was created on, the same as Datasets — it isn't shared across different mocks, even within the same team.

Failing deterministically by request count

Counters are also what powers Chaos Injection's Fail the first N requests — a deterministic alternative to the probability-based error rate, for testing "the client retries twice, then succeeds" on demand instead of hoping a random roll cooperates. That gate tracks its own count per route rather than a named counter you create, so it doesn't show up in the Counters panel above.