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

# Primeira cobrança

> Crie uma cobrança Pix e receba a confirmação por webhook.

> [!WARNING]
>
> A API está em construção. Rotas, campos e eventos desta página são ilustrativos e podem mudar até o lançamento.

## 1. Pegue sua chave

Use uma chave do ambiente de testes enquanto integra. Guarde-a em uma variável de ambiente, nunca no código.

```bash theme={null}
export WOOVPAY_KEY="sua_chave_de_testes"
```

## 2. Crie a cobrança

O valor vai em centavos: `4990` é R\$ 49,90.

```bash cURL theme={null}
curl -X POST https://api.woovpay.com/v1/charges \
  -H "Authorization: Bearer $WOOVPAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 4990,
    "method": "pix",
    "description": "Pedido #1042",
    "webhook_url": "https://seusite.com/webhooks/woov"
  }'
```

```javascript Node theme={null}
const res = await fetch("https://api.woovpay.com/v1/charges", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WOOVPAY_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    amount: 4990,
    method: "pix",
    description: "Pedido #1042",
    webhook_url: "https://seusite.com/webhooks/woov",
  }),
});

const charge = await res.json();
```

```python Python theme={null}
import os
import requests

res = requests.post(
    "https://api.woovpay.com/v1/charges",
    headers={"Authorization": f"Bearer {os.environ['WOOVPAY_KEY']}"},
    json={
        "amount": 4990,
        "method": "pix",
        "description": "Pedido #1042",
        "webhook_url": "https://seusite.com/webhooks/woov",
    },
)

charge = res.json()
```

A resposta traz o Pix para mostrar ao cliente:

```json theme={null}
{
  "id": "ch_7Fq2kM9xLp",
  "status": "pending",
  "amount": 4990,
  "pix": {
    "qr_code": "00020126...",
    "expires_in": 3600
  }
}
```

Mostre `pix.qr_code` como QR Code e como texto para copiar e colar.

## 3. Receba o aviso

Quando o cliente paga, a woov chama a sua `webhook_url`:

```json theme={null}
{
  "type": "charge.paid",
  "data": { "id": "ch_7Fq2kM9xLp", "status": "paid", "amount": 4990 }
}
```

Libere o pedido quando chegar `charge.paid` e responda `200`. Veja [Webhooks](https://docs.woovpay.com/guias/webhooks.md).


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