Authentication
LB Pay API v2 uses OAuth 2.0 Client Credentials with asymmetric keys and DPoP. Your integration keeps an EC P-256 private key and registers only the public key with LB Pay. LB Pay stores no shared secret for the credential.
The private key signs two short-lived JWTs:
- a
client_assertionused to request the access token; - a fresh DPoP proof bound to every API request.
Set up your credential
- Generate an EC P-256 key pair.
- Store the private key in a secrets manager or HSM. Never upload or send it to LB Pay.
- Register the public key in the Customer Portal.
- Record the returned
client_idandkid. - Configure the credential's allowed source IP addresses.
Use separate key pairs for staging and production. A private key must never be embedded in frontend code, committed to source control or written to application logs.
Request an access token
Create a client_assertion signed with ES256 and a DPoP proof bound to the token endpoint. The
request uses application/x-www-form-urlencoded:
curl --request POST \
--url 'https://api.sdb.lbpay.com.br/v2/oauth/token' \
--header 'content-type: application/x-www-form-urlencoded' \
--header 'DPoP: <TOKEN_REQUEST_DPOP_PROOF>' \
--data-urlencode 'client_id=<CLIENT_ID>' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' \
--data-urlencode 'client_assertion=<SIGNED_CLIENT_ASSERTION>'
The access token is valid for 60 seconds and is bound to the same public key used in the DPoP proof. See Tokens for complete examples in the supported languages.
Sign every API request
Every call to /v2/* must include both headers:
Authorization: DPoP <access_token>
DPoP: <fresh_request_bound_proof>
The proof must be generated specifically for the request method, URL, query and exact body bytes. Never reuse or cache a proof. See Signing requests for the required claims and complete code examples.
Token renewal and errors
Cache the token only until shortly before its expiry and ensure concurrent callers do not each request a new token. Generate a new DPoP proof for every use of the cached token.
A failed request may indicate an expired token, a stale proof, a replay, a body/query mismatch, an incorrect key or a source IP outside the allowlist. Do not retry indefinitely: refresh the token once when appropriate, create a new proof and surface persistent failures.
Do not log the private key, client_assertion, access token, DPoP proof or complete authentication
request. Log only the request id, route, status and safe error code.
See Authentication errors for the complete error map.
Next step
Run the Quickstart to make your first transaction end to end.