Overview
Contazen uses conventional HTTP response codes to indicate the success or failure of an API request.Range | Meaning |
---|---|
2xx | Success - Request completed successfully |
4xx | Client Error - Invalid request parameters |
5xx | Server Error - Something went wrong on our end |
Error Response Format
All error responses follow a consistent structure:Error Types
Authentication Errors
Authentication Errors
Type:
Example:
authentication_error
These errors occur when there’s a problem with your API key.Code | Status | Description |
---|---|---|
missing_api_key | 401 | No Authorization header provided |
invalid_api_key | 401 | API key doesn’t exist or is invalid |
expired_api_key | 401 | API key has expired |
ip_restricted | 401 | Request from unauthorized IP |
insufficient_permissions | 403 | API key lacks required permissions |
Validation Errors
Validation Errors
Type:
Example with field-specific errors:
validation_error
These errors occur when request parameters fail validation.Code | Status | Description |
---|---|---|
invalid_request | 400 | General validation failure |
missing_required_field | 400 | Required field not provided |
invalid_field_value | 400 | Field value doesn’t meet requirements |
invalid_format | 400 | Data format is incorrect |
Rate Limit Errors
Rate Limit Errors
Type:
Example:Check the response headers for rate limit information:
rate_limit_error
Returned when you exceed the allowed number of requests.Code | Status | Description |
---|---|---|
rate_limit_exceeded | 429 | Too many requests |
X-RateLimit-Limit
: Maximum requests allowedX-RateLimit-Remaining
: Requests remainingX-RateLimit-Reset
: Reset time (Unix timestamp)
Resource Errors
Resource Errors
Type:
Example:
resource_error
These errors relate to specific resources.Code | Status | Description |
---|---|---|
resource_not_found | 404 | Requested resource doesn’t exist |
resource_already_exists | 409 | Resource with same identifier exists |
resource_locked | 423 | Resource is locked for editing |
Server Errors
Server Errors
Type:
Example:
api_error
These indicate problems on our servers.Code | Status | Description |
---|---|---|
internal_server_error | 500 | Unexpected server error |
service_unavailable | 503 | Service temporarily unavailable |
Handling Errors
Best Practices
1
Always check the response status
Don’t assume a request succeeded. Check the HTTP status code and
success
field.2
Log error details
Store the full error response, especially the
request_id
for debugging.3
Handle specific error types
Implement different handling for different error types.
4
Implement retry logic
For 5xx errors and rate limits, implement exponential backoff.
Example Error Handling
Common Error Scenarios
Invalid CUI Format
Duplicate Invoice Number
Missing Required Fields
Invalid Date Format
e-Factura Not Configured
Invoice Already Sent to SPV
Cannot Delete Used Product
Getting Help
If you encounter an error you can’t resolve:- Check the error message and code - They provide specific information about what went wrong
- Review the API documentation - Ensure you’re using the correct parameters
- Include the request ID - Found in error responses for server errors
- Contact support - Email contact@contazen.ro with details