Skip to main content

Error Handling

The Blinksale API uses conventional HTTP response codes to indicate the success or failure of an API request. Here’s a guide to understanding and handling errors in the Blinksale API.

HTTP Status Codes

Error Response Format

All error responses from the API follow a consistent structure:
For validation errors (422 status code), the errors object will contain field-specific error messages:

Common Error Types

Authentication Errors

If your API token is invalid or expired, you’ll receive a 401 Unauthorized response:

Permission Errors

If you attempt to access or modify a resource you don’t have permission for, you’ll receive a 403 Forbidden response:

Resource Not Found

When requesting a resource that doesn’t exist, you’ll get a 404 Not Found response:

Validation Errors

If your request contains invalid data, you’ll receive a 422 Unprocessable Entity response with specific validation errors:

Rate Limiting Errors

If you exceed the API rate limits, you’ll receive a 429 Too Many Requests response:

Best Practices for Error Handling

When working with the Blinksale API, consider these best practices for handling errors:
  1. Check the HTTP status code first to determine the general category of the error.
  2. Parse the error message for more specific information about what went wrong.
  3. Handle validation errors by checking the errors object and addressing each field with issues.
  4. Implement exponential backoff for rate limiting errors to automatically retry after a waiting period.
  5. Log detailed error information in your application to help troubleshoot issues.
  6. Display user-friendly error messages to end-users rather than raw API error responses.

Debugging Tips

If you’re encountering errors when working with the API:
  1. Double-check your request parameters against the API documentation.
  2. Verify your authentication token is valid and properly formatted.
  3. Check organization access to ensure you have permission for the operation.
  4. Review your rate limit usage in the response headers.
  5. Contact support if you’re encountering unexpected server errors.