Skip to Content

Configuration

Constructor options

const client = new EInvoice({ apiKey: 'sk_test_your_key_here', organizationId: '9f8e7d6c-5b4a-3210-fedc-ba9876543210', options: { baseUrl: 'https://custom.api.com', timeout: 60000, retry: { maxAttempts: 5, baseDelay: 2000, }, headers: { 'X-Custom-Header': 'value', }, }, });

Options reference

OptionTypeDefaultDescription
apiKeystringRequired. Your API key
organizationIdstringRequired for webhooks, apiKeys, users, invitations, roles
options.baseUrlstringAuto-detectedOverride the base URL
options.timeoutnumber30000Request timeout in milliseconds
options.retry.maxAttemptsnumber3Max retries for 5xx errors
options.retry.baseDelaynumber1000Base delay between retries in ms
options.headersobject{}Additional headers on every request

Environment auto-detection

The base URL is automatically determined from your key prefix:

Key prefixBase URL
sk_test_*https://gateway.useyona.com (sandbox behavior)
sk_live_*https://gateway.useyona.com (production behavior)

Override with options.baseUrl if needed.

Per-request options

Override timeout, add headers, or pass an abort signal per request:

const controller = new AbortController(); const invoices = await client.invoices.list( { status: 'draft', page: 1 }, { timeout: 5000, signal: controller.signal, headers: { 'X-Request-Id': 'req_123' }, }, );

Response format

Every SDK method returns ApiResponse<T>:

interface ApiResponse<T> { meta: { statusCode: number; success: boolean; message: string; errors: Array<{ field?: string; message: string; code?: string }>; timestamp: string; pagination?: { total: number; page: number; pageSize: number; totalPages: number; hasNext: boolean; hasPrevious: boolean; }; }; data: T; }

Access data via .data:

const response = await client.invoices.create({ /* ... */ }); const invoice = response.data;

Deprecated options

The following top-level options still work but will be removed in a future major version. Migrate to the options object:

DeprecatedReplacement
baseUrloptions.baseUrl
timeoutoptions.timeout
maxRetriesoptions.retry.maxAttempts
retryBaseDelayoptions.retry.baseDelay
Last updated on