When to use P2P
The plugin automatically detects when a transfer can be processed as P2P:
| Scenario | Transfer type |
|---|---|
| Recipient’s ISPB different from yours | TED OUT (via SPB) |
| Recipient’s ISPB same as yours | P2P (internal) |
P2P advantages
- Speed: Settlement in less than 2 seconds (compared to minutes for TED).
- Cost: No JD SPB fees, reduced Lerian fees.
- Availability: Works 24/7, without depending on BACEN hours.
Comparison with TED OUT
| Aspect | TED OUT | P2P |
|---|---|---|
| Settlement time | 5-10 minutes | < 2 seconds |
| Operating hours | Mon-Fri 06:30-17:00 | 24/7 |
| Operational cost | Involves JD SPB | Midaz only |
| External dependencies | JD Consultores, BACEN | None |
How it works
The P2P flow is simplified:
- Initiation: client calls
/v1/transfers/initiate - Detection: plugin compares recipient’s ISPB with organization’s ISPB
- Validation: recipient is validated in CRM
- Confirmation: client calls
/v1/transfers/process - Execution: an atomic transaction is created in Midaz (debit + credit)
- Completion: transfer completes immediately
Timeline
Initiating a P2P transfer
The process is identical to TED OUT. The plugin automatically detects it’s P2P.
Step 1: Initiate
Response
estimatedCompletionAt is practically immediate (2 seconds), indicating it will be processed as P2P.
Step 2: Confirm
Response
COMPLETED — the transfer is instant.
P2P states
The state cycle is simpler than TED OUT:
| State | Description |
|---|---|
CREATED | Transfer created |
PROCESSING | Executing transaction in Midaz |
COMPLETED | Transfer completed |
FAILED | Midaz error (rare) |
CANCELLED | Cancelled before processing |
CREATED to COMPLETED occurs in less than 2 seconds.
Query P2P transfer
The
type field is P2P and there’s no controlNumber (as it didn’t go through JD SPB).P2P fees
Fees for P2P transfers are configured separately from TED fees:
| Configuration | Description |
|---|---|
p2p_fee_enabled | Enables fee charging for P2P |
p2p_fee_type | Fee type (flat, percentage, tiered) |
24/7 operation
Unlike TED, P2P transfers can be made at any time:
- Business days: works normally
- Weekends: works normally
- Holidays: works normally
- Late night: works normally
There’s no operating hours validation for P2P, as the operation doesn’t depend on SPB.
Recipient validation
The plugin validates the recipient in two ways:
By bank details
If the recipient is provided with ISPB, branch, and account:- Checks if ISPB matches the organization’s
- Searches for the account in CRM by bank details
- Validates if the document matches
By accountId (optimized)
If you already know the recipient’s MidazaccountId, you can use more direct validation through CRM.
Error handling
Recipient not found (404)
Insufficient balance (422)
Same source and destination account (400)
Common use cases
| Case | Description |
|---|---|
| Transfer between users | Client A transfers to Client B |
| Movement between own accounts | Client moves between checking and savings |
| Internal payment | Company pays employee at same institution |
| Payment split | Distribution of amounts across multiple accounts |
Atomicity
P2P transfers are atomic in Midaz:
- Debit and credit occur in the same transaction
- If any part fails, the entire operation is reverted
- There’s no intermediate state where money “disappears”
Reduced partial-failure risk: The atomic Midaz transaction ensures that debit and credit either both succeed or both fail, preventing partial transfers. However, duplicate transfer submissions (e.g., retries or double-clicks) still require idempotency controls — always use the
X-Idempotency-Key header as described in Best practices.
