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

    Complete Verification & Save

    Complete the Turnstile verification, then click "Save Mock Endpoint". 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.

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. Complete verification and click "Save Mock Endpoint"

✓ 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. If they do, 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.

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.

Document Your Endpoints

Keep a list of your endpoints and their purposes. Share URLs with team members for collaboration.

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.

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.