Node.js SDK
Typed client for the Corebill API with automatic pagination, safe retries and webhook verification.
Installation
Works with ESM and CommonJS (require('@corebill/sdk')) on Node.js 18 or newer. Each API key belongs to one company; corebill.account.retrieve() tells you which.
Resources
| Property | Methods |
|---|---|
customers | list, listAutoPaginate, create, retrieve, update, del |
quotes | list, listAutoPaginate, create, retrieve, update, del, send, approve, reject, convertToInvoice |
invoices | list, listAutoPaginate, create, retrieve, update, del, send, recordPayment, refund, cancel, markUncollectible |
items | list, listAutoPaginate, create, retrieve, update, del |
expenses | list, listAutoPaginate, create, retrieve, update, del |
vendors / expenseCategories | list, create (vendors) |
projects | list, create, retrieve, update, del, timeSummary, plus projects.tasks and projects.timeEntries |
companies | list, retrieve |
account | retrieve (company, organization and permission of the key) |
events | list, retrieve, plus the event types and test events |
webhooks | constructEvent, generateTestHeader |
Optional modules have their own resources, available while the module is on (otherwise the API answers 403 module_disabled, thrown as CorebillPermissionError):
| Property | Module | Guide |
|---|---|---|
products, productCategories, productBrands | Products | Products |
warehouses, stock (with stock.movements, stock.reasons, stock.adjustments, stock.transfers) | Inventory | Inventory |
purchaseOrders, bills | Purchases | Purchases |
cashRegisters, cashSessions, cashMovements | Cash | Cash |
posSales | Point of sale | Point of Sale |
workOrders | Work orders | Work Orders |
Pagination
Retries and Idempotency
Network errors, timeouts, 429 and 5xx responses are retried (2 times by default, honoring Retry-After). Every POST carries an Idempotency-Key, generated automatically, so a retry never creates a duplicate. Pass { idempotencyKey } as the last argument to dedupe across processes.
Verifying Webhooks
Errors
API errors throw typed classes: CorebillAuthenticationError, CorebillPermissionError, CorebillInvalidRequestError (with param), CorebillNotFoundError, CorebillRateLimitError and CorebillConnectionError. All extend CorebillAPIError with status, type and code.