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

# POST /api/v1/subscriptions/:id/payment-update-token

> Gera um link temporário (48h) para o cliente atualizar o cartão de pagamento da assinatura

Cria um token com validade de 48 horas e retorna uma URL que pode ser compartilhada com o cliente para que ele atualize o cartão de crédito vinculado à assinatura.

## Autenticação

> [!NOTE]
>
> Requer um token de acesso válido (`CHARGEFY_ACCESS_TOKEN`) no header `Authorization`. Escopos necessários: `web:write` ou `subscriptions:write`.

## Parâmetros de Path

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `id` | `string` | Sim | ID da assinatura |

> [!WARNING]
>
> Somente assinaturas com `status: active`, `trialing`, `unpaid` ou `past_due` podem gerar tokens de atualização de pagamento.

## Campos da Resposta

| Campo | Tipo | Descrição |
| - | - | - |
| `url` | `string` | URL com o token de atualização, válida por 48 horas |
| `expires_at` | `datetime` | Data e hora de expiração do token |

## Exemplo de Requisição

```bash cURL theme={null}
curl -X POST "https://api.chargefy.io/api/v1/subscriptions/sub_1a2b3c4d/payment-update-token" \
  -H "Authorization: Bearer $CHARGEFY_ACCESS_TOKEN"
```

```typescript SDK theme={null}
import { Chargefy } from '@chargefy/sdk';

const chargefy = new Chargefy({
  accessToken: process.env.CHARGEFY_ACCESS_TOKEN,
});

const token = await chargefy.subscriptions.createPaymentUpdateToken('sub_1a2b3c4d');
```

## Exemplo de Resposta

```json theme={null}
{
  "url": "https://app.chargefy.com.br/update-payment/tok_eyJzdWIiOiJzdWJfMWEyYjNjNGQifQ",
  "expires_at": "2026-03-22T10:00:00Z"
}
```


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