Error Codes

Reference guide for API error codes, troubleshooting, and best practices.

Error Response Format

When an API request fails, you'll receive a JSON response with an error object containing details about what went wrong. The HTTP status code indicates the general category of the error.

Error Response StructureJSON
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "email",
        "message": "Invalid email format"
      }
    ],
    "requestId": "req_abc123xyz"
  }
}

HTTP Status Codes

CodeStatusDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request parameters or body
401UnauthorizedMissing or invalid API key
403ForbiddenAPI key lacks required permissions
404Not FoundResource does not exist
409ConflictResource already exists or conflict in state
422Unprocessable EntityRequest understood but cannot be processed
429Too Many RequestsRate limit exceeded
500Internal ErrorServer error - contact support

Error Codes Reference

The error.code field provides a machine-readable error identifier.

Authentication Errors

CodeDescription
UNAUTHORIZEDNo API key provided
INVALID_API_KEYAPI key is invalid or revoked
FORBIDDENAPI key lacks permission for this action

Validation Errors

CodeDescription
VALIDATION_ERRORRequest body or parameters are invalid
MISSING_REQUIRED_FIELDA required field was not provided
INVALID_FORMATField value has incorrect format
OUT_OF_RANGEValue is outside allowed range

Resource Errors

CodeDescription
NOT_FOUNDRequested resource does not exist
ALREADY_EXISTSResource with this identifier already exists
CONFLICTAction conflicts with current resource state
DELETEDResource has been deleted

Rate Limit Errors

CodeDescription
RATE_LIMITEDToo many requests - slow down and retry

⚠️ Handling Rate Limits

When you receive a 429 error, check these response headers:

  • X-RateLimit-Limit - Total requests allowed per window
  • X-RateLimit-Remaining - Requests remaining in current window
  • X-RateLimit-Reset - Unix timestamp when the window resets
  • Retry-After - Seconds to wait before retrying
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Please retry after 30 seconds.",
    "retryAfter": 30
  }
}

💡 Error Handling Best Practices

  1. Always check the HTTP status code first - Use it to categorize the error type
  2. Parse the error.code for programmatic handling - Don't rely on message text
  3. Implement exponential backoff for retries - Start with 1s, double each retry, max 5 retries
  4. Log the requestId - Include it when contacting support for faster debugging
  5. Handle validation errors gracefully - Show field-level errors to users when possible

Example Error Responses

Validation Error (400)

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "email",
        "message": "Invalid email format",
        "value": "not-an-email"
      },
      {
        "field": "startDate",
        "message": "Start date must be in the future"
      }
    ],
    "requestId": "req_abc123xyz"
  }
}

Not Found Error (404)

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Event not found",
    "resource": "event",
    "identifier": "non-existent-slug",
    "requestId": "req_def456xyz"
  }
}

Server Error (500)

{
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "An unexpected error occurred. Please try again later.",
    "requestId": "req_ghi789xyz"
  }
}

🆘 Need Help?

If you're encountering persistent errors or unexpected behavior:

  • Include the requestId from the error response
  • Describe the expected vs actual behavior
  • Include the request method, URL, and (sanitized) body
  • Contact support@nookhive.com