Start Here

  • Introduction
  • Quick Start

Core Features

  • Project Settings
  • Schema Builder
  • Dynamic Data
  • Conditional Logic
  • Relationships
  • Consuming your API

Integrations

  • n8n Workflows
  • Make (Integromat)
  • AI Tools

Consuming your API

Learn how to integrate your Mock66 endpoints into your applications securely and reliably.

Endpoint Structure

Mock66 assigns a unique subdomain to every project. This keeps your endpoints clean and isolated.

https://project-id.mock66.dev/path
  • project-id
    Your unique project identifier (e.g., proj_abc123). You can find this in your Project Settings.
  • /path
    The specific route you defined in the dashboard (e.g., /users or /products/123).

Authentication

By default, endpoints in a project are either public (read-only) or protected depending on your project settings. To secure your access, enable API Key authentication. When enabled, every request to your endpoints must include the x-mock66-api-key header or query parameter with a valid API Key.

Method 1: Header (Recommended)

Cleaner and more secure. Keeps your key out of browser history.

bash
curl -X GET "https://proj_abc123.mock66.dev/users" \
  -H "x-mock66-api-key: your_api_key_here"
Method 2: Query Parameter

Useful for quick browser testing or simple GET requests.

text
https://proj_abc123.mock66.dev/users?x-mock66-api-key=your_api_key_here

CORS & Frontend Usage

Mock66 is built for frontend development. We automatically handle CORS (Cross-Origin Resource Sharing) headers so you can fetch data directly from localhost or your deployed app without configuration.

React / Fetch Example

javascript
// Example: Fetching users in a React component
useEffect(() => {
  const fetchUsers = async () => {
    try {
      const res = await fetch('https://proj_abc123.mock66.dev/users', {
        headers: {
          'x-mock66-api-key': process.env.NEXT_PUBLIC_MOCK_API_KEY
        }
      });
      const data = await res.json();
      setUsers(data);
    } catch (err) {
      console.error(err);
    }
  };
  
  fetchUsers();
}, []);

Error Codes

While standard requests return 200 OK (or whatever status you configured), you might encounter system errors:

StatusMeaning
401 UnauthorizedMissing or invalid API Key. Check your x-mock66-api-key header.
404 Not FoundThe endpoint path does not exist in your project configuration.
429 Too Many RequestsYou have exceeded your plan's request limits.
500 Internal ErrorSomething went wrong with the data generator (e.g., Infinite recursion depth exceeded).

On this page

  • Endpoint Structure
  • Authentication
  • CORS & Frontend
  • Error Codes
Previous
Relationships
Next
n8n Workflows