API and code · Mock server docs
Two-step approvals
The mock server is part of every plan except Time only. Request access · See the plans
Some actions need a second step: the app gets a reference, then confirms it (in the app, or with a TAN). The mock plays both steps in a session:
- An action endpoint (
mock.approval) answers 2xx and hands out a reference. Itssetsdo not run yet: they wait as the session's pending approval (their templates are filled now, from this request). - A confirm endpoint (
mock.confirm) with that reference (and a valid code, if it asks for one) runs the waitingsets, then its ownsets. The pending approval is gone: a reference works once.
One pending approval per session: a new action replaces the older one. Without a session there are no approvals (the action answers, nothing waits).
The reference: token or id
| Kind | Reference | Added to the answer |
|---|---|---|
token | 32 url-safe characters | {{approval.token}} in the preset body, else "token": "…" added at the top level |
id | a 6-digit number | {{approval.id}} in the preset body, else "id": 123456 added at the top level |
approval.mode
{ "approval": { "mode": "token" } }
{ "approval": { "mode": "state:approvalKind" } }
{ "approval": { "mode": "request:body.b", "values": { "1": "token", "0": "id" } } }
"token"or"id": always that kind."state:<key>": the session's state value at that key says"token"or"id"."request:body.<field>"/"request:query.<field>": the request value picks the kind throughvalues(values compared as text). The field must be documented.
When the mode names no kind (state missing, a value not in values), the call answers 400
{"error":"approval_mode","field":"body.b"} and nothing is stored.
confirm
{ "confirm": { "refField": "token" } }
{ "confirm": { "refField": "tan_id", "codeField": "tan", "fail": { "status": 200, "body": { "status": false, "message": "Wrong TAN." } } } }
refField: the request field with the reference (body first, then query).codeField: the field with the code. The code must be one of the config'sconfirmCodes(default["123456"]). Left out: the reference alone confirms (token-only confirm).fail: the answer when there is no pending approval, the reference is wrong or used, or the code is wrong. Default 400{"error":"invalid_code"}. Nothing changes.
A confirm endpoint without a session is not checked (it answers like any endpoint).
A refused action: final
{
"approval": { "mode": "token" },
"presets": [
{ "status": 200, "when": { "accountActive": false }, "final": true, "body": { "status": false, "message": "The account is not active." } },
{ "status": 200, "body": { "status": true, "data": { "key": "{{approval.token}}" } } }
]
}
A final preset answers and stops: no approval starts, no sets run, the pending approval stays as it was.
Example: one action, two ways to confirm
The deactivate call sends b=1 (confirm in the app with a token) or b=0 (confirm with a TAN by id). See
Full example for the full endpoints.
POST <base>/__mock/s/run-1/api/cash-account/deactivate/ b=1
→ {"status": true, "data": {"key": "Q2x…"}}
POST <base>/__mock/s/run-1/api/cash-account/confirm/ token=Q2x…
→ {"status": true} (cashActive is now false)
POST <base>/__mock/s/run-1/api/cash-account/deactivate/ b=0
→ {"status": true, "data": {"tan_id": 482910}}
POST <base>/__mock/s/run-1/api/cash-account/confirm-tan/ tan_id=482910&tan=000000
→ {"status": false, "message": "Wrong TAN."} (nothing changed)
POST <base>/__mock/s/run-1/api/cash-account/confirm-tan/ tan_id=482910&tan=123456
→ {"status": true}
References and codes never appear in the mock server's own logs. The session's request log keeps request bodies as sent (only the login password is masked).