Authentication
The Smartbills SDK uses OAuth2 bearer tokens for authentication. Every request includes the token in theAuthorization header, a business ID in the x-tenant-id header, and a locale in the Accept-Language header.
Client initialization
Pass credentials when constructing the client:Configuration options
Updating credentials at runtime
You can update the token, business ID, or locale after initialization. This is useful when handling user sessions or switching between business contexts.Reading current values
Per-request overrides
Every service method accepts an optionalRequestOptions parameter that overrides the client defaults for that single request:
RequestOptions
Request cancellation
Pass anAbortSignal to cancel long-running requests:
Credential provider pattern
For advanced scenarios such as automatic token refresh, implement theCredentialProvider interface:
Custom credential provider
Multi-tenant usage
In multi-tenant applications, you typically create a single client instance and switch the business context per request:Retry behavior
The SDK automatically retries requests on transient errors:- 429 Too Many Requests: retries after the
Retry-Afterheader value - 5xx Server Errors: retries with exponential back-off
- Network errors (connection reset, timeout), retries with exponential back-off
maxRetries attempts. Non-retryable errors (400, 401, 403, 404) are thrown immediately.