← All docs
Getting Started

Quick Start

Upload an OpenAPI spec and call your first mock endpoint in under 5 minutes.

What you'll build

By the end of this guide you'll have a live mock API endpoint you can call from anywhere — your browser, curl, a load testing tool, or a CI pipeline.


Prerequisites

  • An OpenAPI spec (version 3.x or Swagger 2.0). If you don't have one, the example below works.
  • A Mockra account — sign up free, no credit card required.

Step 1: Create a workspace

A workspace is a container for your schemas and mock configs. Each workspace gets a unique namespace — a short slug that appears in all your mock URLs.

  1. Sign in at dash.mockra.io
  2. Click New Workspace and give it a name (e.g. "My Project")
  3. Your namespace is generated automatically (e.g. sunny-fox-4a2b)

Your mock base URL will be:

https://mock.mockra.io/sunny-fox-4a2b/

Step 2: Upload an OpenAPI spec

You have three options for uploading a spec:

Option A — Paste a URL (easiest for public specs):

Enter any publicly accessible URL to a YAML or JSON OpenAPI file. Mockra fetches it and stores it.

Option B — Upload a file:

Drag and drop a .yaml, .yml, or .json file into the upload area.

Option C — Paste raw content:

Click "Paste spec" and enter the YAML or JSON directly.

Example spec

If you don't have a spec handy, paste this minimal one:

openapi: "3.0.0"
info:
  title: "Example API"
  version: "1.0.0"
paths:
  /users:
    get:
      summary: "List users"
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    name:
                      type: string
              example:
                - id: 1
                  name: "Alice"
                - id: 2
                  name: "Bob"
  /users/{id}:
    get:
      summary: "Get user"
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              example:
                id: 1
                name: "Alice"
                email: "alice@example.com"

After uploading, Mockra parses the spec and creates a mock config for every endpoint with an auto-generated default response.


Step 3: Call your mock endpoint

Once the upload completes, you'll see a list of endpoints. Click any endpoint to see its mock URL.

For the example spec above:

curl https://mock.mockra.io/sunny-fox-4a2b/users

Response:

[
  { "id": 1, "name": "Alice" },
  { "id": 2, "name": "Bob" }
]
curl https://mock.mockra.io/sunny-fox-4a2b/users/1

Response:

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com"
}

That's it — your mock API is live globally on Cloudflare's edge network.


Step 4: Customize a response

Every endpoint has an editable mock config. Click the pencil icon next to any endpoint in the dashboard to change:

  • Status code — e.g. return 404 or 503 instead of 200
  • Response body — any valid JSON or string
  • Response headers — custom headers like Content-Type or X-Request-Id
  • Latency — simulate a slow API with 100–5000ms delay (Pro+)

Changes take effect immediately — no redeployment needed.


Step 5: Use it in your tests

curl

curl -s https://mock.mockra.io/sunny-fox-4a2b/users | jq .

k6

import http from "k6/http";
import { check } from "k6";

export default function () {
  const res = http.get("https://mock.mockra.io/sunny-fox-4a2b/users");
  check(res, { "status 200": (r) => r.status === 200 });
}

fetch (JavaScript)

const res = await fetch("https://mock.mockra.io/sunny-fox-4a2b/users");
const users = await res.json();

What's next

Try Mockra free

5,000 requests/month, no credit card required. Upload an OpenAPI spec and get mock endpoints in under 60 seconds.

Start for free