API and code · Mock server docs

Test helpers

The mock server is part of every plan except Time only. Request access · See the plans

Forced answers, the request log, delays, multipart uploads and accept rules. Forced answers, the log and the X-Mock-Delay header need a session; the others work with or without one.

Forced answers

Make the next calls of one endpoint fail (or answer anything you like) in one session.

POST <base>/__mock/s/run-1/__mock/force
Content-Type: application/json

{"method": "PUT", "path": "/api/depots/any/link-cash-account/", "status": 500, "body": {"detail": "Server error."}, "times": 1}
{ "items": [{ "endpointId": "depot-link", "method": "PUT", "path": "/api/depots/any/link-cash-account/", "status": 500, "body": { "detail": "Server error." }, "times": 1 }] }
  • method, path (required): matched like a call, so /api/depots/any/… picks the endpoint /api/depots/{depotId}/…; every call of that endpoint counts, whatever the placeholder.
  • status (required): 200..599. It need not be documented.
  • body: any JSON; left out = an empty answer.
  • times: 1..100 (default 1). Each call uses one; at 0 the entry goes.

A forced answer comes before every other rule: no login check, no sets, no approval. It is logged. Several entries for one endpoint answer first in, first out.

GET /__mock/force lists the queue ({items}); DELETE /__mock/force empties it. No endpoint for that method and path → 404 {"error":"unknown_endpoint"}. ≤ 50 entries (120 KB) per session.

Request log

Every endpoint call in a session writes one row: method, the path as called (after the key and the session URL, with its query), the answer's status and the request body.

GET <base>/__mock/s/run-1/__mock/log?limit=100
{
  "items": [
    { "id": 1, "at": "2026-11-12T09:00:00.000Z", "method": "POST", "path": "/api/auth/login", "status": 200, "body": { "username": "sam.tester@example.com", "password": "***" } },
    { "id": 2, "at": "2026-11-12T09:00:01.000Z", "method": "POST", "path": "/api/cash-account/deactivate", "status": 200, "body": { "b": "1" } }
  ],
  "nextAfter": null
}
  • Oldest first. limit 1..500 (default 100). nextAfter is set when more rows follow: ask again with ?after=<nextAfter>.
  • The body as read: JSON, form fields (strings), or for multipart {"files": [{field, name, type, size}], "fields": {…}}. No body → null.
  • The login password reads "***". A body over 16 KB is stored as {"cut": true, "bytes": n}.
  • ≤ 500 rows per session (about 20,000 per project; the oldest go first), kept 24 hours. Reset clears the log.
  • Calls of an unknown path in a session are logged with status 404. Control calls are not logged.

Delay

mock.delayMs on the endpoint, or the header X-Mock-Delay: <ms> on a call in a session. The larger one is used, at most 10 seconds. Without a session only the endpoint's delayMs counts.

Multipart

multipart/form-data bodies up to 4 MB are accepted (every other type: 64 KB). Text fields are read like form fields. A file field reads as {name, type, size}: required-field checks, accept, match and templates see that it was sent ("{{body.file.name}}" gives the file name). The file itself is never kept.

Accept rules

Check the values your app sends; answer like your server does when one is wrong.

{
  "accept": {
    "body.iban": { "pattern": "^DE[0-9]{20}$", "always": ["TEST"] },
    "body.b": { "always": ["0", "1"], "status": 400, "body": { "b": ["Must be 0 or 1."] } },
    "query.mode": { "pattern": "^(fast|slow)$", "status": 422, "body": { "detail": "Unknown mode." } }
  }
}
  • Keys "body.<field>" or "query.<field>", naming documented fields.
  • A rule runs only when the field was sent (also null). Missing required fields are checked before (400 Missing required fields).
  • A value passes when it is in always, else when it matches pattern (a regular expression: no flags, no nested quantifiers, backreferences or lookarounds). A rule with only always lets only those values pass.
  • The first failing rule answers its status + body, else 400 {"error":"invalid_value","field":"body.iban"}.
  • Values are compared as text (numbers as written, objects as JSON). Patterns run only on values of ≤ 256 characters.

Accept rules run with and without a session.