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
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Required. Your API key |
organizationId | string | — | Required for webhooks, apiKeys, users, invitations, roles |
options.baseUrl | string | Auto-detected | Override the base URL |
options.timeout | number | 30000 | Request timeout in milliseconds |
options.retry.maxAttempts | number | 3 | Max retries for 5xx errors |
options.retry.baseDelay | number | 1000 | Base delay between retries in ms |
options.headers | object | {} | Additional headers on every request |
Environment auto-detection
The base URL is automatically determined from your key prefix:
| Key prefix | Base 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:
| Deprecated | Replacement |
|---|---|
baseUrl | options.baseUrl |
timeout | options.timeout |
maxRetries | options.retry.maxAttempts |
retryBaseDelay | options.retry.baseDelay |
Last updated on