Pular para o conteúdo

Gerar Boletos via API REST

O recurso Boletos é o principal endpoint da API Boleto Cloud. Através dele você pode criar boletos, obter PDFs, consultar status de registro, alterar vencimento e realizar baixa/cancelamento.

Panorama dos endpoints de Boletos

https://sandbox.boletocloud.com/api/v1/boletos

A tabela abaixo resume todas as operações disponíveis para o recurso de boletos:

Operação Método Endpoint Descrição
Criar Boleto/PDF POST /boletos Emite um boleto e retorna o PDF
Obter PDF Original GET /boletos/{token} Recupera o PDF com dados originais
Obter PDF Atualizado GET /boletos/{token}/atualizado/vencimento/{data} Recupera PDF com encargos calculados
Obter Status do Registro GET /boletos/{token}/registro Consulta se o boleto foi registrado no banco
Alterar Vencimento PUT /boletos/{token}/vencimento Altera a data de vencimento
Alterar Registro PUT /boletos/{token}/registro Habilita ou desabilita o registro no banco
Conceder Abatimento PUT /boletos/{token}/abatimento Concede abatimento (redução de valor)
Baixar/Cancelar PUT /boletos/{token}/baixa Cancela o boleto na cobrança

O diagrama abaixo mostra os estados do boleto e quais endpoints da API se aplicam em cada etapa:

┌─────────────────────────────────────────────────────────────────────────────────┐
│ CRIAÇÃO DO BOLETO │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ POST /boletos │ │ POST /carnes │ │ POST /batch/ │ │
│ │ (individual) │ │ (3 por página) │ │ boletos │ │
│ │ │ │ │ │ (1 por página) │ │
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
│ └────────────────────┼────────────────────┘ │
│ ▼ │
└────────────────────────────[ CRIADO ]───────────────────────────────────────────┘
(envio automático ou via CNAB remessa)
┌─────────────────────────[ REGISTRO PENDENTE ]───────────────────────────────────┐
│ │
│ Endpoints disponíveis: │
│ • GET /boletos/{token} → Obter PDF original │
│ • GET /boletos/{token}/registro → Consultar status do registro │
│ • PUT /boletos/{token}/registro → Habilitar/desabilitar registro │
│ • PUT /boletos/{token}/baixa → Cancelar antes do registro │
│ │
└─────────────────────────────────┬───────────────────────────────────────────────┘
┌────────────────┴────────────────┐
▼ ▼
┌────────[ REGISTRADO / ATIVO ]────────┐ ┌────────[ REJEITADO ]────────┐
│ │ │ │
│ Endpoints disponíveis: │ │ Ação: Corrigir dados e │
│ • GET /boletos/{token} │ │ criar novo boleto │
│ • GET /boletos/{token}/registro │ │ │
│ • GET /boletos/{token}/atualizado/ │ └─────────────────────────────┘
│ vencimento/{data} │
│ • PUT /boletos/{token}/vencimento │
│ • PUT /boletos/{token}/abatimento │
│ • PUT /boletos/{token}/baixa │
│ │
└──────────────────┬───────────────────┘
┌────────────┼────────────┬─────────────────┐
▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌───────────┐ ┌─────────────────┐
│ PAGO │ │ VENCIDO │ │ BAIXADO │ │ ALTERADO │
│ │ │ │ │ CANCELADO │ │ (vencimento) │
└──────────┘ └────┬─────┘ └───────────┘ └────────┬────────┘
│ │
│ (permanece ATIVO com │
│ nova data) │
│ │
▼ │
┌─────────────┐ │
│ PAGO ou │◄────────────────────────┘
│ BAIXADO │
└─────────────┘
Etapa Endpoints Aplicáveis Descrição
Criação POST /boletos, POST /carnes, POST /batch/boletos Criar boleto individual, carnê (3 por página) ou lote (1 por página)
Registro GET /boletos/{token}/registro, PUT /boletos/{token}/registro Verificar status ou habilitar/desabilitar registro
Consulta PDF GET /boletos/{token} PDF com dados originais
PDF Atualizado GET /boletos/{token}/atualizado/vencimento/{data} PDF com juros/multa recalculados
Alteração PUT /boletos/{token}/vencimento, PUT /boletos/{token}/abatimento Alterar vencimento ou conceder abatimento
Cancelamento PUT /boletos/{token}/baixa Baixar/cancelar o boleto
CNAB POST /arquivos/cnab/remessas, POST /arquivos/cnab/retornos Integração via arquivo bancário