Mock REST API Guide

Create free, instant REST API endpoints with custom responses, status codes, and advanced features. No signup required.

Getting Started

Creating a mock REST API endpoint takes less than 30 seconds. Follow these simple steps:

  1. 1

    Visit the Homepage

    Go to mockapi.dog and select the "REST API" tab.

  2. 2

    Set the Path and HTTP Method

    Type your resource path after the generated URL (for example /api/users), then select GET, POST, PUT, PATCH, or DELETE.

  3. 3

    Write Your JSON Response

    Pick a status code and enter the JSON the endpoint should return. The editor validates JSON as you type.

    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com"
    }
  4. 4

    Configure Delays and Error Simulation Settings (Optional)

    Add a response delay, a random error rate, or an error triggered by a request header.

  5. 5

    Save Your Endpoint

    Click "Save Mock Endpoint". A bot check runs in the background, and a checkbox appears only if it needs you to tick it. Your endpoint URL is automatically copied!

    https://abc123.mockapi.dog/api/users

Your endpoint is live immediately!

No deployment, no waiting. Start making requests right away from your app, tests, or tools like Postman and curl.

Core Features

HTTP Methods

Support for all standard HTTP methods to match your API design.

  • GET - Retrieve data
  • POST - Create resources
  • PUT - Full update
  • PATCH - Partial update
  • DELETE - Remove resources

Status Codes

Return any HTTP status code to test success, errors, and edge cases.

  • 200OK - Success
  • 201Created
  • 400Bad Request
  • 401Unauthorized
  • 500Server Error

JSON Responses

Return any valid JSON structure - from simple objects to complex nested data.

  • Objects and arrays
  • Nested structures
  • Arrays of objects
  • Real-time validation
  • Proper Content-Type

Advanced Features

Fine-tune your mock endpoints with powerful features for realistic testing scenarios.

Response Delays

Add a fixed delay of up to 10,000ms before the response is sent, to simulate slow networks or server processing time.

Use Cases:

  • Test loading states in UI
  • Simulate slow 3G/4G networks
  • Verify timeout handling
  • Check skeleton screens

Example Delays:

500ms - Fast2000ms - Normal5000ms - Slow

Error Simulation

Set a percentage of requests to return errors. Perfect for testing error handling and retry logic.

Use Cases:

  • Test error boundaries
  • Verify retry mechanisms
  • Check error messages
  • Validate fallback UI

Error Rate Examples:

10% errors50% errors100% errors

Error response body:

{
  "error": "Simulated error (10% error rate)",
  "triggeredBy": "random-error-rate"
}

Conditional Errors

Return an error only when a request carries a header with the exact value you set. Send the header when you want the error and leave it out otherwise.

Example Use Cases:

  • Auth failure:X-Test-Auth: expired returns 401 to test your login redirect
  • Not found:X-Test-Error: missing returns 404 to test empty states
  • Outage:X-Test-Error: down returns 503 to test your fallback UI

When a request matches the header, the header error is returned instead of the random error rate.

Error response body:

{
  "error": "Conditional error triggered by header X-Test-Error: down",
  "triggeredBy": "conditional-header-match"
}

TTL (Time to Live)

Endpoints belong to a code, the 6-character subdomain in your URL. When the code expires, it is deleted along with all of its endpoints. New codes expire after 1 month. After saving an endpoint, change this with the clock button next to the URL.

Available Options:

1 week1 month (default)3 monthsCustom (1-365 days)

Perfect for temporary tests or demos. No need to manually clean up.

Request Inspector

Watch the requests your endpoints receive as they arrive. Turn on the Logging switch in the Request Inspector panel below your saved endpoints.

  • The last 50 requests for the code, newest first
  • Method, path, status code, and response time
  • Headers, query parameters, and request body (bodies over 10KB are truncated)
  • Authorization and cookie headers shown as [redacted]

Logging is off by default and covers every endpoint under the code. Only requests that match a saved endpoint are captured, and they are kept for 7 days after the most recent one. Pause the live view or clear the list at any time.

Import & Export

Turn an existing API definition into mocks in one step, or download your mocks to share them or keep them next to your code. The Import and Export buttons are under "Save Mock Endpoint".

Import from OpenAPI or Postman

Paste or upload a file, preview the endpoints it contains, untick any you don't want, and import the rest into the current code at once.

Supported formats:

OpenAPI 3.x (JSON or YAML)Swagger 2.0 (JSON or YAML)Postman collection v2.0 / v2.1

How a file becomes mocks:

  • Each operation becomes one endpoint with the same method and path.
  • The response is the 200 response, else 201, else another 2xx. Its example is used, or one is generated from the schema.
  • Mocks match exact paths, so path parameters get an example value: /users/{id} becomes /users/42, or /users/1 when the file has no example.
  • A base path such as /v1 is left off. Point your client's base URL at your mock URL instead.
  • Postman requests use their first saved 2xx example response, and return {} if they have none.
  • HEAD, OPTIONS, and TRACE operations are skipped.

Up to 100 endpoints and 2 MB per file. An endpoint whose method and path already exist is skipped unless you turn on "Replace existing mocks with the same method and path".

Export to OpenAPI or Postman

Once a code has saved endpoints, Export downloads all of them as a file that points at your mock URL.

  • OpenAPI 3: every endpoint with its example response. Delays, error simulation, and LLM settings go in an x-mockapi-dog extension, so importing the file again restores them.
  • Postman collection v2.1: a request per endpoint with its response saved as an example, and a {{baseUrl}} variable set to your mock URL. Endpoint settings aren't included.

Settings in an exported OpenAPI file:

"/users/1": {
  "get": {
    "responses": { "200": { ... } },
    "x-mockapi-dog": {
      "delayMs": 500,
      "errorRate": 10,
      "errorStatusCode": 503
    }
  }
}

Export from the command line:

curl -o mocks.json \
  "https://api.mockapi.dog/api/mocks/export?code=abc123&format=openapi"

Use format=postman for a Postman collection.

Common Tasks

Create an Endpoint

  1. Open mockapi.dog on the "REST API" tab
  2. Add a path to the URL and select an HTTP method
  3. Enter your JSON response
  4. Configure optional settings
  5. Click "Save Mock Endpoint" (tick the verification checkbox if one appears)

✓ Your endpoint is now live!

Edit an Endpoint

  1. Find your endpoint in the "Saved Endpoints" list
  2. Click the pencil (Edit) button
  3. Change the method, response, status, or settings (the URL is locked while editing)
  4. Click "Update Endpoint"

✓ Changes are live immediately

Delete an Endpoint

  1. Locate the endpoint you want to remove
  2. Click the trash (Delete) button
  3. The endpoint is removed right away, without a confirmation prompt

This action cannot be undone

Test an Endpoint

Using curl:

curl https://abc123.mockapi.dog/api/users

Using JavaScript:

fetch('https://abc123.mockapi.dog/api/users')

Troubleshooting

Endpoint returns 404 Not Found

Solution: Check the URL, HTTP method, and path: all three must match what you saved. Paths match exactly, so /users/1 and /users/2 are separate endpoints. If they match, the code may have expired and been deleted along with its endpoints.

Invalid JSON error when creating endpoint

Solution: Validate your JSON using the built-in editor. Common issues: missing commas, unquoted keys, trailing commas, or unescaped quotes.

CORS errors in browser

Solution: All endpoints automatically include CORS headers. If you still see errors, check if you're using the correct URL and HTTP method.

Endpoint is too slow

Solution: Check if you've added a response delay in advanced settings. Remove or reduce the delay value if not needed.

Requests return 429 Too Many Requests

Solution: Each endpoint has a daily call limit. Once it is reached, calls return 429 with the limit and a resetAt time (midnight server time) in the body. Each IP address is also limited to 100 requests per minute across the service.

Request Inspector shows no requests

Solution: Logging is off by default. Turn on the Logging switch in the Request Inspector, then call the endpoint again. Requests to paths with no saved endpoint are not captured.

Import doesn't accept my file

Solution: Import reads OpenAPI 3.x, Swagger 2.0, and Postman v2 collections, as JSON or YAML. Files over 2 MB or with more than 100 endpoints are rejected, so split them first. References to other files aren't followed, so bundle the spec into a single file.

Tips & Best Practices

Use Realistic Data

Include realistic field names, data types, and structures that match your real API. This makes testing more valuable.

Test Edge Cases

Create endpoints for empty arrays, null values, and error scenarios. This helps catch bugs early.

Keep Your Mocks With Your Code

Export your endpoints as OpenAPI or a Postman collection and commit the file. Import it into a new code whenever you need the same mocks again.

Use Delays Strategically

Add small delays to test loading states. Use longer delays to verify timeout handling.

Version Your Responses

Create multiple endpoints for different API versions. This helps test backward compatibility.

Clean Up Unused Endpoints

Regularly delete endpoints you no longer need. Use TTL to auto-expire temporary endpoints.

Ready-to-Use Mock API Library

We provide pre-built mock APIs for common use cases. Click any category to explore ready-to-use endpoints that you can test immediately - no setup required.

Pro Tip: Browse the Full Library

Visit our Mock API Library to explore all pre-built endpoints with live examples, sample responses, and one-click testing.

Glossary

REST API

Representational State Transfer API - an architectural style for building web services using standard HTTP methods.

HTTP Methods

Standard request methods (GET, POST, PUT, PATCH, DELETE) that indicate the desired action for a resource.

Status Code

Three-digit code returned by server indicating the result of a request (200 OK, 404 Not Found, 500 Error, etc).

JSON

JavaScript Object Notation - a lightweight data format for structuring and exchanging data between client and server.

Endpoint

A specific URL where an API can be accessed. Each endpoint performs a specific function.

Mock API

A simulated API that returns predefined responses, used for testing and development without a real backend.

CORS

Cross-Origin Resource Sharing - a security feature that controls which domains can access your API from browsers.

TTL

Time To Live - how long a code and all of its endpoints exist before they are deleted automatically.

Error Rate

The percentage of requests that should return errors. Used to test error handling and retry logic.

Response Delay

Artificial wait time added before sending a response. Simulates slow networks or processing.

Code

The unique 6-character subdomain of your mock API (abc123 in abc123.mockapi.dog). Endpoints, expiry, and request logging all belong to a code.

Request Inspector

A live log of the requests a code's endpoints receive, including headers, query parameters, and body.

OpenAPI

A standard format for describing REST APIs, formerly called Swagger. MockAPI Dog can create mocks from an OpenAPI file and export mocks as one.

Postman Collection

A file of saved API requests from Postman, often with example responses. MockAPI Dog can import and export collections.

Ready to Create Your First REST API?

Start building free mock REST API endpoints in seconds. No signup required, no credit card needed. Perfect for testing, prototyping, and development.