Activation
Overview
PIX Bacen mode has two independent parts:
- BACEN Endpoints: endpoints compatible with the Central Bank specification. They are available to any authenticated account, with no activation: just use the same Bearer token as the standard API.
- V2 Webhooks: notification format with the
{type, data}envelope. It is chosen per webhook (per registered URL), by the client.
Switching a webhook to V2 is a breaking change for whoever consumes that URL: the payload gets a completely different format. Update your handler before switching the version.
How to Enable V2 Webhooks
1. Via the dashboard
In the FyPay Dashboard, go to Settings → Webhooks, register (or re-register) the URL for the desired event and, under Payload version, select PIX BACEN (V2). The version is configured only in the dashboard.
2. Test the integration
After switching the version:
- Create a test charge via
PUT /api/cob/:txid - Check that the V2 webhook arrived correctly
- Confirm that your application processed the new format
What changes?
Endpoints
The BACEN endpoints are equivalent to the following standard API operations:
| Standard API | PIX Bacen API |
|---|---|
POST /api/pix/cash-in | PUT /api/cob/:txid |
POST /api/pix/cash-out | POST /api/dict/pix |
POST /api/pix/refund-in/:id | PUT /api/pix/:e2eid/devolucao/:id |
GET /api/balance | GET /api/accounts/balances |
The standard API endpoints keep working. You can use both APIs simultaneously.
Webhooks
The webhook format changes completely:
{
"event": "CashIn",
"status": "CONFIRMED",
"transactionId": "12345",
"movementType": "CREDIT",
"originalAmount": 100.00,
"finalAmount": 100.00,
"counterpart": {
"name": "João Silva",
"document": "123.xxx.xxx-xx"
}
}{
"type": "RECEIVE",
"data": {
"id": 123,
"txId": "abc123",
"status": "LIQUIDATED",
"payment": {
"amount": "100.00",
"currency": "BRL"
},
"creditDebitType": "CREDIT",
"debtorAccount": {
"name": "João Silva",
"document": "123.xxx.xxx-xx"
},
"creditorAccount": {...}
}
}Key differences in Webhooks
| Aspect | V1 | V2 |
|---|---|---|
| Structure | Fields at the root | {type, data} envelope |
| Event type | event: "CashIn" | type: "RECEIVE" |
| Success status | CONFIRMED | LIQUIDATED |
| Refund status | CONFIRMED | REFUNDED |
| Values | number (100.00) | string ("100.00") |
| Counterparty | counterpart | debtorAccount / creditorAccount |
Preparing your integration
1. Update the webhook handler
// BEFORE (V1)
function handleWebhookV1(payload: any) {
if (payload.event === 'CashIn' && payload.status === 'CONFIRMED') {
processPayment(payload.transactionId, payload.finalAmount);
}
}
// AFTER (V2)
function handleWebhookV2(payload: any) {
if (payload.type === 'RECEIVE' && payload.data.status === 'LIQUIDATED') {
const amount = parseFloat(payload.data.payment.amount);
processPayment(payload.data.id, amount);
}
}2. Update the types/interfaces
// V2 Types
interface WebhookV2Payload {
type: 'RECEIVE' | 'TRANSFER' | 'REFUND';
data: WebhookV2Data;
}
interface WebhookV2Data {
id: number | null;
txId: string | null;
status: 'PENDING' | 'LIQUIDATED' | 'REFUNDED' | 'ERROR';
payment: {
amount: string; // Note: string, not number!
currency: string;
};
creditDebitType: 'CREDIT' | 'DEBIT';
debtorAccount: AccountInfo;
creditorAccount: AccountInfo;
endToEndId: string | null;
refunds: RefundInfo[];
// ... other fields
}3. Test with an additional URL
Before switching the version of the URLs already in use:
- Register an additional test URL on the same event with the PIX BACEN version (each event accepts up to 3 URLs and each URL has its own version)
- Run full Cash-In, Cash-Out, and Refund tests
- Validate that all webhooks are processed correctly
Rollback
The version can be switched back to V1 at any time, in the dashboard (Settings → Webhooks), by selecting the Standard version (V1) on the URL.
We recommend supporting both versions during the transition:
function handleWebhook(payload: any) {
// Detect version by format
if (payload.type && payload.data) {
return handleWebhookV2(payload);
} else if (payload.event) {
return handleWebhookV1(payload);
}
throw new Error('Unknown webhook format');
}Activation Checklist
Update your code to process the {type, data} envelope format
Register a test URL with the PIX BACEN version and run full tests
Test: RECEIVE, TRANSFER, REFUND with status LIQUIDATED, REFUNDED, and ERROR
Under Settings → Webhooks, select the PIX BACEN payload version for the desired URLs
Follow the first transactions after the switch to make sure everything works