Relmock Guide

Use your API

Custom endpoints and mock login

Tables cover the usual CRUD routes. Custom endpoints cover the rest: POST /checkout, GET /stats, a job that is "running" twice and then "done". Mock login gives your app real sign-up and sign-in.

The Endpoints page: a POST /checkout endpoint with two responses, Paid and Card declined, a JSON template body, and Try it showing the answer
1 method and path · 2 responses, one per tab · 3 how a response is chosen · 4 try it before or after saving.

Create an endpoint

  1. Open EndpointsThe braces icon in the left rail. Click New endpoint, or start from a starter: a record from a table, a paginated list, login success or failure, echo, a job status sequence, a sometimes-failing endpoint.
  2. Set the method and pathUse {name} or :name for path parameters, like /orders/{id}/cancel, and a final * for the rest of the path. A custom endpoint on a table's path takes over that route.
  3. Write the responseStatus, body type, headers and an optional delay. The body is a template (below).
  4. Try itThe Try it panel previews unsaved changes as you type, or sends a real request. Save with Ctrl S.

Templates

Bodies and header values can use values from the request and your data:

{
  "order_id": {{ body.order_id | json }},
  "status": "paid",
  "receipt": "RCPT-{{ random_int(10000, 99999) }}",
  "customer": {{ record('users', body.user_id) | json }},
  "paid_at": "{{ now() }}"
}
In a templateMeaning
params, query, headers, bodyThe path parameters, query string, headers and JSON body of the request.
fake.email(), fake('price')Any data type of the field editor.
table('users'), record('users', id), count('users')Your project's records, read only.
userThe signed-in user, with mock login on.
uuid(), now(), today(), random_int(a, b), choice(list)Helpers.
| jsonWrites a value as JSON.

Press Ctrl Space in the editor for suggestions; Reference lists every helper. A template error answers 500 with the reason.

Several responses

An endpoint can have several responses. Those with conditions are checked first, in order, and the first that matches answers: for example, answer 402 when body.card equals a test card number. Otherwise the endpoint's mode picks one:

  • First match: always the first response without conditions.
  • In turn: the next one on each call, useful for polling (running, running, done).
  • Random: by weight, such as 9 successes to 1 failure.

Request validation can check the body against a JSON Schema and answer 422 with the errors.

Mock login

Turn on Settings › Mock login and pick your users table. Your API then has:

RouteAnswer
POST /auth/registerCreates a user and answers 201 with an access_token.
POST /auth/login{ "email", "password" } gives a token, or 401.
GET /auth/meThe signed-in user.
POST /auth/logout204; the token stops working.

Send the token as Authorization: Bearer <token>. Generated users sign in with the project's shared password (password123 unless you change it). Passwords never appear in answers or logs.

Per-user tables: in the same section, pick a table's owner field, like user_id for orders. Then each user sees and changes only their own records, new records get their id, and calls without a token answer 401.

Free plan
5 custom endpoints per project.