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

# Credenciales

> Certificado digital y API key de Simple API por tenant

Cada tenant necesita dos credenciales para poder emitir DTEs:

1. **API Key de Simple API** — para conectarse al servicio de facturación del SII
2. **Certificado digital (.pfx)** — para firmar los documentos electrónicos

## Opción 1: Link de activación (recomendado)

La forma más simple es generar un link de activación y enviarlo a tu cliente. Ellos configuran sus credenciales en una página hosted por nosotros, sin tocar tu código.

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

Respuesta:

```json theme={null}
{
  "token": "act_...",
  "url": "https://app.example.com/activate/act_...",
  "expiresAt": "2024-04-01T00:00:00Z"
}
```

Envía `url` a tu cliente por email o muéstralo in-app. Ver [Link de activación](/guides/activation-link) para más detalles.

## Opción 2: Vía API

Si prefieres manejar la UI de configuración tú mismo:

### Guardar API key de Simple API

```bash theme={null}
curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/credentials/api-key \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"apiKey": "simple-api-key-aqui"}'
```

### Subir certificado digital

```bash theme={null}
curl -X POST https://api.example.com/api/v1/tenants/{tenantId}/credentials/certificate \
  -H "Authorization: Bearer sk_live_..." \
  -F "file=@certificado.pfx" \
  -F "password=password-del-pfx" \
  -F "rutCertificado=12.345.678-9" \
  -F "nombreTitular=Juan Pérez" \
  -F "fechaVencimiento=2026-12-31" \
  -F "esPrincipal=true"
```

## Consultar estado

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

Respuesta:

```json theme={null}
{
  "apiKey": {
    "configured": true,
    "lastVerified": "2024-03-15T14:00:00Z"
  },
  "certificates": [
    {
      "id": "uuid",
      "rutCertificado": "12.345.678-9",
      "nombreTitular": "Juan Pérez",
      "fechaVencimiento": "2026-12-31",
      "esPrincipal": true
    }
  ]
}
```

<Info>
  El certificado se almacena cifrado con AWS KMS. La contraseña se guarda en AWS Secrets Manager. Nunca almacenamos credenciales en texto plano.
</Info>
