@qontoctl/core
v2.0.5
Published
Core library for Qonto API integration
Maintainers
Readme
@qontoctl/core
Core library for Qonto API integration — HTTP client, authentication, configuration, and typed service functions.
Part of the QontoCtl project.
Installation
npm install @qontoctl/coreUsage
import { resolveConfig, buildApiKeyAuthorization, HttpClient, getOrganization } from "@qontoctl/core";
// Resolve configuration from file or environment
const { config, endpoint } = await resolveConfig();
// Build authorization headers
const authorization = buildApiKeyAuthorization(config.apiKey);
// Create an HTTP client
const client = new HttpClient({ baseUrl: endpoint, authorization });
// Fetch organization details
const org = await getOrganization(client);API
Configuration
resolveConfig(options?): Promise<ConfigResult>— resolve credentials from config files and environment variablesloadConfigFile(path)— load a YAML configuration filevalidateConfig(config)— validate configuration structureapplyEnvOverlay(config, prefix?)— overlay environment variable overridesisValidProfileName(name)— check if a profile name is validsaveOAuthTokens(path, tokens)— save OAuth tokens to a config filesaveOAuthClientCredentials(path, credentials)— save OAuth client credentials to a config fileclearOAuthTokens(path)— remove OAuth tokens from a config fileConfigError— error thrown on configuration validation failures or missing credentials
Authentication
buildApiKeyAuthorization(credentials)— build authorization headers from API key credentialsbuildOAuthAuthorization(tokens)— build authorization headers from OAuth tokensgenerateCodeVerifier()— generate a PKCE code verifiergenerateCodeChallenge(verifier)— generate a PKCE code challenge from a verifierexchangeCode(params)— exchange an authorization code for tokensrefreshAccessToken(params)— refresh an expired access tokenrevokeToken(params)— revoke an OAuth tokenAuthError— error thrown when credentials are missing or invalid
HTTP Client
HttpClient— HTTP client for the Qonto API with rate-limit handlingQontoApiError— typed error for Qonto API error responsesQontoRateLimitError— error for rate-limit (HTTP 429) responsesQontoScaRequiredError— error for SCA-required (HTTP 428) responsesQontoScaNotEnrolledError— error for HTTP 428 withcode: "sca_not_enrolled"(distinct fromsca_required)
SCA (Strong Customer Authentication)
getScaSession(client, scaId)— retrieve an SCA session by IDpollScaSession(client, scaId, options?)— poll an SCA session until completionexecuteWithSca(client, operation, options?)— execute an API call with SCA handling. Theoperationcallback receives anExecuteWithScaContextcarrying a stableidempotencyKey(shared across the initial 428 attempt and the post-SCA retry) and an optionalscaSessionToken(set on retry); callers MUST forwardcontext.idempotencyKeyto the underlying request so both wire attempts emit the sameX-Qonto-Idempotency-Key. Supplyoptions.idempotencyKeyto pin the value (e.g. when the user passes--idempotency-key); otherwise a UUID is generated once and reused.mockScaDecision(client, scaId, decision)— mock an SCA decision (sandbox only)ScaDeniedError— error when SCA is denied by the userScaTimeoutError— error when SCA polling times out
Constants
API_BASE_URL— production API base URL (https://thirdparty.qonto.com)SANDBOX_BASE_URL— sandbox API base URL (https://thirdparty-sandbox.staging.qonto.co)CONFIG_DIR— default config directory path (~/.qontoctl)OAUTH_AUTH_URL/OAUTH_AUTH_SANDBOX_URL— OAuth authorization endpointsOAUTH_TOKEN_URL/OAUTH_TOKEN_SANDBOX_URL— OAuth token endpointsOAUTH_REVOKE_URL/OAUTH_REVOKE_SANDBOX_URL— OAuth revoke endpoints
Services
getOrganization(client)— fetch organization detailsgetBankAccount(client, id)— fetch a bank account by IDcreateBankAccount(client, params)— create a new bank accountupdateBankAccount(client, id, params)— update a bank accountcloseBankAccount(client, id)— close a bank accountgetIbanCertificate(client, id)— download IBAN certificate PDFresolveDefaultBankAccount(client)— resolve the default bank accountgetTransaction(client, id)— fetch a transaction by IDbuildTransactionQueryParams(params)— build query parameters for transaction listinggetBeneficiary(client, id)— fetch a beneficiary by IDcreateBeneficiary(client, params)— create a SEPA beneficiaryupdateBeneficiary(client, id, params)— update a beneficiarytrustBeneficiaries(client, ids)— trust beneficiariesuntrustBeneficiaries(client, ids)— untrust beneficiariesbuildBeneficiaryQueryParams(params)— build query parameters for beneficiary listinggetTransfer(client, id)— fetch a transfer by IDcreateTransfer(client, params)— create a SEPA transfercancelTransfer(client, id)— cancel a pending transfergetTransferProof(client, id)— download transfer proof PDFverifyPayee(client, params)— verify a payee (VoP)bulkVerifyPayee(client, entries)— bulk verify payeesbuildTransferQueryParams(params)— build query parameters for transfer listingcreateInternalTransfer(client, params)— create an internal transfergetBulkTransfer(client, id)— fetch a bulk transfer by IDgetRecurringTransfer(client, id)— fetch a recurring transfer by IDgetClientInvoice(client, id)— fetch a client invoice by IDcreateClientInvoice(client, params)— create a draft client invoiceupdateClientInvoice(client, id, params)— update a draft client invoicedeleteClientInvoice(client, id)— delete a draft client invoicefinalizeClientInvoice(client, id)— finalize a client invoicesendClientInvoice(client, id)— send a client invoice via emailmarkClientInvoicePaid(client, id)— mark a client invoice as paidunmarkClientInvoicePaid(client, id)— unmark paid statuscancelClientInvoice(client, id)— cancel a finalized client invoiceuploadClientInvoiceFile(client, id, file)— upload a file to a client invoicegetClientInvoiceUpload(client, id, uploadId)— get upload detailsbuildClientInvoiceQueryParams(params)— build query parameters for client invoice listinggetSupplierInvoice(client, id)— fetch a supplier invoice by IDbulkCreateSupplierInvoices(client, entries)— bulk create supplier invoicesbuildSupplierInvoiceQueryParams(params)— build query parameters for supplier invoice listinguploadAttachment(client, file)— upload an attachmentgetAttachment(client, id)— fetch attachment detailslistTransactionAttachments(client, transactionId)— list transaction attachmentsaddTransactionAttachment(client, transactionId, attachmentId)— add attachment to transactionremoveAllTransactionAttachments(client, transactionId)— remove all transaction attachmentsremoveTransactionAttachment(client, transactionId, attachmentId)— remove specific attachmentgetEInvoicingSettings(client)— fetch e-invoicing settings
Types
Configuration: QontoctlConfig, ApiKeyCredentials, OAuthCredentials, ConfigResult, ResolveOptions, LoadResult, ValidationResult, TokenUpdate
Auth: OAuthTokens, Authorization
HTTP: HttpClientOptions, HttpClientLogger, QueryParams, QueryParamValue, QontoApiErrorEntry
SCA: ScaSession, ScaSessionStatus, ScaMethod, PollScaSessionOptions, ExecuteWithScaCallbacks, ExecuteWithScaOptions
API: Organization, BankAccount, PaginationMeta, Transaction, TransactionLabel, ListTransactionsParams, Statement, StatementFile, Label, Membership
Beneficiaries: Beneficiary, ListBeneficiariesParams, CreateBeneficiaryParams, UpdateBeneficiaryParams
Transfers: Transfer, ListTransfersParams, CreateTransferParams, VopEntry, VopResult, InternalTransfer, CreateInternalTransferParams, BulkTransfer, BulkTransferResult, BulkTransferResultError, RecurringTransfer
Clients: Client, ClientAddress
Invoicing: ClientInvoice, ClientInvoiceAmount, ClientInvoiceDiscount, ClientInvoiceItem, ClientInvoiceAddress, ClientInvoiceClient, ClientInvoiceUpload, ListClientInvoicesParams, SupplierInvoice, SupplierInvoiceAmount, ListSupplierInvoicesParams, BulkCreateSupplierInvoiceEntry, BulkCreateSupplierInvoiceError, BulkCreateSupplierInvoicesResult, CreditNote, CreditNoteAmount, CreditNoteClient, CreditNoteItem
Other: Quote, QuoteAddress, QuoteAmount, QuoteClient, QuoteDiscount, QuoteItem, Request, RequestFlashCard, RequestVirtualCard, RequestTransfer, RequestMultiTransfer, EInvoicingSettings, Attachment, CreateBankAccountParams, UpdateBankAccountParams
Configuration Resolution
resolveConfig resolves the configuration file in this order (highest precedence first):
options.configFile(programmatic — equivalent to the CLI--config <path>flag)QONTOCTL_CONFIG_FILEenvironment variable~/.qontoctl/{profile}.yaml(whenoptions.profileis set)~/.qontoctl.yaml(home default)
There is no current-working-directory walk-up (removed in v2.0.0 — see CHANGELOG migration note). For repo-local configs, set QONTOCTL_CONFIG_FILE="$PWD/.qontoctl.yaml" (e.g. via direnv).
After the file is loaded, QONTOCTL_* environment variables overlay individual fields (or QONTOCTL_{PROFILE}_* with profile prefix). QONTOCTL_REFRESH_TOKEN is no longer read (refresh tokens rotate, so env-overlay can't persist correctly); QONTOCTL_ACCESS_TOKEN is honored as a one-shot bearer with read-only / discard-after-use semantics (no proactive refresh, no disk persist).
Auth-method precedence between the two configured methods is controlled by config.auth.preference — one of api-key, api-key-first, oauth, oauth-first (default).
Requirements
- Node.js >= 24
License
AGPL-3.0-only — For commercial licensing, contact the maintainer.
