Skip to main content

Overview

The Smartbills API uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success, 4xx indicate client errors, and 5xx indicate server errors.

HTTP Status Codes

Error Response Format

All errors follow a consistent JSON structure:

Error Fields

Error Codes

Authentication Errors

Permission Errors

Validation Errors

Resource Errors

Rate Limit Errors

Server Errors

Handling Errors

Basic Error Handling

Detailed Error Handling

Validation Errors

Validation errors include detailed information about which fields failed validation:

Handling Validation Errors

Retry Logic

Implement retry logic for transient errors:

Debugging

Request IDs

Every error response includes a requestId that you can use to debug issues:
When contacting support, include the requestId to help us investigate:

Logging

Log errors with sufficient context:

Common Error Scenarios

Invalid API Key

Solution: Verify your API key is correct and hasn’t been revoked.

Insufficient Permissions

Solution: Check your API key’s scopes or generate a new key with appropriate permissions.

Resource Not Found

Solution: Verify the resource ID is correct and you have access to it.

Rate Limit Exceeded

Solution: Implement exponential backoff or upgrade your plan. See Rate Limits.

Best Practices

1. Always Check Response Status

2. Implement Proper Error Handling

Don’t ignore errors - handle them appropriately:

3. Use Type-Specific Error Handlers

Handle different error types differently:

4. Log Errors for Debugging

Include sufficient context:

5. Display User-Friendly Messages

Don’t show raw API errors to users:

Next Steps

Rate Limits

Handle rate limiting

Authentication

Learn about authentication

API Reference

Explore all endpoints

Webhooks

Set up webhooks