Skip to main content

Error Responses

All API errors follow a standard JSON format returned by the API gateway error-handling middleware.

Error Format

{
"error": "NOT_FOUND",
"code": "NOT_FOUND",
"message": "The requested resource was not found",
"details": {},
"request_id": "req-abc123-def456",
"timestamp": "2026-02-19T15:30:00Z"
}
FieldTypeDescription
errorstringMachine-readable error code
codestringError code (same as error)
messagestringHuman-readable description
detailsobjectAdditional context (optional, may contain field-level errors)
request_idstringUnique request identifier for debugging
timestampstringISO 8601 timestamp

HTTP Status Codes

StatusCodeDescription
400BAD_REQUESTMalformed request body or parameters
400VALIDATION_ERRORRequest validation failed
400INVALID_JSONJSON parsing error
401UNAUTHORIZEDMissing or invalid JWT token
401INVALID_TOKENToken is malformed
401TOKEN_EXPIREDJWT token has expired
401INVALID_CREDENTIALSWrong email/password
403FORBIDDENUser lacks required permissions
404NOT_FOUNDResource does not exist
405METHOD_NOT_ALLOWEDHTTP method not supported
409CONFLICTResource already exists
413CONTENT_TOO_LARGERequest body exceeds size limit
429TOO_MANY_REQUESTSRate limit exceeded
500INTERNAL_SERVER_ERRORUnexpected server error
502BAD_GATEWAYUpstream service unavailable
503SERVICE_UNAVAILABLEService temporarily unavailable
504TIMEOUTRequest timed out

Business Logic Errors

Some operations return domain-specific error codes:

CodeDescription
INSUFFICIENT_FUNDSPayment amount exceeds available balance
ORDER_NOT_CANCELABLEOrder has already been completed
TABLE_OCCUPIEDTable is already in use
MENU_ITEM_UNAVAILABLEItem is 86'd (out of stock)
DUPLICATE_ENTRYRecord with same key already exists
RESOURCE_LOCKEDResource is locked by another operation

Validation Errors

When a request fails validation, the details field contains field-level errors:

{
"error": "VALIDATION_ERROR",
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": {
"email": "must be a valid email address",
"password": "must be at least 8 characters"
},
"request_id": "req-abc123",
"timestamp": "2026-02-19T15:30:00Z"
}

Rate Limiting

When rate-limited (HTTP 429), the response includes retry headers:

Retry-After: 1
X-RateLimit-Limit: 80
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1708358400

The default rate limit is 80 requests per second per IP address.

Handling Errors

import requests

response = requests.post(
"https://dev.api.olympuscloud.ai/v1/commerce/orders",
headers={"Authorization": f"Bearer {token}"},
json=order_data,
)

if response.status_code == 200:
order = response.json()
elif response.status_code == 401:
# Token expired — refresh and retry
new_token = refresh_token(refresh)
# retry...
elif response.status_code == 429:
# Rate limited — wait and retry
retry_after = int(response.headers.get("Retry-After", 1))
time.sleep(retry_after)
# retry...
else:
error = response.json()
print(f"Error {error['code']}: {error['message']}")
print(f"Request ID: {error['request_id']}")