Error Handling
The Bilanc Metrics API returns standard HTTP status codes to indicate success or failure of an API request.HTTP Status Codes
Status Code | Description |
---|---|
200 OK | Request successful |
400 Bad Request | Invalid request parameters |
401 Unauthorized | Authentication failed |
403 Forbidden | Insufficient permissions |
404 Not Found | Requested resource not found |
422 Unprocessable Entity | Request validation failed |
429 Too Many Requests | Rate limit exceeded |
500 Internal Server Error | Server-side error |
Error Response Format
Error responses include a detail message explaining the issue:Common Error Scenarios
Authentication Errors
- The authentication token is missing
- The authentication token is invalid
- The authentication token has expired
Invalid Parameters
- Required parameters are missing
- Parameters have invalid values
- Parameters have invalid formats
Resource Not Found
- The requested metric type doesn’t exist
- The specified resource ID doesn’t exist
Server Errors
- The server encounters an unexpected condition
- A dependency service is unavailable
Handling Errors in Your Applications
JavaScript Example
Python Example
Best Practices for Error Handling
- Always check status codes: Don’t assume that a request will succeed.
- Implement retry logic: For transient errors (429, 500, etc.), implement a backoff strategy.
- Log detailed error information: Include request details and response information for debugging.
- Provide user-friendly error messages: Translate API errors into actionable information for users.
- Handle validation errors gracefully: Parse the detailed validation error messages to help users fix their inputs.
- Monitor error rates: Set up monitoring to track API errors and patterns.
- Contact support for persistent issues: For recurring errors, contact Bilanc support with detailed information about the problem.