Guides
Cobranças (boletos)

Register a boleto

Register a boleto with the Cobranças v2 API, with or without Pix, and see what comes back and what happens next.

The Cobranças API registers carteira 17 boletos under your account's collection convênio. One boleto per request; registration is synchronous and the boleto can be paid right away.

Prerequisites

  • A token with the cobrancas.boletos-requisicao scope (and cobrancas.boletos-info to query). See Authentication.
  • The application key in gw-dev-app-key on every call.
  • The sandbox's convênio or BB's homologação convênio, 3128557, with carteira 17 and variation 35. In Mimicr both are accepted as yours (see Homologação).

1. Get a token

bash
curl --request POST \
  --url https://oauth.bb.mimicr.dev/oauth/token \
  --header 'Authorization: Basic <base64(client_id:client_secret)>' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'scope=cobrancas.boletos-requisicao cobrancas.boletos-info'

The token is opaque and lasts 600 seconds.

2. Register the boleto

bash
curl --request POST \
  --url 'https://bb.mimicr.dev/cobrancas/v2/boletos?gw-dev-app-key=<app-key>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "numeroConvenio": 3128557,
    "numeroCarteira": 17,
    "numeroVariacaoCarteira": 35,
    "codigoModalidade": 1,
    "dataEmissao": "23.10.2026",
    "dataVencimento": "12.11.2026",
    "valorOriginal": 150,
    "codigoAceite": "A",
    "codigoTipoTitulo": 2,
    "descricaoTipoTitulo": "DM",
    "indicadorPermissaoRecebimentoParcial": "N",
    "numeroTituloBeneficiario": "12501",
    "numeroTituloCliente": "00031285570031443497",
    "desconto": { "tipo": 1, "dataExpiracao": "02.11.2026", "valor": 5 },
    "jurosMora": { "tipo": 2, "porcentagem": 1 },
    "multa": { "tipo": 2, "data": "13.11.2026", "porcentagem": 2 },
    "pagador": {
      "tipoInscricao": 1,
      "numeroInscricao": "96050176876",
      "nome": "VALERIO DE AGUIAR ZORZATO",
      "endereco": "RUA TESTE",
      "cep": 74715715,
      "cidade": "GOIANIA",
      "bairro": "CENTRO",
      "uf": "GO"
    },
    "indicadorPix": "S"
  }'

The response is 201:

json
{
  "beneficiario": { "agencia": 3301, "contaCorrente": 86319, "tipoEndereco": 1, "logradouro": "SETOR BANCARIO SUL QUADRA 1", "bairro": "ASA SUL", "cidade": "BRASILIA", "codigoCidade": 2000, "uf": "DF", "cep": 70073900, "indicadorComprovacao": "" },
  "qrCode": {
    "url": "qrcodepix.bb.mimicr.dev/pix/v2/cobv/69bd55c0-bf68-4ed8-b0a0-fe4450b03ae7",
    "txId": "BOLETO31285570031443497DATA23102026",
    "emv": "00020101021226940014br.gov.bcb.pix2572qrcodepix.bb.mimicr.dev/pix/v2/cobv/69bd55c0-…6304FB60"
  },
  "numero": "00031285570031443497",
  "numeroCarteira": 17,
  "numeroVariacaoCarteira": 35,
  "codigoCliente": 3128557,
  "linhaDigitavel": "00190000090312855700031443497172516280000015000",
  "codigoBarraNumerico": "00195162800000150000000003128557003144349717",
  "numeroContratoCobranca": 19898773,
  "urlImagemBoleto": "https://boleto.apps.bb.com.br/segunda-via/00190000090312855700031443497172516280000015000/96050176876/0",
  "observacao": ""
}

Keep the numero (nosso número): it is the {id} of every other operation. Reference: Register a boleto.

Field rules

FieldRule
dataEmissao, dataVencimentodd.mm.aaaa. Issue date up to today; due date not before registration
valorOriginalNumber in reais (150, 109.9), greater than discounts + abatimento
numeroTituloClienteNosso número: 000 + convênio (7) + control (10). In Mimicr, without it the bank numbers it
codigoAceiteA or N
codigoTipoTituloKind: 1 to 25, 31, 32, 33 or 99 (2 duplicata mercantil, 4 duplicata de serviço, 17 recibo, 99 other…)
desconto, segundoDesconto, terceiroDescontoIncreasing dates before the due date; the 2nd and 3rd inherit the 1st's tipo
jurosMora.tipo0 waive, 1 amount per day, 2 monthly rate, 3 exempt
multadata after the due date; 1 fixed amount, 2 percentage
pagador.numeroInscricaoValid CPF or CNPJ (string; alphanumeric CNPJ accepted)
indicadorPixS creates the Pix QR Code (see Boleto with Pix)

Numbers never start with zero in the JSON: CEP 74715715, agência 452.

Common errors

All in the {"erros":[{codigo, versao, mensagem, providencia, ocorrencia}]} shape:

HTTPcodigoWhen
4004874915Nosso número already used (providencia: "Informar outro Nosso Número.")
4004500431 / 4500947Invalid payer CPF or CNPJ
4004432632Convênio, carteira or variation not owned by the sandbox
4004014800Due date in the past or before the issue date
4004010933, 4014727, 4014711, 4012111Missing due date, carteira, variation or kind; 4012111 also for a kind outside BB's table (in Mimicr)
400999Body is not JSON
json
{ "erros": [{ "codigo": "4874915", "versao": "1", "mensagem": "Nosso Número já incluído anteriormente.", "providencia": "Informar outro Nosso Número.", "ocorrencia": "meO5nvkRVesPc5HWJsTqIsR0" }] }

More in Errors.

What happens next

  • The boleto starts open: codigoEstadoTituloCobranca 1 (NORMAL), in the indicadorSituacao=A list.
  • When the payer pays, it moves to 6 (LIQUIDADO), the amount shows up in the statement and BB sends the baixa operacional webhook.
  • If nobody pays by the limit date (due date + numeroDiasLimiteRecebimento, or 360 days in Mimicr), the bank writes it off for expiry (state 7).

Pay the boleto in tests

Use BB's homologação simulator with the typeable line:

bash
curl --request POST \
  --url 'https://bb.mimicr.dev/testes-portal-desenvolvedor/v1/boletos-cobranca/00190000090312855700031443497172516280000015000/pagar?gw-app-key=95cad3f03fd9013a9d15005056825665'
json
{ "mensagem": "Boleto pago com sucesso." }

Or Mimicr's control action, which picks the bank, channel and amount:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/bb/actions/boleto.pay \
  --header 'Authorization: Bearer mk_…' \
  --header 'Content-Type: application/json' \
  --data '{ "nossoNumero": "00031285570031443497", "banco": "outro" }'

Reference: Pay a boleto (simulator). Next: Manage boletos.