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

# Assinaturas

> Eventos disparados para assinaturas (PIX e Cartão).

> [tab] subscription.trial\_started
>
> Disparado quando uma assinatura com período de teste gratuito é criada. O cliente não é cobrado neste momento — a primeira cobrança pelo valor integral ocorre ao final do `trialDays`.
>
> ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> {
>   "id": "log_trialXYZ123abc",
>   "event": "subscription.trial_started",
>   "apiVersion": 2,
>   "devMode": false,
>   "data": {
>     "subscription": {
>       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
>       "amount": 4990,
>       "currency": "BRL",
>       "method": "CARD",
>       "status": "ACTIVE",
>       "frequency": "MONTHLY",
>       "trialDays": 7,
>       "trialEndsAt": "2024-11-11T23:59:59.999Z",
>       "createdAt": "2024-11-04T18:38:28.573Z",
>       "updatedAt": "2024-11-04T18:38:28.573Z",
>       "canceledAt": null,
>       "cancelPolicy": null,
>       "cancelledDueTo": null
>     },
>     "customer": {
>       "id": "cust_def456",
>       "name": "Maria Santos",
>       "email": "maria@exemplo.com",
>       "taxId": "12.***.***/0001-**"
>     }
>   }
> }
> ```

> [tab] subscription.completed
>
> Disparado quando uma assinatura se torna ativa.
>
> > [tab] Cartão
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_taQArRTApemxwcbw5EJeF3hS",
> >   "event": "subscription.completed",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "CARD",
> >       "status": "ACTIVE",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z",
> >       "canceledAt": null,
> >       "cancelPolicy": null,
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "CARD",
> >       "CARD": {
> >         "number": "1234",
> >         "brand": "VISA"
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T19:59:57.819Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```
>
> > [tab] PIX
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_taQArRTApemxwcbw5EJeF3hS",
> >   "event": "subscription.completed",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "PIX",
> >       "status": "ACTIVE",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z",
> >       "canceledAt": null,
> >       "cancelPolicy": null,
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "PIX",
> >       "PIX": {
> >         "name": "Maria Santos",
> >         "taxId": "12.***.***/0001-**",
> >         "isSameAsCustomer": true
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T19:59:57.819Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```

> [tab] subscription.renewed
>
> Disparado sempre que uma assinatura é renovada com sucesso.
>
> > [tab] Cartão
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_abc123xyz",
> >   "event": "subscription.renewed",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "CARD",
> >       "status": "ACTIVE",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z",
> >       "canceledAt": null,
> >       "cancelPolicy": null,
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2025-01-06T20:00:00.000Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "CARD",
> >       "CARD": {
> >         "number": "1234",
> >         "brand": "VISA"
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_renewxyz789",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_renewxyz789",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2025-01-06T19:59:57.819Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```
>
> > [tab] PIX
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_abc123xyz",
> >   "event": "subscription.renewed",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "PIX",
> >       "status": "ACTIVE",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z",
> >       "canceledAt": null,
> >       "cancelPolicy": null,
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2025-01-06T20:00:00.000Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "PIX",
> >       "PIX": {
> >         "name": "Maria Santos",
> >         "taxId": "12.***.***/0001-**",
> >         "isSameAsCustomer": true
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_renewxyz789",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_renewxyz789",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2025-01-06T19:59:57.819Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```

> [tab] subscription.payment\_failed
>
> Disparado a cada falha de cobrança de um ciclo. O campo `retryNumber` indica quantas tentativas já foram feitas. Quando `retryNumber` atingir `maxRetry` (configurado em `retryPolicy` ao criar a assinatura), a assinatura é cancelada automaticamente e o evento `subscription.cancelled` é disparado logo em seguida com `cancelledDueTo: "max_payment_retries_exceeded"`.
>
> ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> {
>   "id": "log_abc123xyz",
>   "event": "subscription.payment_failed",
>   "apiVersion": 2,
>   "devMode": false,
>   "data": {
>     "subscription": {
>       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
>       "amount": 2990,
>       "currency": "BRL",
>       "method": "CARD",
>       "status": "ACTIVE",
>       "frequency": "MONTHLY",
>       "retryPolicy": {
>         "maxRetry": 3,
>         "retryEvery": 2
>       },
>       "createdAt": "2024-12-06T20:00:00.000Z",
>       "updatedAt": "2025-01-06T20:00:05.000Z",
>       "canceledAt": null,
>       "cancelPolicy": null,
>       "cancelledDueTo": null
>     },
>     "installmentId": "intl_abc123xyz",
>     "installmentNumber": 2,
>     "retryNumber": 1
>   }
> }
> ```

> [tab] subscription.cancelled
>
> Disparado quando uma assinatura é cancelada — seja via API ou automaticamente após esgotar todas as tentativas de cobrança. Nesse segundo caso, `cancelledDueTo` será `"max_payment_retries_exceeded"`.
>
> > [tab] Cancelamento manual
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_abc123xyz",
> >   "event": "subscription.cancelled",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "CARD",
> >       "status": "CANCELLED",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z",
> >       "canceledAt": "2024-12-06T20:00:05.000Z",
> >       "cancelPolicy": "NOW",
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "CARD",
> >       "CARD": {
> >         "number": "1234",
> >         "brand": "VISA"
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 100,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["CARD"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T19:59:57.819Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```
>
> > [tab] Cancelamento automático (max retries)
> >
> > Disparado quando todas as tentativas de cobrança são esgotadas. `cancelledDueTo` identifica a causa e `cancelPolicy` é `"NOW"`, indicando que os ciclos futuros também foram cancelados.
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_abc123xyz",
> >   "event": "subscription.cancelled",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "CARD",
> >       "status": "CANCELLED",
> >       "frequency": "MONTHLY",
> >       "retryPolicy": {
> >         "maxRetry": 3,
> >         "retryEvery": 2
> >       },
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2025-01-06T20:00:05.000Z",
> >       "canceledAt": "2025-01-06T20:00:05.000Z",
> >       "cancelPolicy": "NOW",
> >       "cancelledDueTo": "max_payment_retries_exceeded"
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     }
> >   }
> > }
> > ```
>
> > [tab] PIX
> >
> > ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> > {
> >   "id": "log_abc123xyz",
> >   "event": "subscription.cancelled",
> >   "apiVersion": 2,
> >   "devMode": false,
> >   "data": {
> >     "subscription": {
> >       "id": "subs_tAFqDWBhcEYTjQh2K0ZYDHau",
> >       "amount": 2990,
> >       "currency": "BRL",
> >       "method": "PIX",
> >       "status": "CANCELLED",
> >       "frequency": "MONTHLY",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z",
> >       "canceledAt": "2024-12-06T20:00:05.000Z",
> >       "cancelPolicy": "NOW",
> >       "cancelledDueTo": null
> >     },
> >     "customer": {
> >       "id": "cust_def456",
> >       "name": "Maria Santos",
> >       "email": "maria@exemplo.com",
> >       "taxId": "12.***.***/0001-**"
> >     },
> >     "payment": {
> >       "id": "char_xyz789",
> >       "externalId": "pedido-456",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T20:00:00.000Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     },
> >     "payerInformation": {
> >       "method": "PIX",
> >       "PIX": {
> >         "name": "Maria Santos",
> >         "taxId": "12.***.***/0001-**",
> >         "isSameAsCustomer": true
> >       }
> >     },
> >     "checkout": {
> >       "id": "bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "externalId": null,
> >       "url": "https://whallet.com/pay/bill_jskd3TMfScHZDJe5NSZjTmQ4",
> >       "amount": 2990,
> >       "paidAmount": 2990,
> >       "platformFee": 60,
> >       "frequency": "SUBSCRIPTION",
> >       "items": [{ "id": "prod_bx4BstRWhQ2SUcKsPt4c6pmq", "quantity": 1 }],
> >       "status": "PAID",
> >       "methods": ["PIX"],
> >       "customerId": "cust_def456",
> >       "receiptUrl": "https://whallet.com/receipt/...",
> >       "createdAt": "2024-12-06T19:59:57.819Z",
> >       "updatedAt": "2024-12-06T20:00:05.000Z"
> >     }
> >   }
> > }
> > ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.