Error Handling
Understand API error responses and implement robust error handling in your integrations.
Error Response Format
When a request fails, the API returns a structured error response:
{
"success": false,
"error": {
"code": "PRODUCT_NOT_FOUND",
"message": "Product with ID 999 was not found",
"details": "The specified product does not exist or belongs to another organization"
},
"timestamp": "2024-12-25T12:00:00Z"
}
| Field | Type | Description |
|---|---|---|
success |
boolean | Always false for error responses |
error.code |
string | Machine-readable error code for programmatic handling |
error.message |
string | Human-readable error message |
error.details |
string | Additional context (may be null) |
HTTP Status Codes
| Status | Meaning | When It Occurs |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource successfully created |
| 400 | Bad Request | Invalid request format or parameters |
| 401 | Unauthorized | Missing, invalid, or expired authentication |
| 404 | Not Found | Resource does not exist |
| 500 | Internal Server Error | Unexpected server-side error |
Error Codes Reference
This table provides a quick reference of all error codes used across the API:
| Code | HTTP Status | Description |
|---|---|---|
INVALID_CREDENTIALS |
401 | Email or password is incorrect |
TOKEN_EXPIRED |
401 | JWT token has expired, refresh or re-login required |
INVALID_TOKEN |
401 | JWT token is missing or malformed |
UNAUTHORIZED |
401 | No valid authentication provided |
ACCOUNT_LOCKED |
401 | Account locked after too many failed attempts |
FORBIDDEN |
403 | User lacks permission for this action |
NOT_FOUND |
404 | Generic resource does not exist |
PRODUCT_NOT_FOUND |
404 | Product with specified ID does not exist |
PROJECT_NOT_FOUND |
404 | Project with specified ID does not exist |
ROOM_NOT_FOUND |
404 | Room with specified ID does not exist |
VENDOR_NOT_FOUND |
404 | Vendor with specified ID does not exist |
CUSTOMER_NOT_FOUND |
404 | Customer with specified ID does not exist |
BUNDLE_NOT_FOUND |
404 | Bundle with specified ID does not exist |
TEMPLATE_NOT_FOUND |
404 | Proposal template with specified ID does not exist |
LINE_ITEM_NOT_FOUND |
404 | Line item with specified ID does not exist |
INVOICE_NOT_FOUND |
404 | Invoice with specified ID does not exist |
SCHEMATICS_NOT_FOUND |
404 | Schematics with specified ID does not exist |
DRAWING_NOT_FOUND |
404 | Drawing with specified ID does not exist |
VALIDATION_ERROR |
400 | Request data failed validation (check details for specific fields) |
INVALID_DATA |
400 | Request body is malformed or missing required fields |
INVALID_TENANT |
400 | User is not assigned to any organization |
DUPLICATE_ENTRY |
409 | Resource with same identifier already exists |
INVOICE_GENERATION_FAILED |
400 | Could not generate invoice (no rooms or project not found) |
EMBEDDINGS_NOT_READY |
400 | Product embeddings must be generated before semantic search |
INSUFFICIENT_CREDITS |
402 | Not enough AI credits for this operation |
RATE_LIMITED |
429 | Too many requests, slow down |
SERVICE_UNAVAILABLE |
503 | External service (AI, vendor API) is unavailable |
CREATE_FAILED |
500 | Failed to create resource |
UPDATE_FAILED |
500 | Failed to update resource |
DELETE_FAILED |
500 | Failed to delete resource |
INTERNAL_ERROR |
500 | Unexpected server error |
Authentication Errors (401)
| Code | Description | Resolution |
|---|---|---|
INVALID_CREDENTIALS |
Email or password is incorrect | Verify login credentials |
INVALID_TOKEN |
JWT token is missing, malformed, or expired | Obtain a new token via login or refresh |
ACCOUNT_LOCKED |
Account locked after failed login attempts | Wait for lockout to expire or contact support |
Validation Errors (400)
| Code | Description | Resolution |
|---|---|---|
VALIDATION_ERROR |
Request body contains invalid data | Check required fields and data formats |
INVALID_TENANT |
User is not assigned to an organization | Contact administrator to assign tenant |
Resource Errors (404)
| Code | Description |
|---|---|
PRODUCT_NOT_FOUND |
Product with specified ID does not exist |
PROJECT_NOT_FOUND |
Project with specified ID does not exist |
ROOM_NOT_FOUND |
Room with specified ID does not exist |
VENDOR_NOT_FOUND |
Vendor with specified ID does not exist |
Server Errors (500)
| Code | Description | Resolution |
|---|---|---|
CREATE_FAILED |
Failed to create resource | Retry request or contact support |
UPDATE_FAILED |
Failed to update resource | Retry request or contact support |
DELETE_FAILED |
Failed to delete resource | Retry request or contact support |
INTERNAL_ERROR |
Unexpected server error | Retry with exponential backoff |
Best Practices
Error Handling
- Always check the
successfield before processing response data - Use error codes (not messages) for programmatic error handling
- Log error responses for debugging, including the timestamp
- Display user-friendly messages based on error codes
Token Management
- Store tokens securely (never in localStorage for sensitive apps)
- Set a timer to refresh tokens 2-3 minutes before expiration
- Handle
INVALID_TOKENby redirecting to login
Retry Logic
- Implement exponential backoff for 500 errors
- Do not retry 400/401/404 errors automatically
- Set a maximum retry count (3-5 attempts)
Need Help?
If you encounter persistent errors, contact support with the error code, timestamp, and request details for faster resolution.
