> ## Documentation Index
> Fetch the complete documentation index at: https://developers.siplex.cl/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Emite tu primera factura electrónica en 5 minutos

## Prerequisitos

<Check>Una cuenta creada en el [dashboard](https://app.example.com)</Check>
<Check>Una API key generada en Settings → API Keys</Check>
<Check>Un tenant con credenciales configuradas (certificado .pfx + API key de Simple API)</Check>

## 1. Crear un tenant

Cada empresa que factura es un tenant. Créalo con los datos tributarios del RUT.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.example.com/api/v1/tenants \
    -H "Authorization: Bearer sk_live_..." \
    -H "Content-Type: application/json" \
    -d '{
      "rutEmpresa": "76.123.456-7",
      "razonSocial": "Mi Empresa SpA",
      "giro": "Tecnología",
      "direccion": "Av. Principal 123",
      "comuna": "Santiago",
      "ciudad": "Santiago",
      "numeroResolucion": 80,
      "fechaResolucion": "2024-01-15"
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch('https://api.example.com/api/v1/tenants', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk_live_...',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      rutEmpresa: '76.123.456-7',
      razonSocial: 'Mi Empresa SpA',
      giro: 'Tecnología',
      direccion: 'Av. Principal 123',
      comuna: 'Santiago',
      ciudad: 'Santiago',
      numeroResolucion: 80,
      fechaResolucion: '2024-01-15',
    }),
  })
  const tenant = await res.json()
  // tenant.id → usar en los siguientes pasos
  ```
</CodeGroup>

## 2. Enviar link de activación

Genera un link para que tu cliente suba su certificado digital y API key de Simple API. El link expira en 7 días.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/activation-link \
    -H "Authorization: Bearer sk_live_..."
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(
    `https://api.example.com/api/v1/tenants/${tenant.id}/activation-link`,
    {
      method: 'POST',
      headers: { 'Authorization': 'Bearer sk_live_...' },
    }
  )
  const { url, expiresAt } = await res.json()
  // Envía `url` a tu cliente por email o in-app
  ```
</CodeGroup>

<Info>
  Tu cliente abre el link, sube su .pfx y API key de Simple API en una página hosted por nosotros.
  No necesitas construir UI para esto.
</Info>

## 3. Solicitar folios

Una vez que tu cliente configuró credenciales (recibirás un webhook `tenant.credentials.updated`), solicita folios al SII.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/folios/request \
    -H "Authorization: Bearer sk_live_..." \
    -H "Content-Type: application/json" \
    -d '{"tipoDte": 33, "cantidad": 50}'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    `https://api.example.com/api/v1/tenants/${tenant.id}/folios/request`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk_live_...',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ tipoDte: 33, cantidad: 50 }),
    }
  )
  ```
</CodeGroup>

## 4. Emitir una factura

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/dte \
    -H "Authorization: Bearer sk_live_..." \
    -H "Content-Type: application/json" \
    -d '{
      "tipoDte": 33,
      "receptor": {
        "rut": "77.777.777-7",
        "razonSocial": "Cliente SpA",
        "giro": "Comercio",
        "direccion": "Calle 1",
        "comuna": "Santiago",
        "ciudad": "Santiago"
      },
      "detalle": [
        {
          "nombre": "Servicio de desarrollo web",
          "cantidad": 1,
          "precioUnitario": 100000,
          "montoItem": 100000
        }
      ],
      "montoTotal": 119000
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(
    `https://api.example.com/api/v1/tenants/${tenant.id}/dte`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk_live_...',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        tipoDte: 33,
        receptor: {
          rut: '77.777.777-7',
          razonSocial: 'Cliente SpA',
          giro: 'Comercio',
          direccion: 'Calle 1',
          comuna: 'Santiago',
          ciudad: 'Santiago',
        },
        detalle: [
          {
            nombre: 'Servicio de desarrollo web',
            cantidad: 1,
            precioUnitario: 100000,
            montoItem: 100000,
          },
        ],
        montoTotal: 119000,
      }),
    }
  )
  const dte = await res.json()
  ```
</CodeGroup>

## 5. Enviar al SII

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/dte/send \
    -H "Authorization: Bearer sk_live_..." \
    -H "Content-Type: application/json" \
    -d '{"dteIds": ["uuid-del-dte"]}'
  ```

  ```javascript Node.js theme={null}
  await fetch(
    `https://api.example.com/api/v1/tenants/${tenant.id}/dte/send`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk_live_...',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ dteIds: [dte.id] }),
    }
  )
  ```
</CodeGroup>

<Check>La factura queda enviada al SII. Puedes consultar el estado con `GET /dte/{dteId}/status`.</Check>

## Siguiente paso

<CardGroup cols={2}>
  <Card title="Autenticación" icon="key" href="/guides/authentication">
    Generar y gestionar API keys
  </Card>

  <Card title="Webhooks" icon="bell" href="/guides/webhooks">
    Notificaciones en tiempo real
  </Card>
</CardGroup>
