Relmock Guide

Use your API

Using your mock API

Your project's tables are a REST API at its mock URL. It behaves like a small real backend: writes are saved, foreign keys are checked, and errors come back as JSON with a reason.

Find the mock URL

The mock URL is on the Projects page and in the status bar at the bottom of every project page. It looks like https://app.relmock.com/mock/<token>. Anyone who has it can call the API; turn on API keys to limit that. Settings › Danger zone can give the project a new mock URL, which stops the old one working.

Routes

RequestAnswer
GET /ordersThe records, as an array (filters below).
GET /orders/3One record, or 404.
POST /ordersCreates a record and answers 201. Without an id, the next number (or a UUID) is used.
PUT /orders/3Replaces the record; fields you don't send are removed.
PATCH /orders/3Changes only the fields you send.
DELETE /orders/3204, applying the relations' delete rules.

Browser apps can call it from any origin, with or without credentials.

Filter, sort and page

ParameterExampleMeaning
field?status=paidEquals. ?field=null finds empty values.
_ne?status_ne=cancelledNot equal.
_gt, _gte, _lt, _lte?total_gte=100Greater or less than.
_like?name_like=proContains, in any case.
_sort, _order?_sort=total&_order=descSorting.
_page, _limit?_page=2&_limit=10Pages. The answer becomes { "data": [...], "total", "page", "limit" }.
_limit?_limit=5At most 5 records, still a plain array.
_start, _end?_start=0&_end=5A slice of the list.

A filter on a field the table doesn't have matches nothing, and the X-Mock-Warning header says so. To test slow or failing calls, see Network, latency and time.

Errors your app will see

StatusWhen
400The body isn't a JSON object.
401API keys are on and the key is missing or wrong, or a signed-in route has no valid token.
404No such record, table or route.
409The id already exists, or a delete is blocked by a relation.
422A field breaks a rule, or a foreign key points at nothing. The body lists each field and the reason.
429Too many requests. See limits.
{
  "error": "Unprocessable Entity",
  "message": "Validation failed: category must be one of \"books\", \"games\", ...",
  "errors": [{ "field": "category", "message": "must be one of \"books\", \"games\", ..." }]
}

Settings › Data and writes decides how strict writes are: refuse (the default), warn (saved, with the problems in a header) or off.

Protect it with an API key

In Settings › API keys, turn on Require an API key and create a key. The key is shown once; copy it then. Your app sends it in a header:

X-API-Key: mk_9f3b7c8a1e2d4f5...

Keys in the URL are not accepted, since URLs end up in logs. The dashboard's own Try it and Replay keep working without a key.

Share docs with your team

The public API reference for Shop API: the base URL, authentication, list parameters and every route grouped by table

Every project has an API reference page that needs no account: base URL, every route with parameters and examples, the models, code snippets (cURL, JavaScript, Python, Go) and a Try it button. Open it with Docs on the Tables page, and share it from Settings › Docs and sharing, where you can make it private, add a passcode, or make a new link.