Run Each Customer in a Sub-account, Credit the Main
Use this when each of your customers has a sub-account, but you want the money to end up in one pool: the main account. The operation is created for the customer's sub-account, so the quote, the limits, the KYC and the ticket list stay per customer, and the resulting funds are credited to the main account.
The most common case is a PIX deposit: the customer pays a PIX that belongs to their sub-account's operation, and the tokens land on the main account's balance.
Who is who
Two fields decide this, and they are independent:
subAccountIddecides who owns the operation: whose quote it is, whose limits and KYC apply, and whose ticket list shows it. It goes on the quote and on the ticket.ticketBlockchainOutput.beneficiaryWalletIddecides where the funds end up. For an internal output it is an account ID, never a wallet address.
You need two IDs. The sub-account's is the subAccountId returned when you created it (or listed by GET /v2/account/sub-accounts). The main account's is the top-level id of GET /v2/account/account-info called without subAccountId.
Both accounts must be yours, inside the same main account. An account ID from outside it is refused.
Give the access that creates these tickets the manageAssets permission. Crediting another account is a transfer between accounts, and without that permission the ticket is refused with 403. See Accesses management.
Example: a PIX deposit that lands on the main account
1. Quote. The usual PIX deposit, with the sub-account's subAccountId. No blockchainSendMethod: nothing is sent on-chain.
2. Ticket. The same subAccountId in the query string, and the main account's ID as the destination:
{
"quoteToken": "eyJ...",
"ticketBlockchainOutput": {
"beneficiaryWalletId": "MAIN_ACCOUNT_ID"
}
}
The response carries the brCode the payer must pay, its expiration, and the ticket id, as in any PIX deposit.
3. Confirm. Read the ticket with the sub-account's subAccountId until status is PAID, or wait for the TICKET-COMPLETE webhook:
Without subAccountId, the read returns 404: the ticket belongs to the sub-account.
Other operations that credit the main
The same two fields work for any operation whose output is internal:
- Sweep a sub-account's balance to the main account. Quote
INTERNALtoINTERNALin the same token withblockchainSendMethod=PERMIT. The full request is in Move Funds Between Your Accounts. - Credit your own sub-account instead. Send the zeroed UUID
00000000-0000-0000-0000-000000000000asbeneficiaryWalletId: it credits the account that runs the operation, here the sub-account insubAccountId.
Which IDs go where
| You want the funds on | subAccountId (quote and ticket) | beneficiaryWalletId |
|---|---|---|
| The main account | the sub-account ID | the main account ID |
| The sub-account itself | the sub-account ID | 00000000-0000-0000-0000-000000000000 |
Errors you may see
| Error | Cause |
|---|---|
404 NotFoundError: subAccountId not found | The subAccountId is not one of your sub-accounts. |
400 InvalidFieldError: subAccountId is invalid | The subAccountId is not a valid ID. |
400 InvalidFieldError: quoteToken is invalid | The quote and the ticket don't carry the same subAccountId. |
400 InvalidFieldError: ticketBlockchainOutput.beneficiaryWalletId is invalid | The destination is not your main account or one of its sub-accounts, or it is a hidden sub-account. |
403 ForbiddenError: ManageAssets permission is required to transfer between accounts | The access has no manageAssets and the output credits another account. |
More on owners and destinations in Accounts and Sub-accounts.