Overview
The High IQ API uses structured error responses with machine-readable codes and human-readable messages. Every error follows the same envelope format, making client-side error handling consistent and predictable.Error Response Format
All errors returnsuccess: false with a structured error object:
Error Fields
The
error.stack field is only included in non-production environments. In production, stack traces are stripped to avoid leaking internal implementation details.Error Codes
Client Errors (4xx)
Resource-Specific Errors (4xx)
Server Errors (5xx)
Common Error Examples
Not Found
Validation Error
When a request body fails Zod schema validation, the API returns aVALIDATION_ERROR with the full list of validation issues in the details field.
Bad Request
Rate Limit Exceeded
Database Error
In non-production environments, database errors include the underlying error for debugging. In production, they return a generic message.- Production
- Development
CommonErrors Helper
The API uses aCommonErrors helper object to generate consistent error responses throughout the codebase. These are the pre-built error factories:
Custom ApiError Class
For route handlers that need to throw errors, the API provides a customApiError class:
ApiError instances and formats them into the standard error response envelope.
