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

# Link de activación

> Onboarding hosted para que tus clientes configuren credenciales

El link de activación es una página hosted donde tu cliente sube su certificado digital (.pfx) y API key de Simple API. Tú no necesitas construir UI para esto.

## Flujo

```
Tu SaaS                    Nuestra API              Tu cliente
  │                             │                       │
  ├── POST /activation-link ───►│                       │
  │◄── { url, expiresAt } ─────┤                       │
  │                             │                       │
  ├── envía url por email ──────┼──────────────────────►│
  │                             │                       │
  │                             │◄── abre url ──────────┤
  │                             │◄── sube .pfx ─────────┤
  │                             │◄── ingresa API key ───┤
  │                             │                       │
  │◄── webhook: credentials ────┤                       │
  │    updated                  │                       │
```

## Generar el link

<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 { url, expiresAt } = await fetch(
    `https://api.example.com/api/v1/tenants/${tenantId}/activation-link`,
    {
      method: 'POST',
      headers: { 'Authorization': 'Bearer sk_live_...' },
    }
  ).then(r => r.json())

  // Envía `url` a tu cliente
  await sendEmail(clientEmail, {
    subject: 'Configura tu facturación electrónica',
    body: `Completa tu activación aquí: ${url}`,
  })
  ```
</CodeGroup>

Respuesta:

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

## Qué ve tu cliente

La página de activación guía al usuario en 2 pasos:

1. **API Key de Simple API** — campo de texto enmascarado
2. **Certificado digital** — drag-and-drop de archivo .pfx con password, RUT, nombre y fecha de vencimiento

Cuando ambos pasos están completos, el token se marca como completado y recibes un webhook.

## Token

* Expira en 7 días por defecto
* Se puede generar un nuevo link en cualquier momento (el anterior se invalida)
* El token se hashea con SHA-256 antes de almacenarse
* Es de un solo uso — una vez completado, no se puede reutilizar

## Saber cuándo terminó

Configura un [webhook](/guides/webhooks) para el evento `tenant.credentials.updated`. Se dispara automáticamente cuando tu cliente completa la activación.

```json theme={null}
{
  "event": "tenant.credentials.updated",
  "data": {
    "tenantId": "uuid",
    "apiKey": { "configured": true },
    "certificate": { "configured": true }
  }
}
```
