Guides
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:
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:
{ "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.
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'
{
"access_token": "TP5asLc750z1MiAUEDCP_k17RulW9So-w4KR15Rqx-2Z1ygrVjmo...",
"token_type": "Bearer",
"expires_in": 600,
"scope": "pix.read cob.write cob.read"
}scopeis mandatory and space-separated. Commas, empty or unknown scopes give400 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
scopein the response comes in BB's order, not the request's. client_idandclient_secretfollow 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
| Status | error | When |
|---|---|---|
400 | invalid_request | No Basic header ("Software cliente não identificado.") |
401 | invalid_client | Wrong client_id or client_secret |
400 | unsupported_grant_type | grant_type other than client_credentials |
400 | invalid_scope | scope missing, with commas or with an unknown scope |
429 | too_many_requests | More 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.
| API | Scopes |
|---|---|
| Pix · cob | cob.read, cob.write |
| Pix · cobv | cobv.read, cobv.write |
| Pix · cobv batches | lotecobv.read, lotecobv.write |
| Pix · locations | payloadlocation.read, payloadlocation.write |
| Pix · received and refunds | pix.read, pix.write |
Pix · pix-bb | pix-bb.read or pix.read |
| Pix · webhook | webhook.read, webhook.write (GET /webhook also accepts pix.read) |
| Cobranças | cobrancas.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 Lote | pagamentos-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 |
| Extratos | extrato-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
| Situation | Pix and Cobranças | Pagamentos em Lote | Extratos v1 |
|---|---|---|---|
| No app key | 403 JSON "AppKey nao foi informada" | 403 text Authentication parameters missing | 400 "A key must be provided…" |
| Invalid app key | 403 JSON "AppKey informada e invalida" | 403 text Authentication failed | 403 "Application key is not allowed…" |
| Missing, invalid or expired token | 401 Bad credentials | 403 text Authentication failed | 401 Bad credentials |
| Token without the scope | Pix: 403 AcessoNegado; Cobranças: 403 "Application key is not allowed to call this resource method" | 403 text Authentication failed | 403 "Application key is not allowed…" |
The exact bodies are in Errors.