> ## 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.

# Folios

> Solicitar y gestionar rangos de folios (CAF) del SII

Los folios son números autorizados por el SII para emitir documentos tributarios. Antes de emitir cualquier DTE, necesitas solicitar folios para ese tipo de documento.

## Solicitar folios

<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/${tenantId}/folios/request`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk_live_...',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ tipoDte: 33, cantidad: 50 }),
    }
  )
  ```
</CodeGroup>

| Parámetro  | Tipo      | Descripción                                                    |
| ---------- | --------- | -------------------------------------------------------------- |
| `tipoDte`  | `integer` | Código del tipo de DTE (ver [tipos de DTE](/guides/dte-types)) |
| `cantidad` | `integer` | Cantidad de folios a solicitar (1-100)                         |

## Consultar inventario

```bash theme={null}
curl https://api.example.com/api/v1/tenants/{tenantId}/folios \
  -H "Authorization: Bearer sk_live_..."
```

Respuesta:

```json theme={null}
[
  {
    "tipoDte": 33,
    "total": 500,
    "disponibles": 350,
    "estado": "activo",
    "porcentaje": 70
  },
  {
    "tipoDte": 61,
    "total": 100,
    "disponibles": 5,
    "estado": "activo",
    "porcentaje": 5
  }
]
```

## Anular folios

Si necesitas anular un rango de folios no utilizados:

```bash theme={null}
curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/folios/void \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"tipoDte": 33, "desde": 100, "hasta": 150}'
```

<Warning>
  Configura un webhook `folio.low` para recibir alertas cuando los folios estén por agotarse. Así puedes solicitar más automáticamente.
</Warning>
