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

# Criar cobrança avulsa

> Pagamento único: boleto, cartão ou PIX na Conta Padrão. Não é assinatura recorrente.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.goatpay.com.br/v1/billings/create' \
    -H 'X-API-Key: gp_live_SUA_CHAVE' \
    -H 'Content-Type: application/json' \
    -d '{ "salesCustomerId": "clx_customer", "billingType": "BOLETO", "amount": 79.9, "description": "Pedido 123", "dueDate": "2026-08-15", "installmentCount": 1, "externalReference": "pedido-123" }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "success": true,
    "message": "Cobrança avulsa criada",
    "data": {
      "id": "clx_billing",
      "status": "PENDING",
      "statusLabel": "Pendente",
      "billingType": "PIX",
      "amount": 79.9,
      "netAmount": 76.91,
      "feeAmount": 2.99,
      "notificationFeeAmount": 0,
      "installmentCount": 1,
      "description": "Pedido 123",
      "dueAt": "2026-06-15T23:59:59.000Z",
      "dueDate": "2026-06-15",
      "paidAt": "2026-05-31T14:22:00.000Z",
      "estimatedCreditDate": "2026-06-02T00:00:00.000Z",
      "invoiceUrl": "https://...",
      "bankSlipUrl": null,
      "digitableLine": null,
      "pixCopyPaste": "00020101021226730014br.gov.bcb.pix...",
      "pixEncodedImage": "iVBORw0KGgo...",
      "accountTransactionId": "clx_ledger",
      "externalReference": "pedido-123",
      "createdAt": "2026-05-30T10:00:00.000Z",
      "customer": {
        "id": "clx_customer",
        "name": "Cliente Exemplo",
        "taxId": "12345678909"
      }
    },
    "requestId": "req_abc123"
  }
  ```
</ResponseExample>

### Corpo da requisição

<ParamField body="salesCustomerId" type="string">
  ID do cliente cadastrado (`POST /customers/create`).
</ParamField>

<ParamField body="customerName" type="string">
  Nome do pagador (se não usar salesCustomerId).
</ParamField>

<ParamField body="customerTaxId" type="string">
  CPF/CNPJ do pagador (se não usar salesCustomerId).
</ParamField>

<ParamField body="customerEmail" type="string">
  E-mail do pagador.
</ParamField>

<ParamField body="billingType" type="string" required>
  BOLETO, CREDIT\_CARD, DEBIT\_CARD ou VOUCHER.
</ParamField>

<ParamField body="amount" type="number" required>
  Valor em reais.
</ParamField>

<ParamField body="description" type="string">
  Descrição exibida ao pagador.
</ParamField>

<ParamField body="dueDate" type="string">
  YYYY-MM-DD (boleto; padrão +3 dias).
</ParamField>

<ParamField body="installmentCount" type="number">
  Parcelas 1–21 (cartão crédito).
</ParamField>

<ParamField body="creditCardToken" type="string">
  Token do cartão para cobranças seguintes.
</ParamField>

<ParamField body="creditCardHolderInfo" type="object">
  Titular: name, email, cpfCnpj, postalCode, addressNumber, phone.
</ParamField>

<ParamField body="externalReference" type="string">
  ID do seu sistema.
</ParamField>

<Note>
  Pagamento **único**. Cartão: primeira vez com dados do titular; depois use `creditCardToken`. Para cobrança **recorrente** use `POST /subscriptions/create`.
</Note>


## OpenAPI

````yaml POST /billings/create
openapi: 3.1.0
info:
  title: GoatPay API
  description: >
    API pública merchant da GoatPay. Autenticação via header `X-API-Key:
    gp_live_...`.

    Respostas de sucesso usam o envelope `{ success, message, data, requestId
    }`.

    Campos internos (`accountId`, `metadata`, histórico de entregas de webhook,
    etc.) não são expostos.

    `providerTransactionId` aparece como `referenceId`; `providerInfractionId`
    como `infractionId`.

    Rate limit global: 100 requisições por minuto por API key (HTTP 429). Sem
    chave, limite por IP.
  version: 1.0.0
servers:
  - url: https://api.goatpay.com.br/v1
    description: Produção
security:
  - apiKeyAuth: []
tags:
  - name: pix
    description: >-
      Cobranças PIX (receber), reembolsos de depósito recebido e transferências
      PIX (enviar). Alias legado em payouts/* para envios.
  - name: transfer-internal
    description: Transferências entre contas GoatPay
  - name: transfer-scheduled
    description: Transferências programadas (agendar, repetir ou por saldo)
  - name: crypto
    description: Depósitos e transferências em criptomoeda
  - name: billings
    description: >-
      Cobranças avulsas (pagamento único) — boleto, cartão ou PIX na Conta
      Padrão (PF ou PJ)
  - name: subscriptions
    description: >-
      Assinaturas recorrentes com ciclo fixo — boleto, cartão ou PIX na Conta
      Padrão (PF ou PJ)
  - name: account
    description: Saldo e extrato
  - name: subaccount
    description: Subcontas merchant (carteiras lógicas sob a conta principal)
  - name: meds
    description: Disputas MED
  - name: webhooks
    description: Endpoints de webhook de saída
  - name: payouts
    description: Alias de transfer-pix para saques PIX
  - name: customers
    description: Clientes da loja (CRM)
  - name: products
    description: Produtos e entregas digitais
  - name: coupons
    description: Cupons de desconto para links
  - name: payment-links
    description: Links de pagamento e checkout hospedado
paths:
  /billings/create:
    post:
      tags:
        - billings
      summary: Criar cobrança avulsa
      description: >-
        Pagamento único (boleto, cartão ou PIX). Para recorrência use
        `/subscriptions/create`.
      operationId: createBilling
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBilling'
      responses:
        '200':
          $ref: '#/components/responses/SuccessEnvelope'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    CreateBilling:
      type: object
      required:
        - method
        - amount
        - customer
      properties:
        method:
          type: string
          enum:
            - BOLETO
            - CARD_CREDIT
            - CARD_DEBIT
            - CARD_VOUCHER
            - PIX
        amount:
          type: number
          minimum: 0.01
        customer:
          $ref: '#/components/schemas/PublicCustomer'
        description:
          type: string
        dueDate:
          type: string
          format: date
        installmentCount:
          type: integer
          minimum: 1
          maximum: 21
        cardToken:
          type: string
          description: Token do cartão para reutilização em cobranças futuras.
        creditCard:
          $ref: '#/components/schemas/CreditCard'
        creditCardHolderInfo:
          $ref: '#/components/schemas/CreditCardHolderInfo'
        remoteIp:
          type: string
          description: IP do comprador (obrigatório em CARD_*)
        authorizeOnly:
          type: boolean
        externalReference:
          type: string
    PublicCustomer:
      type: object
      required:
        - name
        - taxId
      properties:
        id:
          type: string
          description: ID no seu sistema (default taxId)
        name:
          type: string
        taxId:
          type: string
          description: CPF/CNPJ somente dígitos
        email:
          type: string
          format: email
        phone:
          type: string
    CreditCard:
      type: object
      required:
        - holderName
        - number
        - expiryMonth
        - expiryYear
        - ccv
      properties:
        holderName:
          type: string
        number:
          type: string
        expiryMonth:
          type: string
        expiryYear:
          type: string
        ccv:
          type: string
    CreditCardHolderInfo:
      type: object
      required:
        - name
        - email
        - cpfCnpj
        - postalCode
        - addressNumber
        - phone
      properties:
        name:
          type: string
        email:
          type: string
          format: email
        cpfCnpj:
          type: string
        postalCode:
          type: string
        addressNumber:
          type: string
        addressComplement:
          type: string
        phone:
          type: string
        mobilePhone:
          type: string
    SuccessEnvelope:
      type: object
      required:
        - success
        - message
        - data
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Operação concluída com sucesso
        data:
          type: object
          additionalProperties: true
        requestId:
          type: string
    ErrorEnvelope:
      type: object
      required:
        - success
        - message
        - error
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Subconta inativa
        error:
          type: object
          properties:
            code:
              type: string
              example: Bad Request
            statusCode:
              type: integer
              example: 400
        requestId:
          type: string
          example: req_abc123
  responses:
    SuccessEnvelope:
      description: Operação concluída.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SuccessEnvelope'
          examples:
            default:
              summary: Sucesso
              value:
                success: true
                message: Operação concluída com sucesso
                data: {}
                requestId: req_abc123
    Forbidden:
      description: Chave sem permissão para este endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Chave `gp_live_...` criada em Integrações → Chaves de API no dashboard.

````