Back to Builder

Mock API Builder Guide

Build a working REST API in your browser. Define endpoints, return realistic data and lists, add delays and pagination, then share the live URL or export it to Postman, Mockoon, or json-server.

Quick Start

1

Add an endpoint

Click Add Endpoint and choose an HTTP method and path. For example: GET /users or POST /users/:id.
2

Configure the response

Set the status code, content type, and response body. Use template variables like {{faker.person.fullName}} for dynamic data.
3

Call it

The toolbar shows a live base URL. Add your endpoint path and send a real request from your app, the terminal, or the built-in docs. Click Share to copy a link to the whole setup.

That is the whole loop. A GET /users endpoint returning a Faker name responds like this:

$ curl https://webtoolz.dev/api/mock-api/<your-config>/users

{ "id": "a1b2c3d4-...", "name": "Jane Doe" }

Want a head start? Open the builder with no endpoints and pick a template. Each one is a working example you can call right away and edit.

Creating Endpoints

Each endpoint has an HTTP method and a path. Supported methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.

Paths start with / and can include path parameters prefixed with ::

/users
/users/:id
/projects/:projectId/tasks/:taskId

Path parameter values are available in your response body via {{params.id}}, {{params.projectId}}, etc.

Endpoints can be reordered by dragging, and removed with the delete button. You can have multiple endpoints with the same path but different methods.

Response Configuration

Each response has the following settings:

  • Status Code: any standard HTTP status (200, 201, 400, 404, 500, and so on)
  • Content Type: JSON, plain text, HTML, or XML
  • Custom Headers: key-value pairs sent with every response
  • Body: the response body, with template variables for dynamic values

Example JSON response body:

{
  "id": "{{uuid}}",
  "name": "{{faker.person.fullName}}",
  "email": "{{faker.internet.email}}",
  "createdAt": "{{now}}"
}

Template Variables

Template variables are placeholders in your response body wrapped in double curly braces. They are replaced with dynamic values when a request is made.

VariableDescriptionExample
{{params.id}}Path parameter value/users/:id → "42"
{{query.page}}Query string parameter?page=2 → "2"
{{headers.authorization}}Request header value"Bearer token123"
{{body.name}}Request body field (JSON){"name":"Jane"} → "Jane"
{{uuid}}Random UUID v4"a1b2c3d4-e5f6-..."
{{now}}Current ISO 8601 timestamp"2026-03-02T12:00:00.000Z"
{{timestamp}}Current Unix epoch (seconds)"1772236800"
{{faker.*}}Faker.js generated dataSee Faker Reference below

There are a few more for building lists: {{#repeat}}, {{index}}, {{oneOf}}, and {{int}}. See Lists and Repeats.

Faker Data Generation

Use {{faker.<method>}} to generate realistic fake data. Values are regenerated on every request. For numeric methods, pass a range: {{faker.number.int(1,100)}}.

Person

MethodExample Output
{{faker.person.fullName}}John Smith
{{faker.person.firstName}}John
{{faker.person.lastName}}Smith
{{faker.person.jobTitle}}Software Engineer
{{faker.person.bio}}Short bio text

Internet

MethodExample Output
{{faker.internet.email}}john@example.com
{{faker.internet.username}}john_doe42
{{faker.internet.url}}https://example.com
{{faker.internet.ip}}192.168.1.1
{{faker.internet.password}}aB3dEf9Gh

Number

MethodExample Output
{{faker.number.int(1,1000)}}427
{{faker.number.float(0,100)}}73.42

Lorem

MethodExample Output
{{faker.lorem.sentence}}Lorem ipsum dolor sit amet.
{{faker.lorem.paragraph}}A full paragraph...
{{faker.lorem.word}}consequatur

Image

MethodExample Output
{{faker.image.avatar}}https://avatars.githubusercontent.com/...
{{faker.image.url}}https://picsum.photos/...

Location

MethodExample Output
{{faker.location.city}}San Francisco
{{faker.location.country}}United States
{{faker.location.zipCode}}94102
{{faker.location.streetAddress}}123 Main St
{{faker.location.latitude}}37.7749
{{faker.location.longitude}}-122.4194

Commerce

MethodExample Output
{{faker.commerce.price}}29.99
{{faker.commerce.productName}}Ergonomic Chair
{{faker.commerce.productDescription}}A comfortable chair...

Company

MethodExample Output
{{faker.company.name}}Acme Corp
{{faker.company.catchPhrase}}Innovative solutions

Date

MethodExample Output
{{faker.date.past}}2024-03-15T...
{{faker.date.future}}2027-08-22T...
{{faker.date.recent}}2026-02-28T...

Phone

MethodExample Output
{{faker.phone.number}}+1-555-123-4567

Finance

MethodExample Output
{{faker.finance.amount}}542.32
{{faker.finance.currency}}USD
{{faker.finance.bitcoinAddress}}3J98t1Wp...

Datatype

MethodExample Output
{{faker.datatype.boolean}}true
{{faker.datatype.uuid}}a1b2c3d4-...

String

MethodExample Output
{{faker.string.uuid}}a1b2c3d4-...
{{faker.string.alphanumeric}}abc123

Other

MethodExample Output
{{faker.animal.type}}dog
{{faker.color.human}}blue
{{faker.food.dish}}Spaghetti
{{faker.music.genre}}Rock
{{faker.science.chemicalElement}}Hydrogen

Lists and Repeats

To return a list, wrap part of the body in {{#repeat N}} and {{/repeat}}. The block renders N times, and Faker generates fresh values on each pass. Put the block between the array brackets and the helper adds the commas for you:

[
  {{#repeat 5}}
  {
    "id": {{index1}},
    "name": "{{faker.person.fullName}}",
    "email": "{{faker.internet.email}}"
  }
  {{/repeat}}
]

This returns an array of five users, each with its own data.

Inside a repeat you can use:

  • {{index}} for the position, starting at 0 (or {{index1}} to start at 1)
  • {{oneOf 'active' 'pending'}} to pick one option at random
  • {{int 1 100}} for a random whole number in a range

The count can be a number, a range like {{#repeat 5 20}} (a random size between 5 and 20), or a query value like {{#repeat query.limit}}. Repeats can nest, so an item can hold its own list.

Watch out: do not add your own commas between items. The block joins them, so an extra comma would break the JSON.

Response Modes

Default (Single Response)

Each endpoint returns one response every time. This is the default mode when you add a single response to an endpoint.

Sequence Mode

Add multiple responses and assign each a sequence order. Each request returns the next response in the sequence, cycling back to the first after the last.

Use case: Test retry logic by returning a 500 error on the first call and a 200 success on the second.

Response 1 (order 0): 200 OK  → {"status": "success"}
Response 2 (order 1): 500    → {"error": "Internal Server Error"}

Request #1 → 200 OK
Request #2 → 500 Internal Server Error
Request #3 → 200 OK  (cycles back)

Conditional Mode

Add conditions to responses to match requests by query parameters, headers, or body content. Condition values support regex patterns. The first matching condition wins; unmatched requests fall through to the response with no condition.

Use case: Return different user lists based on a status query parameter.

Response 1: condition query.status = "^active$"
  → {"data": [...active users...]}

Response 2: no condition (fallback)
  → {"data": [...all users...]}

Response Delay

Set a delay in milliseconds on any response to mimic a slow network. It is useful for testing loading spinners, timeouts, and retry logic. The field sits next to the content type in the response editor.

Delays are capped at 10 seconds. The response is held for that long and then sent as usual.

Collections

Turn on Collection for a JSON response whose body is an array, and the endpoint answers query parameters the way json-server does. No extra setup, and it pairs well with a {{#repeat}} block that builds the rows.

GET /users?_page=2&_limit=10        page through results
GET /users?_sort=name&_order=desc   sort by a field
GET /users?role=admin               filter by an exact value
GET /users?age_gte=18               operators: _gte _lte _ne _like
GET /users?q=jane                   search across the whole item

The response includes an X-Total-Count header with the total before paging, and a Link header with first, prev, next, and last page URLs.

Watch out: collection mode only applies when the body is a JSON array. A single object is returned as-is.

Import and Export

Import: paste an OpenAPI 3.x or Swagger 2.0 document (JSON or YAML), or a config you exported here, and the builder generates endpoints with Faker placeholders so they return fresh data. Replace your current setup or add to it.

Export from the toolbar in the format that fits where you are headed:

  • Config (JSON): this builder's own format, re-importable here later
  • OpenAPI spec: for Swagger UI and code generators
  • Postman collection: a ready-to-send collection
  • Mockoon environment: to run locally in Mockoon
  • json-server db.json: seed data for a local json-server

Sharing and Docs

Sharing: Click Share in the toolbar to copy the builder URL. The whole configuration is compressed into the URL, with no account or database. Anyone with the link can open and edit the mock API.

Base API URL: The toolbar shows the live API base URL. Append any endpoint path to make real HTTP requests. For example, if you defined GET /users, you can curl the base URL + /users.

Interactive Docs: Click Docs in the toolbar to open a Swagger-style documentation page for your mock API. It shows all endpoints, their methods, expected parameters, and response examples. Use the Test Request button to send live requests directly from the docs page.

Inherited a Mock URL?

If someone handed you a webtoolz mock API URL (even just the endpoint your app calls), you can open it in the builder to see and edit every route. The whole configuration lives in the URL, so there's nothing else to track down.

Paste it. On the builder with no endpoints, paste any mock URL (endpoint, docs, or builder link) into Have a mock API URL? and press open.

Or swap the path. The encoded segment is the same across every URL, so change /api/mock-api/ to /json/mock-api/ (and drop any request path after the encoded part) to open the builder, or to /json/mock-api/docs/ to read the docs:

Endpoint you have:
https://webtoolz.dev/api/mock-api/~a1b2c3d4e5f6g7h8/users

Open in the builder (swap the prefix, drop the path):
https://webtoolz.dev/json/mock-api/~a1b2c3d4e5f6g7h8

Read the docs:
https://webtoolz.dev/json/mock-api/docs/~a1b2c3d4e5f6g7h8

Or open it in a browser. Visiting the endpoint root shows an overview page with Open in Builder, View Docs, and OpenAPI spec links. Inspecting any response also works: the endpoint sends Link, X-Mock-Builder, and X-Mock-Docs headers pointing back here.

A short ~id link must still be resolvable (it was saved when the mock was shared); a longer link carries the entire config inline and always opens, even offline.

Templates

Templates are the quickest way to see a feature in action. Open the builder with no endpoints, pick one, and read how it is built. Between them they cover everything on this page: REST CRUD shows repeat blocks, a collection, a delay, and create/update/delete; Auth Endpoints shows a conditional login and a sequence that expires; and Health Check is the minimal case.

REST CRUD

A list that pages, filters, and sorts; a delayed lookup; and create, update, delete

GET/usersGET/users/:idPOST/usersPUT/users/:idDELETE/users/:id

Health Check

A single status endpoint with the current time

GET/health

Auth Endpoints

A conditional login, a refresh that expires on the second call, and logout

POST/auth/loginPOST/auth/refreshPOST/auth/logout

Frequently Asked Questions

Do I need to install anything to use the Mock API Builder?

No. The Mock API Builder runs entirely in your browser. There is nothing to install, no sign-up required, and no server to configure.

How do I share my mock API with others?

Click the Docs button in the toolbar to generate an interactive documentation page for your API. Share the docs URL with your team — they can explore endpoints, view response examples, and send test requests directly from the page.

What is a template variable?

Template variables are placeholders like {{faker.person.fullName}} or {{params.id}} that get replaced with dynamic values each time a request is made. They let you generate realistic, context-aware responses.

Can I return different responses based on the request?

Yes. Use Conditional mode to match requests by query parameters, headers, or body content. Each condition maps to a different response, with a fallback for unmatched requests.

How does sequence mode work?

In Sequence mode, each successive request returns the next response in the list. After the last response, it cycles back to the first. This is useful for testing retry logic or simulating intermittent errors.

Does CORS work with mock API responses?

Yes. All mock API responses include CORS headers automatically, so you can call them from any origin including localhost during development.

Can AI agents use the Mock API Builder programmatically?

Yes. AI agents can construct configuration URLs programmatically using the wire format, or use the interactive documentation page to explore and test endpoints.

How do I return a list of items?

Wrap part of the response body in {{#repeat N}} and {{/repeat}}. The block renders N times and Faker generates fresh values each time. Use {{index}} or {{index1}} for a running number. Put the block between the array brackets and it adds the commas for you.

Can I add a delay to a response?

Yes. Set a delay in milliseconds on any response to simulate a slow network. It is capped at 10 seconds and is handy for testing loading states and timeouts.

Does pagination work?

Turn on Collection for a JSON array response and the endpoint answers json-server style queries: _page and _limit for paging, _sort and _order for sorting, field filters with _gte/_lte/_ne/_like, and q for search. It returns an X-Total-Count header with the total before paging.

Can I import an existing OpenAPI or Swagger spec?

Yes. Paste an OpenAPI 3.x or Swagger 2.0 document as JSON or YAML and the builder generates endpoints with Faker placeholders. You can replace your current setup or add the imported endpoints to it.

Can I run this mock somewhere else?

Export from the toolbar as a Postman collection, a Mockoon environment, a json-server db.json, an OpenAPI spec, or this builder's own re-importable config.