Authentication Guide
This guide explains step by step how to obtain an access token to use the CorpX PIX API.
Overview
The CorpX API uses OAuth 2.0 with the Client Credentials flow for authentication. You will need your credentials (client_id and client_secret) to obtain a valid access token.
Prerequisites
Before you begin, make sure you have:
- Client ID - Your unique client identifier
- Client Secret - Secret key for authentication
- X-Tenant-Id - Your tenant identifier (e.g.,
tenant-suaempresa)
If you don’t have credentials yet, contact our support team.
Environments
Step 1: Request an Access Token
Request
Parameters
Success Response (200 OK)
The access_token lasts 5 minutes (expires_in: 300) and must be reused
for every call until it expires. Minting a new token on every request is
forbidden: it exhausts Cognito, slows your integration down, and can get
token issuance refused.
Cache the token on your side. Only call /oauth2/token again when about
60 seconds remain on expires_in, or when the API answers 403 for an
expired token. Do not hardcode the TTL — read expires_in from the response.
Error Response (401 Unauthorized)
Step 2: Use the Token in Requests
With the obtained token, include it in the Authorization header of all API requests.
Example: Check Balance
Required Headers
Step 3: Renew the Token
The token expires after the time indicated in expires_in (5 minutes on
current credentials). Reusing the same token until near that deadline is
mandatory:
- Store the token in cache with the
expires_inthat came in the response - Renew before expiration — with a 5-minute TTL, renewing in the last minute is already tight
- Handle the 403 for expired tokens — the API answers
403 Forbidden, not401; when you get it, obtain a new token and retry the call
Automatic Renewal Example (Bash)
Full Examples in Different Languages
Python
Node.js
Credential scopes
Every credential (client_id/client_secret) carries a set of scopes that
defines exactly what it can do. You pick the scopes when creating the credential
in the backoffice panel (API Credentials, available to users with the tenant
manager profile).
Scopes you grant yourself:
kyc.read is the only query scope not covered by read: since it delivers
customer faces, it has to be granted explicitly. The endpoint also requires the
kyc_artifacts feature enabled for the tenant — see
Evidence files.
Every scope already queries its own domain. That is what makes an
inflow-only credential possible: grant qrcode.manage alone and it issues QR
codes and sees whether they were paid without access to the balance and the
statement. Only check read when the credential genuinely needs the
account-wide queries.
Scopes that move money are issued by CorpX, never from the panel:
Requesting one of these from the panel is refused with
403 scope_not_self_service — contact support and we issue the credential.
Delegated credentials
The credentials.delegate scope is CorpX-only: the internet-banking master
issues children bound to one account. If you received that child (IB API
feature), this BaaS section is not your guide — go to
Internet banking.
Per-account restriction
A credential can be restricted to specific accounts of your tenant. That is
how you give a subsystem a credential that only issues QR codes for one account.
Calls to accounts outside the set answer 403 forbidden — the generic
permission error, not insufficient_scope: the scope is there, the account is
not. The message deliberately does not distinguish a nonexistent account from
one outside the set.
Combining both dimensions: qrcode.manage plus a single account yields a
credential that charges by QR code on that account and sees nothing else —
neither its balance nor the tenant’s other accounts.
When a scope is missing
If the credential lacks the scope for the route, the API answers 403 Forbidden naming what is missing:
Credentials issued before granular scopes keep working unchanged: they retain
the coarse pair (api2/read api2/write) and full access.
Access suspended by a pendency
When there is an open pendency with CorpX, a tenant’s access can be suspended
temporarily. Suspension does not invalidate your credential: the same
client_id/client_secret keeps issuing tokens normally, and the refusal comes
on the API call.
Two things worth knowing:
- Money does not stop. Incoming PIX is still credited and you still receive the webhooks for those events. What suspension blocks is starting new operations.
- Reactivation is immediate. Once the pendency is cleared, access returns on the next call — no new credential and no new token needed.
The reason for the pendency is not in the error body: it shows up in the backoffice panel, for your team’s operators.
Common Errors
Best Practices
- Reuse the token — one token per call is forbidden
- Never expose the
client_secretin client-side code (frontend) - Use environment variables to store credentials
- Monitor expiration and renew tokens proactively
- Use HTTPS for all communications
Next Steps
Now that you know how to authenticate, explore the other guides:
- Dynamic QR Code Guide - Generate PIX charges
- Cash Out Guide - Make PIX transfers
- Refund Guide - Request reversals