Skip to content

Features

dte-sdk covers the whole life of a Chilean electronic tax document with nine typed functions: build it, total it, stamp it, sign it, send it to the SII, follow its status and serialize it. Each step returns a new immutable object, so you can stop at any stage, inspect it, and continue.

These pages describe the planned 1.0 API. The published 0.0.2 is a placeholder, and details may change before 1.0.

The Functions#

The other three public functions live on the page of the step they support: parseCaf() with stampDte(), loadCertificate() with signDte(), and getStatus() with sendToSii(). Every signature, type and constant is also listed in the API Reference.

How They Compose#

A document moves through five steps. Each one takes the output of the previous step:

1

Create

createDte() validates the issuer, receiver and lines, and calculates the totals. Returns a Dte.

2

Stamp

stampDte() adds the TED using the CAF for that type and folio. Returns a StampedDte.

3

Sign

signDte() signs the document with your certificate. Returns a SignedDte.

4

Send

sendToSii() uploads one or more signed documents and returns a track id.

5

Check

getStatus() tells you whether the SII accepted, accepted with objections, or rejected them.

In code:

TypeScript
import { createDte, getStatus, sendToSii, signDte, stampDte } from 'dte-sdk'
 
const dte = createDte(input)                        // Dte
const stamped = stampDte(dte, caf)                  // StampedDte
const signed = await signDte(stamped, certificate)  // SignedDte
 
const { trackId } = await sendToSii(signed, {
  certificate,
  environment: 'certification',
  senderRut: '15.234.567-4',
  resolution: { number: 0, date: '2026-09-01' },
})
 
const status = await getStatus(trackId, {
  certificate,
  environment: 'certification',
  issuerRut: '76.123.456-0',
})

calculateTotals() and toXml() are helpers you can use at any point: totals for a cart before a document exists, XML for a preview or an archive.

Shared Behavior#

All functions:

  • ✅ Are fully typed - each stage has its own type, so sending an unsigned document is a compile error
  • ✅ Are immutable - every step returns a new object and never changes its input
  • ✅ Throw one error class - DteError, with a stable code to branch on
  • ✅ Emit generic messages - errors never include RUTs, amounts, CAF private keys or certificate passwords
  • ✅ Run everywhere - Node 20 or later, the browser, Deno and Bun, using Web Crypto
  • ✅ Add no dependencies - zero runtime dependencies, tree-shakeable ESM and CJS

dte-sdk builds, stamps, signs and sends documents. It does not render the printed PDF version: use stamped.pdf417 with your own printing pipeline.

Next Steps#

  • Follow a complete flow in Issue an Invoice
  • Learn the moving parts (folios, CAF, certificates) in Concepts
  • Keep your CAF and certificate safe with the Security guide