# Quickstart

> Install the Simplo SDK, emit your first DTE (Chilean electronic invoice) and follow its SII status in a few minutes.

Emit your first DTE (Documento Tributario Electronico — a Chilean electronic
tax document, such as an invoice or receipt) in a few minutes.

> **Private beta:**
> The Simplo API is currently in **private beta**: API-key access to the
> invoicing surface is being enabled account by account as part of the rollout,
> so this walkthrough works once your account is in the beta. To request
> access, email [hola@simplo.cl](mailto:hola@simplo.cl).

## 1. Install

```bash
npm install @simplohq/sdk
# or: pnpm add @simplohq/sdk
```

Requirements: Node.js 18.17+ (or Deno, Bun, Cloudflare Workers — anything
with a global `fetch`). The SDK has zero runtime dependencies.

## 2. Configure credentials

Get an API key (`sk_simplo_...`) from your Simplo account — see
[Authentication](/comienza/autenticacion/) — and export it:

```bash
export SIMPLO_API_KEY="sk_simplo_..."
```

The client picks up `SIMPLO_API_KEY` automatically, or you can pass `apiKey`
explicitly.

## 3. Emit an invoice

```ts
import Simplo from '@simplohq/sdk';

const simplo = new Simplo(); // reads SIMPLO_API_KEY

const dte = await simplo.dtes.emit({
  tipo_dte: 33, // Factura Electronica (invoice)
  receptor: {
    rut: '76543210-K', // recipient's RUT (Chilean tax ID)
    razon_social: 'Cliente Ejemplo SpA',
    giro: 'Software services',
    direccion: 'Av. Providencia 1234',
    comuna: 'Providencia',
  },
  detalle: [{ nombre: 'Consulting services', cantidad: 10, precio: 50000 }],
});

console.log(dte.id, dte.folio, dte.estado); // "….", 1042, "firmado"
```

`emit` returns as soon as the document is signed (`estado: "firmado"`).
Submission to the SII (Servicio de Impuestos Internos, the Chilean tax
authority) happens asynchronously.

Amounts are integer Chilean pesos (CLP). VAT (19%) is computed by the API —
you send net prices.

## 4. Follow the document's status

Poll:

```ts
const current = await simplo.dtes.retrieve(dte.id);
console.log(current.estado); // "enviando" | "procesando" | "aceptado" | "rechazado" | "con_reparos"
console.log(current.tracking?.track_id); // SII track ID once submitted
```

Or subscribe to webhooks — see [Webhooks](/referencia/webhooks/).

The full status lifecycle is documented in [Estados](/referencia/estados/).

## 5. Download the PDF and XML

```ts
import { writeFile } from 'node:fs/promises';

const pdf = await simplo.dtes.pdf(dte.id); // ArrayBuffer
await writeFile('invoice.pdf', Buffer.from(pdf));

const xml = await simplo.dtes.xml(dte.id); // signed XML as string
```

Pass `{ cedible: true }` to `pdf()` for the transferable copy used in
factoring.

## Before you can emit for real

Two one-time setup steps per company:

1. **Digital certificate** — uploaded through your Simplo account; the SDK
   lets you check it with `await simplo.company.certificate.status()`.
2. **Folios (CAF)** — a CAF (Codigo de Autorizacion de Folios) is the SII
   file authorizing a range of document numbers. Upload one through the SDK
   with `await simplo.folios.upload({ tipo_dte: 33, caf_xml })` and monitor
   availability with `simplo.folios.list()`.

## Next steps

The rest of this site is in Spanish (the root locale); every page an
integration needs is linked from the sidebar. The English SDK docs live in
the [SDK repository](https://github.com/SimploHQ/simplo-node-sdk) as plain
markdown.

---

Versión HTML: https://docs.simplo.cl/en/comienza/quickstart/ · Índice para agentes: https://docs.simplo.cl/llms.txt
