Ir al contenido

SDK de JavaScript

Ventana de terminal
npm install @chaski/sdk
import { Chaski, ChaskiError } from '@chaski/sdk';
const chaski = new Chaski(process.env.CHASKI_API_KEY!);
const invoice = await chaski.invoices.create(body, { idempotencyKey: `pedido-${order.id}` });
const pdf = await chaski.invoices.pdf(invoice.id); // Uint8Array
for await (const inv of chaski.invoices.listAll({ status: 'authorized' })) {
console.log(inv.number);
}
  • Sin dependencias. Usa fetch y Web Crypto.
  • Reintentos ante errores de red, 429 (respetando Retry-After) y 5xx, con la misma clave de idempotencia. Configurable con maxRetries y timeoutMs.
  • Tipos generados del contrato OpenAPI: Invoice, CreditNote, CreateInvoiceRequest, etc.
  • Errores como ChaskiError, con status, code, field y raw.
  • Webhooks con verifyWebhook(rawBody, signatureHeader, secret). Ver Webhooks.
Recurso Métodos
invoices create, get, list, listAll, xml, pdf, void, resend, emails
creditNotes create, get, list, listAll, xml, pdf, resend, emails
debitNotes create, get, list, listAll, xml, pdf, resend, emails
withholdings create, get, list, listAll, xml, pdf, resend, emails
deliveryGuides create, get, list, listAll, xml, pdf, resend, emails
purchaseSettlements create, get, list, listAll, xml, pdf, resend, emails
issuers create, get, list, update, createEmissionPoint, updateEmissionPoint
certificates upload, list
brandingProfiles create, get, list, update, delete, logo
emailDomains create, get, list, verify, delete
exports create, get, list, download
webhookEndpoints create, list, delete, deliveries
events list, listAll
usage get