Private mock servers with an API key
A mock server's URL has a random id, which is enough for a quick prototype. It stops being enough when the mock holds examples of an unreleased API, when the URL ends up in a public repository, or when a partner should use it and nobody else. A private mock answers only calls that carry its key.
Make it private
Open the collection's Mocks tab. When creating a mock, tick Private; for an existing mock, make it private there. The key is shown once, right then. Copy it into a secret store, not into a chat message.
Call it
curl -H "x-api-key: $MOCK_KEY" https://mock.requestarium.com/m_8f3k2x9q1z/users/42In a collection, keep the key in a secret environment variable and send it as a header. The easiest way is API key auth on the collection, with the key name x-api-key in a header and the value {{mockApiKey}}, so every request inherits it. On a single request it looks like this:
GET {{baseUrl}}/users/42
x-api-key: {{mockApiKey}}In a frontend, put it in the same config as the base URL, for the mock environment only.
Keep it out of the browser bundle, if you can
A key in a JavaScript bundle is readable by anyone who opens the page. For an internal prototype on a staging site behind a login, that's usually acceptable. For a public demo, call the mock from your own backend or a dev proxy instead, so the key stays on the server.
Rotate it
If the key leaks, press New key. The old key stops working at once; everyone using the mock needs the new one. That's another reason to keep the key in one config value or one environment variable, not copied into every request.
Delays
A mock can wait before it answers, up to 10 seconds. Use it to see loading states and timeouts in the app:
- 300 to 800 ms feels like a real API on a normal network.
- 3 to 5 seconds shows whether spinners and skeletons work.
- Longer than your client's timeout tests the error path.
Set the delay when you create the mock. On the Free plan a delay you set is ignored.
Errors
Errors come back as JSON, {"error": "...", "message": "..."}:
| Status | Why |
|---|---|
401 | Private mock, and x-api-key is missing or wrong |
404 | No such mock, no matching request, or no example (with that name or code) |
429 | Too many calls, see Retry-After |
403 | The example body is larger than your plan allows |
A 401 from the mock looks like a 401 from a real API. If your frontend shows "please sign in again" during development, check the key before you debug your auth code.
Limits
| Plan | Calls / month | Calls / minute / mock | Body | Private, delay |
|---|---|---|---|---|
| Free | 10,000 | 60 | 256 KB | no |
| Pro | 500,000 | 300 | 1 MB | yes |
| Team | 5,000,000 | 1,000 | 1 MB | yes |
| Enterprise | unlimited | 1,000 | 1 MB | yes |
Every call that reaches a mock counts toward the month, including 401s and 404s.