Skip to content

Issue 🇨🇱 electronic tax documents with TypeScript.

invoice.ts
import { createDte, stampDte } from 'dte-sdk'
import { signDte, sendToSii } from 'dte-sdk'

const dte = createDte(invoice)
dte.totals.vat             // → 22800
dte.totals.total           // → 142800

const doc = stampDte(dte, caf)  // TED ✓
const signed = await signDte(doc, cert)
await sendToSii(signed, opts)  // → { trackId }

dte-sdk is a TypeScript toolkit for Chilean DTE as defined by the SII — build, stamp, sign, and send invoices, receipts, and credit notes from any runtime.

Document types

81

Dependencies

0

License

MIT

Typed end to end,
built for the SII;
ready for your billing flows

From line items to an accepted document — each function owns one step of the lifecycle, so you compose only what your flow needs.

By example

From line items to an accepted DTE

Nine composable functions across the whole lifecycle — typed documents, IVA-correct totals, the TED stamp, XMLDSig signing, SII upload and tracking, and PII-safe errors. Tab through to see them in context.

import { createDte } from 'dte-sdk'

const dte = createDte({
  type: 33,                // Factura electrónica
  folio: 1024,
  issuer,                  // { rut: '76.123.456-0', ... }
  receiver,                // { rut: '77.654.321-7', ... }
  items: [
    { name: 'Licencia anual', quantity: 1, unitPrice: 120000 },
  ],
})

dte.totals.net     // → 120000
dte.totals.vat     // → 22800
dte.totals.total   // → 142800

Live demo

Build a document — watch the totals

Pick a document type and a line item. Net, IVA, total, and the XML preview update live in your browser — no server, no account.

Try it — build a document

receiver RUT validtrue
totals.net$120.000
totals.exempt$0
totals.vat (19%)$22.800
totals.total$142.800

toXml() preview — unsigned, no TED

<DTE version="1.0">
  <Documento ID="F1024T33">
    <Encabezado>
      <IdDoc>
        <TipoDTE>33</TipoDTE>
        <Folio>1024</Folio>
        <FchEmis>2026-10-30</FchEmis>
      </IdDoc>
      <Emisor>
        <RUTEmisor>76123456-0</RUTEmisor>
        <RznSoc>Arrow Software SpA</RznSoc>
      </Emisor>
      <Receptor>
        <RUTRecep>77654321-7</RUTRecep>
      </Receptor>
      <Totales>
        <MntNeto>120000</MntNeto>
        <TasaIVA>19</TasaIVA>
        <IVA>22800</IVA>
        <MntTotal>142800</MntTotal>
      </Totales>
    </Encabezado>
    <Detalle>
      <NroLinDet>1</NroLinDet>
      <NmbItem>Licencia anual</NmbItem>
      <QtyItem>1</QtyItem>
      <PrcItem>120000</PrcItem>
      <MontoItem>120000</MontoItem>
    </Detalle>
  </Documento>
</DTE>

Why an SDK

“Why not just build the XML myself?”

You can template a DTE by hand. The hard part is everything around it: IVA rounding that matches the SII, CAF folio bookkeeping, the TED stamp, XMLDSig canonicalization, the seed/token dance, and tracking acceptance. Here's how the alternatives compare.

CapabilityOther SDKsHand-rolled XMLdte-sdk
Produces SII-schema XMLSupportedSupportedSupported
IVA and totals with SII rounding rulesSupportedPartial supportSupported
TED stamp from your CAF (with PDF417 payload)SupportedPartial supportSupported
XMLDSig signing with Web Crypto — no OpenSSL binaryPartial supportNot supportedSupported
Folio range and CAF expiry checks before stampingPartial supportNot supportedSupported
SII authentication, upload, and status trackingPartial supportNot supportedSupported
End-to-end TypeScript types, no @types packageNot supportedNot supportedSupported
Typed, PII-safe errors (DteError codes)Not supportedNot supportedSupported
Runs in Node, Deno, Bun, Edge, and the browserNot supportedPartial supportSupported
Zero runtime dependenciesNot supportedSupportedSupported
Actively maintained & tested (412 cases)Partial supportNot supportedSupported

dte-sdk is the focused, fully typed version of all this — nine composable functions covering the whole lifecycle, in ~8.4 KB and with no runtime dependencies.

Runs everywhere your TypeScript or JavaScript runs

Zero dependencies, fully typed, tree-shakeable ESM and CommonJS. Signing uses Web Crypto, so dte-sdk behaves the same on Node (>= 20), Deno, and Bun, at the Edge, and in the browser.

Node.js
Bun
React
Astro
Node.js
Bun
React
Astro
Deno
TypeScript
Next.js
Vercel
Deno
TypeScript
Next.js
Vercel

Your first DTE in four steps

1

Install the SDK

Add the package with your manager of choice: npm install dte-sdk — also works with bun, pnpm, and yarn.

2

Build the document

Call createDte({ type: 33, folio, issuer, receiver, items }) and get back an immutable, validated document with its totals already computed.

3

Stamp and sign

stampDte() adds the TED with your CAF; signDte() applies the XMLDSig signature with your digital certificate.

4

Send it to the SII

sendToSii() uploads the signed envelope and returns a track id; getStatus() tells you when it's accepted.

FAQs

  • A DTE (Documento Tributario Electrónico) is the electronic version of a Chilean tax document — invoices, receipts, dispatch guides, debit and credit notes — as defined by the SII, Chile's tax authority. Each one is an XML document with a folio, an electronic stamp (TED), and a digital signature.

    Issuing one means getting the details right end to end: totals and IVA, folios authorized by a CAF, the stamp, the signature, and the upload to the SII. That lifecycle is exactly what dte-sdk models.

Go deeper on DTE.

The blog covers the engineering behind dte-sdk — how electronic tax documents actually work, from folios and stamps to signatures and SII acceptance.

dte-sdk

MIT License © 2026 Arrow Software