API Reference

Complete reference for the MockJSON API. Create and manage mock JSON endpoints programmatically with RESTful endpoints.

1Authentication

All API requests require authentication via API Key. Include your API key in the X-API-Key header.

X-API-Key: YOUR_API_KEY

You can create and manage API keys from your Dashboard. Free tier users get 1 API key, Pro users get unlimited keys with granular permissions.

2Endpoints (Bins)

A "bin" is a mock JSON endpoint with persistent storage. Each bin has a unique ID and can store any valid JSON payload.

Create a Bin

POST /api/bins

curl -X POST https://mockjsonapi.com/api/bins \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "users", "data": {"users": [{"id": 1, "name": "John"}]}, "isPublic": true, "expiresIn": 30}'

Request Body

FieldTypeRequiredDescription
namestringYesUnique name for the bin (max 120 chars)
dataobjectYesJSON payload to store
isPublicbooleanNoWhether the bin is publicly accessible (default: true). Private bins require Pro/Enterprise.
expiresInnumberNoDays until bin expires (1-365). Overrides tier retention.

Response

{
  "success": true,
  "bin": {
    "id": "abc123def456",
    "name": "users",
    "userId": "user_123",
    "isPublic": true,
    "sizeBytes": 1024,
    "version": 1,
    "accessCount": 0,
    "expiresAt": "2026-02-14T10:30:00Z",
    "createdAt": "2026-01-15T10:30:00Z",
    "updatedAt": "2026-01-15T10:30:00Z"
  },
  "url": "https://mockjsonapi.com/bin/abc123def456"
}

List Your Bins

GET /api/bins

Supports pagination via page and pageSize query parameters. Filter by name (or q), public (true/false), and scope (admin only: "all").

Get a Bin

GET /api/bin/:id

Returns the bin data and metadata. Public bins can be accessed without authentication. Response includes { data, meta: { bin, rateLimit } } with CORS headers, ETag, and rate limit headers.

Update a Bin

PUT /api/bin/:id

Updates the bin data and creates a new version. Returns the updated bin with new version info.

Request Body

API Key Auth (x-api-key header): Only data field allowed. name and isPublic are locked.

Session Auth (Dashboard): Supports data, name, isPublic. Visibility-only toggles (no data change) are allowed.

curl -X PUT https://mockjsonapi.com/api/bin/abc123def456 \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": {"users": [{"id": 1, "name": "John"}, {"id": 2, "name": "Jane"}]}}'

Delete a Bin

DELETE /api/bin/:id

Permanently deletes the bin and all its versions. This action cannot be undone.

API Key Auth: DELETE blocked on public bins. Use private bins for write access via API.

curl -X DELETE https://mockjsonapi.com/api/bin/abc123def456 \
  -H "X-API-Key: YOUR_API_KEY"

Bin Versions

GET /api/bin/:id/versions

Lists all versions of a bin (max 20). Each update creates a new version for rollback capability. Returns { versions: [...], total } with current version marked.

POST /api/bin/:id/versions — Rollback to a specific version:

curl -X POST https://mockjsonapi.com/api/bin/abc123def456/versions \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"versionId": "v1"}'

3Public Access (No Auth)

Public bins can be accessed without an API key via the public URL:

GET https://mockjsonapi.com/bin/abc123def456

This is ideal for frontend prototyping — just share the URL with your team or use it directly in your application during development.

Response includes CORS headers (Access-Control-Allow-Origin: *), caching (Cache-Control: public, max-age=30), and ETag.

4Rate Limits

Daily request limits per tier (reset at midnight UTC). Rate limit headers included in all responses.

TierRequests/DayMax BinsMax Size/BinPrivate BinsVersion HistoryRetention
Free1,00010100 KBNoCurrent only (1)7 days
Pro100,0001,0005 MBYes100 versionsUnlimited
EnterpriseUnlimited100,00020 MBYes1,000 versionsUnlimited

Rate limit headers included in all responses: X-RateLimit-Limit,X-RateLimit-Remaining.

5Error Codes

All errors return { success: false, error: "message", meta?: { rateLimit: {...} } }.

HTTP StatusError MessageDescription
400"Name and data are required"Missing required fields in request body
400"Invalid JSON data"Request body is not valid JSON
400"Data is required"PUT request missing data field
400"Version ID is required"Rollback missing versionId
401"Unauthorized"Missing or invalid API key / session
401"Private bin: unauthorized"Accessing private bin without auth
403"Forbidden"Not owner / insufficient role
403"Private bins require Pro or Enterprise"Free tier creating private bin
403"PUT/DELETE not allowed on public bins via API"API key auth on public bin write
404"Bin not found"Bin ID doesn't exist
404"Version not found"Rollback to non-existent version
410"Bin expired"Bin past its expiresAt date
413"Payload too large for X tier"Exceeds maxBytesPerBin for tier
429"Rate limit exceeded"Daily quota exhausted (includes meta.rateLimit)
500"Failed to fetch bin data" / "Failed to create bin" / etc.Server/internal error

Ready to integrate?

Get your API key from the dashboard and start building mock endpoints in seconds.

Go to Dashboard
=