Route Behavior

Datasets

Datasets are named tables of test data that live on a mock and can be shared across its routes — instead of copy-pasting the same example rows into every route's response body, define them once and reference them from a Dynamic Template.

Creating a dataset

On a mock's page, open the Datasets panel and click Add. Give it a name (this is what you'll reference in templates) and its rows as a JSON array of objects:

json
[
  { "id": 1, "name": "Ada", "email": "ada@example.com" },
  { "id": 2, "name": "Grace", "email": "grace@example.com" }
]

You can also click Import CSV and upload a CSV file instead of typing JSON by hand — the header row becomes each row's keys, and every value comes through as a string (CSV has no other types). Either way, editing a dataset later updates every route that references it; there's nothing to keep in sync by hand.

Referencing a dataset from a template

Enable Dynamic template on a route, then use the dataset in its response body:

datasets.<name>              → the full table (a list of rows)
datasets.<name>[0]           → the first row
datasets.<name>[0].email     → a field on that row
pick_random('<name>')        → one random row from the table

pick_random uses a cryptographically secure random source, not a predictable pseudo-random generator, and returns a different row on every call — useful for a route that should look different each time it's hit without you hand-writing every variation.

Example

A mock with a users dataset (the two rows above) and this route:

  • GET /users/random, template enabled, response body:
json
{
  "id": "{{ pick_random('users').id }}",
  "name": "{{ pick_random('users').name }}"
}

Note that each pick_random('users') call is independent — the example above can mix fields from different rows. To get one consistent row's fields together, look it up once with a variable-free reference like datasets.users[0], or match on an id via Conditional Matching instead of picking randomly.

Referencing a dataset that doesn't exist

datasets.<name> for an unknown name renders as empty rather than erroring the request — the same fail-open behavior as any other undefined template value. pick_random() on an unknown or empty dataset returns nothing.

Limits

A mock can have up to 10 datasets, each with up to 500 rows. Both counts are enforced when you save.

Scope

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