Endpoints and paths
An endpoint is a method and a path that your mock server answers, such as GET /users/:id. This page covers creating endpoints, the path patterns, how Mock Studio picks an endpoint when several fit, and organising the list.
Create an endpoint
In the side panel, select + beside Endpoints.
In Add an endpoint, choose Blank endpoint, or pick a template.
Set the method and the path at the top of the editor.
Give it an Endpoint name you will recognise in the list and the Live log.
A blank endpoint is GET /hello with one 200 response. Templates are ordinary endpoints with useful settings already filled in. You can change everything afterwards.
| Template | What you get |
|---|---|
| Simple JSON response | GET /something returning a fixed JSON object |
| Resource by id | GET /items/:id that sends the id back |
| Create (POST) endpoint | POST /items returning 201 with a new id |
| Protected endpoint | GET /me that requires an Authorization header |
| Flaky service (random errors) | GET /flaky returning 500 about 20% of the time |
| Slow endpoint | GET /slow with a 2 second delay |
| Retry sequence | GET /retry that fails twice, then succeeds |
| List with pagination | GET /items returning a list and the requested page |
Methods
The method dropdown offers ANY, GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS.
- ANY answers every method on that path. Use it when the method does not matter, or pair it with a rule on HTTP method to answer methods differently. See Conditional rules.
- HEAD requests have a fallback. If no endpoint answers
HEADfor a path, Mock Studio uses the matching GET endpoint and sends its status and headers with no body, which is how HTTP definesHEAD. - OPTIONS endpoints are only reached when CORS is turned off for the project. While Enable CORS is on, the server answers every
OPTIONSrequest itself with204. See Auth, CORS and project settings.
Path templates
Type the path in the field beside the method. A leading / is added if you leave it out. Select the ? button in the field to open Path patterns, a short reminder of the syntax.
| Pattern | Matches | Value available as |
|---|---|---|
/users | Exactly /users | |
/users/:id | One segment in place of :id, such as /users/42 | {{params.id}} |
/files/* | Any single segment, such as /files/report | {{params.wildcard0}} |
/assets/** | Everything after it, such as /assets/img/logo.png | {{params.rest}} |
A segment is the text between two slashes.
Details worth knowing
- Query strings are ignored when matching.
/users?page=2is answered by the/usersendpoint. Read the query with{{query.page}}or a rule on Query param. - A trailing slash does not matter.
/users/and/usersare the same path. - Fixed text is case-sensitive.
/Usersdoes not match/users. - A parameter or a single wildcard needs exactly one segment.
/users/:iddoes not match/usersor/users/42/orders. - A wildcard is a whole segment.
/files/*.pngis not a pattern; the*must stand alone between slashes. - The double wildcard can match nothing.
/assets/**also matches/assets, with an emptyrest. - The double wildcard ends the template. Anything you write after
**is ignored. - Several wildcards are numbered. In
/a/*/b/*the values arewildcard0andwildcard1. - Captured values are URL-decoded.
/users/ana%20ligivesana li.
You can name a parameter anything: /orders/:orderId/items/:itemId gives {{params.orderId}} and {{params.itemId}}.
Which endpoint wins
When a request arrives, Mock Studio looks at every enabled endpoint whose method fits (the same method, or ANY) and whose path template fits. If more than one fits, the most specific path wins.
Each segment of a template scores points:
| Segment | Points |
|---|---|
Fixed text, such as users | 3 |
:name or * | 1 |
** | 0 |
The endpoint with the highest total answers. On a tie, the endpoint that is higher in the list answers.
Example. A project has these three GET endpoints, and a client calls GET /users/me:
| Endpoint path | Fits /users/me? | Score |
|---|---|---|
/users/me | Yes | 3 + 3 = 6 |
/users/:id | Yes | 3 + 1 = 4 |
/users/** | Yes | 3 + 0 = 3 |
/users/me answers. A call to /users/42 is answered by /users/:id, and /users/42/orders by /users/**.
Good to know
The method is not part of the score. An ANY endpoint and a GET endpoint with the same path tie, so the one higher in the list answers GET requests. Two endpoints with the same method and the same path shape, such as /users/:id and /users/:userId, also tie, and the lower one is never reached.
When nothing matches
If no enabled endpoint fits, the server forwards the request to a real API when a proxy address is set (see Proxy and record). Otherwise it answers 404 with this body:
{
"error": "not_found",
"message": "No mock endpoint matched GET /user",
"hint": "Add this endpoint in Mock Studio, or enable proxy passthrough."
}The request shows in the Live section with a no match tag, which is the fastest way to spot a typo in a path.
Enable or disable an endpoint
Turn off the Enabled switch at the top right of the editor, or choose Disable from the endpoint's ⋯ menu in the list. The server then ignores the endpoint as if it did not exist, and the list marks it as disabled. Nothing is deleted. Turn the switch back on, or choose Enable, to bring it back.
Disabling is useful for testing what your app does when a route is missing, or for keeping two versions of an endpoint and switching between them.
Duplicate, move and delete
Open the ⋯ menu on an endpoint in the list:
| Menu item | What it does |
|---|---|
| Disable / Enable | Stops or resumes answering, without deleting. |
| Move to folder… | Puts the endpoint in a folder. |
| Duplicate | Adds a copy named with (copy) directly below, with the same method, path and responses. |
| Delete | Removes the endpoint. |
WARNING
Delete removes the endpoint at once, with no confirmation and no undo. If you might want it back, use Disable instead, or export the project first.
A duplicate has the same method and path as the original, so the original, being higher in the list, keeps answering. Change the copy's path or method, or disable the original.
Folders
Folders group endpoints in the list. They do not change any URL.

- 1Folder — Click to collapse or expand it. The number on the right counts its endpoints.
- 2Folder actions — Rename folder and Ungroup.
- 3Breadcrumbs — The folder appears in the path at the top.
Open the ⋯ menu on an endpoint and choose Move to folder….
In Folder, type a folder name, or select one of the existing folders shown below the field.
Use
/to nest folders:Users/Adminputs the endpoint in Admin inside Users. Leave the field empty to move the endpoint back to the top level.Select Move.
A folder exists as long as an endpoint is in it. To change a folder, open its ⋯ menu:
- Rename folder changes the name for every endpoint inside.
- Ungroup removes the folder and keeps its endpoints, moving them up one level.
Search
Type in Search endpoints to filter the list. It matches endpoint names, paths, folders and methods, so post shows every POST endpoint and orders shows everything with that word in its name, path or folder.
Check yourself
Question 1 of 6
A project has these three enabled GET endpoints. A client calls GET /orders/7/items. Which one answers?
/orders/:id
/orders/**
/orders/:id/items