API and code · Mock server docs

The endpoint mock block

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

Each endpoint may carry a mock block inside its data. Every key is optional. It is saved like the rest of the endpoint: a revision with a note, a stale rev is refused, a member's change is a proposal. Edit it through MCP (Editing with MCP).

{
  "presets": [{ "status": 200, "body": { "status": true } }],
  "sets": [{ "key": "cashActive", "value": false }],
  "accept": { "body.b": { "always": ["0", "1"] } },
  "approval": { "mode": "token" },
  "delayMs": 300
}
KeyWhat
presetsCanned answers per status, picked by state (when) or by the request (match).
setsState changes after a 2xx answer in a session.
acceptValue checks on request fields.
approvalThis endpoint starts a two-step approval.
confirmThis endpoint confirms the pending approval.
loginThis endpoint is the project's mock login.
delayMsWait this long before answering.

Every save checks the block against the rest of the endpoint: a preset's status must be one of the endpoint's responses; accept keys, match keys and an approval's request field must name documented fields. The checks run on every save, also when someone edits only the contract.

presets

{
  "presets": [
    { "status": 200, "when": { "accountActive": false }, "final": true, "body": { "status": false, "message": "The account is not active." } },
    { "status": 200, "match": { "query.mode": "fast" }, "body": { "speed": "fast" } },
    { "status": 200, "body": { "speed": "normal", "balance": "{{state.balance}}" } },
    { "status": 404, "body": { "detail": "Not found." } }
  ]
}
  • status (required): one of the endpoint's documented statuses.
  • body (required): any JSON. Strings that are exactly one template are filled (State, rules and templates).
  • when: state key → value. All must be equal (typed: true is not "true"). Keys may be dot paths (account.cash.active).
  • match: request key → value: "body.<field>", "query.<field>" or "path.<field>". All must be equal, compared as text (form values are strings).
  • final: true: this answer ends the action: no approval starts, no sets run (a refused action).

For the answer's status: the first preset with a when / match that fits wins, else the first one without either, else fake values from the documented response fields. In a session the scenario's presets come first (Project config). Without a session a preset with when never answers.

sets

{
  "sets": [
    { "key": "cashActive", "value": false },
    { "key": "lastReason", "value": "{{body.reason}}" },
    { "key": "depots[depotId={{path.depotId}}].linkedToCashAccount", "value": true },
    { "op": "remove", "key": "depots[depotId={{path.depotId}}]" },
    { "op": "logout" }
  ]
}

Run in order after a 2xx answer in a session (not after a final preset). op is set (the default), remove or logout. Details: State, rules and templates.

accept

{
  "accept": {
    "body.iban": { "pattern": "^DE[0-9]{20}$", "always": ["TEST"] },
    "query.mode": { "pattern": "^(fast|slow)$", "status": 422, "body": { "detail": "Unknown mode." } }
  }
}

Keys "body.<field>" or "query.<field>" (documented fields). A sent value passes when it is in always or matches pattern. A failed check answers the rule's status + body, else 400 {"error":"invalid_value","field":"body.iban"}. Details: Test helpers.

approval

{ "approval": { "mode": "request:body.b", "values": { "1": "token", "0": "id" } } }

mode is "token", "id", "state:<key>" (the state value names the kind) or "request:body.<field>" / "request:query.<field>" with values (request value → "token" | "id"). Details: Two-step approvals.

confirm

{ "confirm": { "refField": "tan_id", "codeField": "tan", "fail": { "status": 200, "body": { "status": false } } } }

refField (required): the request field with the reference. codeField: the field with the code (left out = the reference alone confirms). fail: the answer when the reference or code is wrong, missing or used (default 400 {"error":"invalid_code"}). Details: Two-step approvals.

login

{ "login": true }

Marks the login endpoint. It works only with a login in the project config (Project config).

delayMs

{ "delayMs": 1500 }

0..10,000 ms. In a session the header X-Mock-Delay can ask for a wait too; the larger one is used (≤ 10 s).

Limits

KeyLimit
whole block128 KB (JSON)
presets50
when / match10 keys each
sets20; a key path ≤ 200 characters, ≤ 10 steps
accept20 rules; always ≤ 20 values; pattern ≤ 200 characters; no nested quantifiers like (a+)+, no backreferences or lookarounds
approval.values20
delayMs0..10,000

A pattern is run only on values of ≤ 256 characters; a longer value fails the rule.