Skip to main content

Error Handling

The Bilanc Metrics API returns standard HTTP status codes to indicate success or failure of an API request.

HTTP Status Codes

Error Response Format

Error responses include a detail message explaining the issue:
For validation errors, the response includes more detailed information about the specific validation issues:

Common Error Scenarios

Authentication Errors

This error occurs when:
  • The authentication token is missing
  • The authentication token is invalid
  • The authentication token has expired

Invalid Parameters

This error occurs when:
  • Required parameters are missing
  • Parameters have invalid values
  • Parameters have invalid formats

Resource Not Found

This error occurs when:
  • The requested metric type doesn’t exist
  • The specified resource ID doesn’t exist

Server Errors

This error occurs when:
  • 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

  1. Always check status codes: Don’t assume that a request will succeed.
  2. Implement retry logic: For transient errors (429, 500, etc.), implement a backoff strategy.
  3. Log detailed error information: Include request details and response information for debugging.
  4. Provide user-friendly error messages: Translate API errors into actionable information for users.
  5. Handle validation errors gracefully: Parse the detailed validation error messages to help users fix their inputs.
  6. Monitor error rates: Set up monitoring to track API errors and patterns.
  7. Contact support for persistent issues: For recurring errors, contact Bilanc support with detailed information about the problem.