Guides
Getting started

Authentication

App key in the query, scoped OAuth client_credentials token and the errors of each layer.

Every call to BB's APIs goes through three checks, in this order: the app key, the Bearer token and the token's scope. Mimicr reproduces all three, with BB's error bodies.

App key (gw-dev-app-key)

Your sandbox's developer_application_key goes in the query of every call:

text
https://api-pix.bb.mimicr.dev/pix/v2/cob?gw-dev-app-key=<app-key>

It is in credentials.developer_application_key of GET https://api.mimicr.dev/v1/bb. Mimicr also accepts gw-app-key in the query and the gw-dev-app-key, X-Developer-Application-Key and X-Application-Key headers, but BB documents the gw-dev-app-key query: prefer it.

Without an app key, the Pix and Cobranças APIs answer 403:

json
{ "detail": "A chave de aplicacao (AppKey) nao foi informada", "userHelp": "A chave de aplicacao deve ser informada como parametro de consulta (query parameter gw-dev-app-key)", "errorCode": "403", "bbMsg": { "categoria": "SISTEMA", "tipo": "ERRO" } }

With an app key that doesn't exist, detail is "A chave de aplicacao (AppKey) informada e invalida". Pagamentos em Lote and Extratos have their own answers; see Errors.

OAuth token

The token comes from POST /oauth/token with client_credentials: credentials in Basic auth and an application/x-www-form-urlencoded body with grant_type and scope.

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=cob.write cob.read pix.read'
json
{
  "access_token": "TP5asLc750z1MiAUEDCP_k17RulW9So-w4KR15Rqx-2Z1ygrVjmo...",
  "token_type": "Bearer",
  "expires_in": 600,
  "scope": "pix.read cob.write cob.read"
}
  • scope is mandatory and space-separated. Commas, empty or unknown scopes give 400 invalid_scope.
  • The token is opaque and lasts 600 seconds. Don't try to read it; ask for a new one when it expires.
  • The scope in the response comes in BB's order, not the request's.
  • client_id and client_secret follow BB's format (base64 of a JSON); copy them as they are.
  • The token only works with the app key of the same sandbox. A token from another sandbox, expired or tampered with gives 401.
  • Mimicr requires no mTLS, neither for the token nor for the APIs.

See Get a token.

Token errors

StatuserrorWhen
400invalid_requestNo Basic header ("Software cliente não identificado.")
401invalid_clientWrong client_id or client_secret
400unsupported_grant_typegrant_type other than client_credentials
400invalid_scopescope missing, with commas or with an unknown scope
429too_many_requestsMore than 10 tokens in 10 minutes, with the limit on

The body follows RFC 6749: {"error": "...", "error_description": "..."}. A method other than POST answers 405.

Token limit

BB's homologação limits token requests. In Mimicr the limit is optional: turn on tokenRateLimit with PUT https://api.mimicr.dev/v1/bb/homolog (or in the console) and the 11th request within 10 minutes gets 429. Reuse the token until it expires. See Homologação.

Scopes per API

Ask only for the scopes of the routes you call. A token without the route's scope gets 403.

APIScopes
Pix · cobcob.read, cob.write
Pix · cobvcobv.read, cobv.write
Pix · cobv batcheslotecobv.read, lotecobv.write
Pix · locationspayloadlocation.read, payloadlocation.write
Pix · received and refundspix.read, pix.write
Pix · pix-bbpix-bb.read or pix.read
Pix · webhookwebhook.read, webhook.write (GET /webhook also accepts pix.read)
Cobrançascobrancas.boletos-info (queries and retorno de movimento), cobrancas.boletos-requisicao (register, update, write off, boleto Pix), cobrancas.convenio-requisicao (enable and disable baixa operacional)
Pagamentos em Lotepagamentos-lote.lotes-requisicao, pagamentos-lote.lotes-info, pagamentos-lote.transferencias-requisicao, pagamentos-lote.transferencias-info, pagamentos-lote.transferencias-pix-requisicao, pagamentos-lote.transferencias-pix-info, pagamentos-lote.pix-info, pagamentos-lote.boletos-requisicao, pagamentos-lote.boletos-info, pagamentos-lote.guias-codigo-barras-requisicao, pagamentos-lote.guias-codigo-barras-info, pagamentos-lote.pagamentos-guias-sem-codigo-barras-requisicao, pagamentos-lote.pagamentos-guias-sem-codigo-barras-info, pagamentos-lote.pagamentos-codigo-barras-info, pagamentos-lote.pagamentos-info, pagamentos-lote.cancelar-requisicao, pagamentos-lote.devolvidos-info, pagamentos-lote.lancamentos-info
Extratosextrato-info

The Pix Automático scopes (rec.*, solicrec.*, cobr.*, payloadlocationrec.*, webhookrec.*, webhookcobr.*, webhooksolicrec.*) and pagamentos-lote.mtls are accepted in the token, but no route uses them. Each operation's page in the reference states the scope it requires.

Token and scope errors in the APIs

SituationPix and CobrançasPagamentos em LoteExtratos v1
No app key403 JSON "AppKey nao foi informada"403 text Authentication parameters missing400 "A key must be provided…"
Invalid app key403 JSON "AppKey informada e invalida"403 text Authentication failed403 "Application key is not allowed…"
Missing, invalid or expired token401 Bad credentials403 text Authentication failed401 Bad credentials
Token without the scopePix: 403 AcessoNegado; Cobranças: 403 "Application key is not allowed to call this resource method"403 text Authentication failed403 "Application key is not allowed…"

The exact bodies are in Errors.