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 with the SDK

The Smartbills SDKs provide typed error classes for structured error handling:

Validation Errors

Validation errors include detailed information about which fields failed:

Handling Validation Errors

Retry Logic

Implement retry logic with exponential backoff for transient errors:

Debugging with Request IDs

Every error response includes a requestId. Include this when contacting support:
When contacting support, include:
  • The requestId from the error response
  • The endpoint and HTTP method you called
  • The timestamp of the error
  • A description of what you expected to happen

Best Practices

Never assume a request succeeded. Always check the HTTP status code or catch exceptions from the SDK.
Handle different error types with appropriate actions: redirect to login for 401, show field errors for validation failures, retry for 429/5xx.
Log errors with sufficient context including the request ID, endpoint, and relevant parameters.
Do not show raw API error messages to end users. Map error codes to user-friendly messages in your application.
Implement exponential backoff for transient errors (429, 5xx). Do not retry client errors (4xx other than 429).

Rate Limits

Handle rate limiting

Authentication

Fix authentication errors

API Introduction

API overview

Webhooks

Set up webhooks