Error Codes

All errors follow a consistent envelope format. The HTTP status code indicates the error category, while the error.code field provides a machine-readable identifier you can match on in your code.

Error Response Format

Every error response has the same shape, regardless of HTTP status code.

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description of what went wrong.",
    "details": []  // Optional array. Present on validation errors.
  }
}
Field
error.code
Type
string
Description
Machine-readable error code. Stable across versions.
Field
error.message
Type
string
Description
Human-readable message. May change; do not match on this.
Field
error.details
Type
array
Description
Optional. Array of objects for validation errors.

400 Bad Request

The request body is not valid JSON, is empty, or is missing top-level required fields. This fires before schema validation, so it typically means the payload could not be parsed at all.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request body must be valid JSON. Check for trailing commas or unquoted keys."
  }
}

Common causes

  • Trailing comma in JSON body
  • Missing Content-Type: application/json header
  • Empty request body
  • Body sent as form-encoded instead of JSON

400 Bad Request — Schema Error

The schema definition contains invalid field types, references to undefined tables, or invalid count values.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": {
    "code": "SCHEMA_ERROR",
    "message": "Schema validation failed. Check field types, table references, and count values."
  }
}

400 Bad Request — Dependency Cycle

The schema contains circular foreign-key references between tables that cannot be resolved.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": {
    "code": "DEPENDENCY_CYCLE",
    "message": "Circular dependency detected between tables."
  }
}

401 Unauthorized

The API key is missing, malformed, expired, or revoked. Check that you are sending a valid key in the Authorization or x-api-key header.

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "API key is missing or invalid. Include a valid key in the Authorization header."
  }
}

Common causes

  • No Authorization or x-api-key header
  • Missing Bearer prefix in Authorization header
  • Key has been revoked from the dashboard
  • Using a key from a different MockHero account

403 Forbidden

Your API key is valid but your plan does not include the requested feature. Upgrade your plan to access the feature.

HTTP/1.1 403 Forbidden
Content-Type: application/json

{
  "error": {
    "code": "FEATURE_REQUIRES_UPGRADE",
    "message": "Your plan does not include access to the schema detection endpoint. Upgrade to Pro or above."
  }
}

Features that require Pro or Scale

  • Schema detection endpoint (POST /schema/detect)
  • CSV and SQL output formats
  • Seed parameter for reproducibility

404 Not Found

The requested resource does not exist. This typically means the ID in the URL path is invalid or the resource has been deleted.

HTTP/1.1 404 Not Found
Content-Type: application/json

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found. Check the ID and try again."
  }
}

413 Payload Too Large

The request body exceeds the maximum allowed size of 1 MB. This typically happens when sending very large schema definitions or long prompts.

HTTP/1.1 413 Payload Too Large
Content-Type: application/json

{
  "error": {
    "code": "PAYLOAD_TOO_LARGE",
    "message": "Request body exceeds the 1 MB limit. Reduce the number of table definitions or use a template instead."
  }
}

422 Unprocessable Entity

The JSON is well-formed but the content fails validation. This covers schema errors (invalid field types, missing required fields, circular references) and prompt conversion failures.

Schema Validation Error

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Schema validation failed. See details for specific issues.",
    "details": [
      {
        "field": "tables[0].fields[2].type",
        "message": "Unknown field type \"emial\"",
        "suggestion": "Did you mean \"email\"?"
      },
      {
        "field": "tables[1].fields[0].params.table",
        "message": "Referenced table \"users\" is not defined in the schema."
      }
    ]
  }
}

Prompt Conversion Error

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "error": {
    "code": "PROMPT_CONVERSION_FAILED",
    "message": "Could not convert prompt to a valid schema. Try being more specific about the tables and columns you need."
  }
}

429 Too Many Requests

You have exceeded your daily record limit or per-minute request limit. For per-minute limits, the response includes a Retry-After header indicating how many seconds to wait.

Per-Request Limit Exceeded

HTTP/1.1 429 Too Many Requests
Content-Type: application/json

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Per-request limit exceeded. Maximum 10,000 records per request for pro tier."
  }
}

Daily Limit Exceeded

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 2026-04-01T00:00:00.000Z

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Daily record limit exceeded. Your plan allows 1,000 records per day. Resets at 2026-04-01T00:00:00Z."
  }
}

Per-Minute Limit Exceeded

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 42

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Per-minute request limit exceeded. Your plan allows 10 requests per minute."
  }
}

Handling 429 responses

  • Read the Retry-After header and wait that many seconds before retrying.
  • Implement exponential backoff if you receive multiple 429s in a row.
  • Do not retry immediately in a tight loop. This may result in extended throttling.

500 Internal Server Error

An unexpected error occurred on the MockHero server. These are rare and are automatically reported to our engineering team. If the error persists, include the X-Request-Id header value when contacting support.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
X-Request-Id: req_8a3f2c1d7e9b

{
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "An unexpected error occurred. Our team has been notified. If this persists, contact support@mockhero.dev with request ID req_8a3f2c1d7e9b."
  }
}

When to retry

  • Wait 1-2 seconds and retry once. Most 500 errors are transient.
  • If the error persists after 3 retries, check the status page for ongoing incidents.
  • Contact support@mockhero.dev with the X-Request-Id value for investigation.

Quick Reference

Status
400
Code
VALIDATION_ERROR
Retryable
No
Action
Fix the JSON payload.
Status
400
Code
SCHEMA_ERROR
Retryable
No
Action
Fix field types, table refs, or counts.
Status
400
Code
DEPENDENCY_CYCLE
Retryable
No
Action
Remove circular table dependencies.
Status
401
Code
UNAUTHORIZED
Retryable
No
Action
Check your API key.
Status
403
Code
FEATURE_REQUIRES_UPGRADE
Retryable
No
Action
Upgrade your plan.
Status
404
Code
NOT_FOUND
Retryable
No
Action
Check the resource ID and try again.
Status
413
Code
PAYLOAD_TOO_LARGE
Retryable
No
Action
Reduce request body size.
Status
422
Code
VALIDATION_ERROR
Retryable
No
Action
Fix validation issues in details.
Status
429
Code
RATE_LIMIT_EXCEEDED
Retryable
Yes
Action
Wait for Retry-After seconds.
Status
500
Code
INTERNAL_ERROR
Retryable
Yes
Action
Retry after 1-2 seconds.