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

# Create an Invoice

> Cria uma invoice.

Cria uma invoice em status `open`. Os valores, itens de linha, vencimento e
snapshots do customer ficam fixos desde a criação. Para corrigir esses dados,
cancele a invoice (`void`) e crie uma nova.

Para uma **cobrança avulsa** (com vencimento, multa/juros e URL de fatura
para o cliente), envie `due_date`, defina `late_fee`/`interest` quando quiser
penalidades por atraso, e deixe `delivery: "chargefy"` para que a Chargefy
envie a fatura por email e cuide dos lembretes. Use `amount` quando a cobrança
não tiver produtos.

A resposta inclui `hosted_invoice_url`, uma URL pública ativa em
`billing.chargefy.io/invoice/:token`. Compartilhe esse campo quando quiser que o
cliente visualize ou pague a invoice manualmente. O token pertence à invoice
criada, pode ser renovado pela Chargefy, e não é um `payment_link`
reutilizável.

<ParamField body="customer" type="string" required>
  Customer que receberá a invoice (`cus_*`).
</ParamField>

<ParamField body="amount" type="integer">
  Valor total em centavos, quando a cobrança não tem produtos. Cria um item de
  linha único. Use `line_items` para cobranças com produtos — envie um ou outro.
</ParamField>

<ParamField body="line_items" type="array">
  Itens da invoice. Cada item usa `price` ou `price_data`. Obrigatório, exceto
  quando você envia `amount`.
</ParamField>

<ParamField body="collection_method" type="string">
  `send_invoice` ou `charge_automatically`. Padrão: `send_invoice`.
</ParamField>

<ParamField body="due_date" type="string">
  Data de vencimento em ISO 8601. Em branco, vence hoje (a cobrança é enviada na
  criação quando `delivery` é `chargefy`).
</ParamField>

<ParamField body="late_fee" type="object">
  Multa aplicada uma vez após o vencimento.

  <Expandable title="late_fee">
    <ParamField body="type" type="string">
      `percentage` ou `fixed`.
    </ParamField>

    <ParamField body="value" type="number">
      Percentual (ex.: `2` para 2%) quando `type` é `percentage`; centavos quando
      `fixed`.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="interest" type="object">
  Juros mensais que acumulam por dia após o vencimento.

  <Expandable title="interest">
    <ParamField body="percent_per_month" type="number">
      Percentual ao mês (ex.: `1` para 1% a.m.).
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="allow_late_payment" type="boolean">
  Permite pagamento após o vencimento (multa/juros acumulam, lembretes continuam
  até o limite). Padrão: `true` quando há `late_fee` ou `interest`.
</ParamField>

<ParamField body="payment_method_types" type="array">
  Meios de pagamento permitidos na página da invoice: `pix`, `boleto`,
  `credit_card`. Padrão: todos.
</ParamField>

<ParamField body="delivery" type="string">
  `chargefy` para a Chargefy enviar por email e lembrar automaticamente, ou
  `manual` para você compartilhar `hosted_invoice_url`. Padrão: `chargefy`.
</ParamField>

<ParamField body="default_payment_method" type="string">
  Payment method salvo (`pm_*`) escolhido como padrão desta invoice. Ao pagar
  sem `payment_method` explícito, a Chargefy tenta usar o padrão da invoice,
  depois o padrão da subscription, e por fim o padrão do customer.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata livre.
</ParamField>

<RequestExample>
  ```bash Valor avulso theme={}
  curl -X POST "https://api.chargefy.io/v1/invoices" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 12990,
      "customer": "cus_123"
    }'
  ```

  ```bash Com line_items theme={}
  curl -X POST "https://api.chargefy.io/v1/invoices" \
    -H "Authorization: Bearer {{API_KEY}}" \
    -H "Content-Type: application/json" \
    -d '{
      "customer": "cus_123",
      "line_items": [
        {
          "price": "price_123"
        }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response 200 theme={}
  {
    "id": "inv_123",
    "object": "invoice",
    "allow_late_payment": true,
    "amount_credit_balance_applied": 0,
    "amount_discount": 0,
    "amount_due": 12990,
    "amount_due_now": 12990,
    "amount_paid": 0,
    "amount_remaining": 12990,
    "amount_subtotal": 12990,
    "amount_tax": 0,
    "amount_total": 12990,
    "billing_reason": "manual",
    "collection_method": "send_invoice",
    "created_at": "2026-05-19T18:00:00Z",
    "currency": "brl",
    "customer": "cus_123",
    "customer_billing_address": {},
    "customer_billing_name": "Ada Lovelace",
    "customer_document": "12345678901",
    "customer_document_type": "cpf",
    "customer_email": "ada@example.com",
    "customer_name": "Ada Lovelace",
    "default_payment_method": null,
    "description": "Mensalidade de junho",
    "due_date": "2026-06-10T03:00:00Z",
    "ending_balance": 0,
    "hosted_invoice_url": "https://billing.chargefy.io/invoice/ilink_8Pz6wKf3tVn2Qa9LmXr4Bc7D",
    "interest": {
      "percent_per_month": 1
    },
    "interest_amount": null,
    "invoice_pdf_url": null,
    "late_fee": {
      "type": "percentage",
      "value": 2
    },
    "late_fee_amount": null,
    "latest_charge": null,
    "line_items": [
      {
        "id": "ili_123",
        "object": "invoice_line_item",
        "amount_discount": 0,
        "amount_subtotal": 12990,
        "amount_tax": 0,
        "amount_total": 12990,
        "currency": "brl",
        "description": "Mensalidade de junho",
        "discountable": true,
        "metadata": {},
        "period_end": null,
        "period_start": null,
        "position": 0,
        "price": null,
        "price_data": {
          "currency": "brl",
          "unit_amount": 12990
        },
        "product": null,
        "proration": false,
        "proration_details": {},
        "quantity": 1,
        "recurring_interval": null,
        "recurring_interval_count": null,
        "subscription_item": null,
        "unit_amount": 12990
      }
    ],
    "livemode": true,
    "marked_uncollectible_at": null,
    "metadata": {
      "order_id": "6735"
    },
    "number": "K7M2-0001",
    "paid_at": null,
    "payment_intent": null,
    "payment_method_types": ["pix", "boleto", "credit_card"],
    "payments": {
      "object": "list",
      "data": [],
      "has_more": false,
      "url": "/v1/invoices/inv_123/payments"
    },
    "starting_balance": 0,
    "statement_descriptor": null,
    "status": "open",
    "subscription": null,
    "updated_at": "2026-05-19T18:00:00Z",
    "voided_at": null
  }
  ```
</ResponseExample>
