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çãoMétodoEndpointDescrição
Criar Boleto/PDFPOST/boletosEmite um boleto e retorna o PDF
Obter PDF OriginalGET/boletos/{token}Recupera o PDF com dados originais
Obter PDF AtualizadoGET/boletos/{token}/atualizado/vencimento/{data}Recupera PDF com encargos calculados
Obter Status do RegistroGET/boletos/{token}/registroConsulta se o boleto foi registrado no banco
Alterar VencimentoPUT/boletos/{token}/vencimentoAltera a data de vencimento
Alterar RegistroPUT/boletos/{token}/registroHabilita ou desabilita o registro no banco
Conceder AbatimentoPUT/boletos/{token}/abatimentoConcede abatimento (redução de valor)
Baixar/CancelarPUT/boletos/{token}/baixaCancela 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 │
└─────────────┘
EtapaEndpoints AplicáveisDescrição
CriaçãoPOST /boletos, POST /carnes, POST /batch/boletosCriar boleto individual, carnê (3 por página) ou lote (1 por página)
RegistroGET /boletos/{token}/registro, PUT /boletos/{token}/registroVerificar status ou habilitar/desabilitar registro
Consulta PDFGET /boletos/{token}PDF com dados originais
PDF AtualizadoGET /boletos/{token}/atualizado/vencimento/{data}PDF com juros/multa recalculados
AlteraçãoPUT /boletos/{token}/vencimento, PUT /boletos/{token}/abatimentoAlterar vencimento ou conceder abatimento
CancelamentoPUT /boletos/{token}/baixaBaixar/cancelar o boleto
CNABPOST /arquivos/cnab/remessas, POST /arquivos/cnab/retornosIntegração via arquivo bancário