Mock APIs with Map Local
Response variants and conditions
One rule, several responses: success, wrong password, not found, slow network…
A rule can hold several responses. Each extra response has conditions. AegisCeptor checks them from top to bottom and sends the first one whose conditions match. If none match, it sends the default.
Add a response
- Open a rule in Map Local and click + Response.
- Give it a name, for example Wrong password, and set its status and body.
- Add one or more conditions (below).
- Choose All conditions match or Any condition matches.
Example: login with a wrong password
Rule: POST example.com/api/login, status 200, body with a token. Add a response:
- Name
- Wrong password
- Status
401- Body
{"error": "invalid_credentials"}- Condition
- Body ·
password· not equals ·demo1234
Now signing in as demo@example.com / demo1234 succeeds, and any other password gets the 401.
What a condition can check
| Source | Name / key | Example |
|---|---|---|
| Query param | parameter name | page equals 2 → empty list |
| Route parameter | name from the pattern (:id) | id equals 999 → 404 |
| Header | header name | Authorization does not exist → 401 |
| Cookie | cookie name | session exists |
| Body (JSON path / form field) | a field, dots for nesting: card.number, items.0.id | card.number equals 4000000000000002 → declined |
| Path | (no key) | path contains /v2/ |
| Method | (no key) | method equals DELETE |
Operators
- equals / not equals
- Exact text. A missing value counts as "not equals".
- contains
- Text anywhere in the value, ignoring case.
- regex
- A regular expression, for example
^u_\d+$. - exists / does not exist
- Only checks that the parameter, header, cookie or field is there.
The ! button next to a condition inverts it: it matches when the condition is not true.
All or any
All conditions match needs every condition. Any condition matches needs just one, which is handy for "error if the header says so or the URL has ?fail=1":
- Name
- Server error · status
500· Any condition matches - Condition 1
- Header ·
X-Demo-Scenario· equals ·error - Condition 2
- Query param ·
fail· exists
The default response
When no conditions match, the rule sends its base response (the fields at the top, shown as Base). Click ⚑ Set as default on any response to send that one instead. It applies right away, which makes it a one-click switch between states while you test a screen: success now, server error next, without editing anything.
Each response can have its own delay. A Slow network response with 3000 ms and a condition on a test header lets you try loading spinners on demand.