> ## 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/webhook-endpoints/

> Cria um novo endpoint de webhook

Cria um novo endpoint de webhook para receber notificações de eventos em tempo real.

## Autenticação

> [!NOTE]
>
> Requer um token de acesso válido (`CHARGEFY_ACCESS_TOKEN`) no header `Authorization`.

## Parâmetros do Body

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `url` | `string` | Sim | URL do endpoint que receberá os eventos |
| `events` | `array` | Sim | Lista de eventos a escutar (ex: `subscription.created`, `subscription.canceled`) |
| `secret` | `string` | Não | Secret para validação de assinatura (gerado automaticamente se omitido) |
| `organizationId` | `string` | Sim | ID da organização |

## Campos da Resposta

| Campo | Tipo | Descrição |
| - | - | - |
| `id` | `string` | ID do endpoint |
| `url` | `string` | URL do endpoint |
| `events` | `array` | Lista de eventos |
| `secret` | `string` | Secret para validação |
| `status` | `string` | Status (`active`, `disabled`) |
| `createdAt` | `datetime` | Data de criação |

## Exemplo de Requisição

```bash cURL theme={null}
curl -X POST "https://api.chargefy.io/api/v1/webhook-endpoints/" \
  -H "Authorization: Bearer $CHARGEFY_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://meusite.com.br/webhooks/chargefy",
    "events": ["subscription.created", "subscription.canceled", "checkout.updated"],
    "organizationId": "org_abc"
  }'
```

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

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

const endpoint = await chargefy.webhookEndpoints.create({
  url: 'https://meusite.com.br/webhooks/chargefy',
  events: ['subscription.created', 'subscription.canceled', 'checkout.updated'],
  organizationId: 'org_abc',
});
```

## Exemplo de Resposta

```json theme={null}
{
  "id": "we_abc123",
  "url": "https://meusite.com.br/webhooks/chargefy",
  "events": ["subscription.created", "subscription.canceled", "checkout.updated"],
  "secret": "whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "active",
  "organizationId": "org_abc",
  "createdAt": "2026-03-12T10:00:00Z"
}
```


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