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

# Criar Cobrança

> Cria uma nova cobrança PIX

## Descrição

Cria uma nova cobrança PIX. O retorno inclui o QR Code e o código copia-e-cola para apresentar ao cliente.

<Note>
  O campo `amount` deve ser enviado em <strong>centavos</strong> (inteiro). Por exemplo, `1000` = R\$ 10,00.
</Note>

**Rate Limit:** 60 requisições/minuto

***

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token de autenticação. Formato: `Bearer sk_live_xxx`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Deve ser `application/json`
</ParamField>

<ParamField header="Idempotency-Key" type="string">
  Chave única para evitar cobranças duplicadas
</ParamField>

***

## Body

<ParamField body="amount" type="integer" required>
  Valor em <strong>centavos</strong> (ex: `1000` = R\$ 10,00)
</ParamField>

<ParamField body="description" type="string">
  Descrição da cobrança
</ParamField>

<ParamField body="customer" type="object">
  Dados do cliente

  <Expandable title="Propriedades">
    <ParamField body="customer.name" type="string">
      Nome do cliente
    </ParamField>

    <ParamField body="customer.email" type="string">
      E-mail do cliente
    </ParamField>

    <ParamField body="customer.document" type="string">
      CPF/CNPJ do cliente
    </ParamField>
  </Expandable>
</ParamField>

***

## Exemplo de Requisição

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.flarepayments.com/v1/charges \
    -H "Authorization: Bearer sk_live_sua_chave_aqui" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: pedido-1234" \
    -d '{
      "amount": 1000,
      "description": "Pedido #1234",
      "customer": {
        "name": "João Silva",
        "email": "joao@email.com",
        "document": "12345678900"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.flarepayments.com/v1/charges', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk_live_sua_chave_aqui',
      'Content-Type': 'application/json',
      'Idempotency-Key': 'pedido-1234'
    },
    body: JSON.stringify({
      amount: 1000,
      description: 'Pedido #1234',
      customer: {
        name: 'João Silva',
        email: 'joao@email.com',
        document: '12345678900'
      }
    })
  });

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

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

  response = requests.post(
      'https://api.flarepayments.com/v1/charges',
      headers={
          'Authorization': 'Bearer sk_live_sua_chave_aqui',
          'Content-Type': 'application/json',
          'Idempotency-Key': 'pedido-1234'
      },
      json={
          'amount': 1000,
          'description': 'Pedido #1234',
          'customer': {
              'name': 'João Silva',
              'email': 'joao@email.com',
              'document': '12345678900'
          }
      }
  )
  charge = response.json()
  ```
</CodeGroup>

***

## Resposta `201 Created`

<ResponseField name="id" type="string">
  ID da cobrança no formato `ch_flare_xxx`
</ResponseField>

<ResponseField name="object" type="string">
  Sempre `"charge"`
</ResponseField>

<ResponseField name="amount" type="float">
  Valor em Reais
</ResponseField>

<ResponseField name="amount_cents" type="integer">
  Valor em centavos
</ResponseField>

<ResponseField name="currency" type="string">
  Moeda (`BRL`)
</ResponseField>

<ResponseField name="method" type="string">
  Método de pagamento (`pix`)
</ResponseField>

<ResponseField name="status" type="string">
  Status da cobrança: `pending`, `paid`, `expired`, `failed`
</ResponseField>

<ResponseField name="pix" type="object">
  Dados do PIX

  <Expandable title="Propriedades">
    <ResponseField name="pix.qr_code" type="string">
      QR Code em base64
    </ResponseField>

    <ResponseField name="pix.copy_paste" type="string">
      Código copia-e-cola do PIX
    </ResponseField>

    <ResponseField name="pix.payment_link" type="string">
      Link de pagamento
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="expires_at" type="string">
  Data de expiração (ISO 8601)
</ResponseField>

<ResponseField name="created_at" type="string">
  Data de criação (ISO 8601)
</ResponseField>

<ResponseField name="livemode" type="boolean">
  `true` em produção
</ResponseField>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "ch_flare_dc7dc11b7f984d2886d2b429",
    "object": "charge",
    "amount": 10.00,
    "amount_cents": 1000,
    "currency": "BRL",
    "method": "pix",
    "status": "pending",
    "pix": {
      "qr_code": "base64...",
      "copy_paste": "00020101021226...",
      "payment_link": "https://..."
    },
    "expires_at": "2026-03-05T19:14:48.549Z",
    "created_at": "2026-03-05T18:14:48.552Z",
    "livemode": true
  }
  ```
</ResponseExample>

***

## Erros

| Status | Código                | Descrição                                         |
| ------ | --------------------- | ------------------------------------------------- |
| `400`  | `invalid_amount`      | `amount` deve ser um inteiro positivo em centavos |
| `401`  | `unauthorized`        | Header `Authorization` ausente                    |
| `401`  | `invalid_api_key`     | Chave de API inválida                             |
| `429`  | `rate_limit_exceeded` | Limite de 60 req/min excedido                     |
