Skip to main content

Authentication

The Smartbills SDK uses OAuth2 bearer tokens for authentication. Every request includes the token in the Authorization 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 optional RequestOptions parameter that overrides the client defaults for that single request:

RequestOptions

Request cancellation

Pass an AbortSignal to cancel long-running requests:

Credential provider pattern

For advanced scenarios such as automatic token refresh, implement the CredentialProvider 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-After header value
  • 5xx Server Errors: retries with exponential back-off
  • Network errors (connection reset, timeout), retries with exponential back-off
Retries stop after maxRetries attempts. Non-retryable errors (400, 401, 403, 404) are thrown immediately.