API
Errors
Error response format and codes.
Response shape
All errors return JSON with this structure:
{
"code": "DEAL_NOT_FOUND",
"message": "Deal abc-123 not found",
"meta": {}
}| Field | Type | Description |
|---|---|---|
code | string | Machine-readable error code |
message | string | Human-readable description |
meta | object? | Optional additional context (e.g. field names for validation errors) |
Error codes
| Code | HTTP Status | Description |
|---|---|---|
DEAL_NOT_FOUND | 404 | The requested deal does not exist |
UNAUTHORIZED | 401 | Missing or invalid authentication |
FORBIDDEN | 403 | Authenticated but not allowed |
INTERNAL_ERROR | 500 | Unexpected server error |
Error registry
Errors are defined in apps/api/src/errors/errors.ts as a typed registry organized by domain:
import { errors } from "../errors";
// In a handler:
throw errors.deals.notFound(id);
throw errors.auth.unauthorized();New error codes are added to the registry as the API grows.