Guides
Deposit
Credit an account with a dynamic Pix QR code, track it to COMPLETED and refund it if needed.
A deposit credits the account when the payer pays a dynamic Pix QR code. You create a quote, create the deposit with the payer and get the QR to show them. The payment comes in as BRL and can be credited as BRL or converted to USDT or USDC through the quote.
Prerequisites
- An
ACTIVEaccount (see Open an account). In Mimicr, an account in any other state answers422 ACCOUNT_NOT_ACTIVE. - A valid token (see Authentication).
1. Create the quote
sourceAsset is what the payer pays (always BRL for Pix) and targetAsset is what the account receives.
curl --request POST \
--url https://trace.mimicr.dev/v1/quotes \
--header 'Authorization: Bearer <token>' \
--header 'X-Idempotency-Key: <uuid>' \
--header 'Content-Type: application/json' \
--data '{
"accountId": "<account-id>",
"sourceAsset": "BRL",
"targetAsset": "BRL",
"sourceAmount": "500.00"
}'{
"id": "262a1185-5206-4e2e-8cc8-643e266e915c",
"sourceAmount": { "value": "500.00", "asset": "BRL", "decimals": 2 },
"targetAmount": { "value": "500.00", "asset": "BRL", "decimals": 2 },
"effectiveRate": { "base": "BRL", "quote": "BRL", "value": "1.00" },
"expiresAt": "2026-11-05T20:11:12Z"
}The quote is valid for 30 seconds and serves a single operation. Send sourceAmount or targetAmount, never both. More on quotes in Swap. Reference: Create a quote.
2. Create the deposit
curl --request POST \
--url https://trace.mimicr.dev/v1/operations/deposits \
--header 'Authorization: Bearer <token>' \
--header 'X-Idempotency-Key: <uuid>' \
--header 'Content-Type: application/json' \
--data '{
"externalId": "order-2026-0043",
"accountId": "<account-id>",
"quoteId": "<quote-id>",
"fundingInstruction": { "rail": "PIX_DYNAMIC_QR_CODE" },
"payer": {
"identificationDocument": { "type": "CPF", "value": "52998224725" },
"firstName": "Maria",
"lastName": "Silva",
"address": { "city": "São Paulo" }
}
}'The response is 201 with the operation in REQUESTED and intent.fundingInstruction: null, because the QR is generated asynchronously. OPERATION_REQUESTED fires.
| Error | When |
|---|---|
422 MISSING_DEPOSIT_PAYER | No payer |
400 INVALID_DATA (INVALID_ENUM) | rail other than PIX_DYNAMIC_QR_CODE |
422 RAIL_NOT_AVAILABLE | The quote's sourceAsset is not BRL |
422 QUOTE_EXPIRED or QUOTE_ALREADY_CONSUMED | Quote expired or already used |
404 RESOURCE_NOT_FOUND | Unknown account or quote |
Reference: Create a deposit.
3. Show the QR code to the payer
About 1 second later the operation moves to PROCESSING and OPERATION_PROCESSING fires once. That event means QR generation was queued; it is not the "QR ready" signal. Poll the operation until intent.fundingInstruction is filled in:
curl --url https://trace.mimicr.dev/v1/operations/<operation-id> \ --header 'Authorization: Bearer <token>'
"intent": {
"type": "DEPOSIT",
"fundingInstruction": {
"rail": "PIX_DYNAMIC_QR_CODE",
"qrCode": "00020101021226930014br.gov.bcb.pix2571qr.sandbox.tracefinance.com/pix/v2/...",
"expiresAt": "2026-11-06T20:12:22Z"
}
}qrCode is an EMV BR Code (Pix copy-and-paste) and expires in 24 hours. The amount paid must be the quote's sourceAmount.
4. Track it to completion
In Mimicr the simulated payer pays about 4 seconds after the QR. The operation becomes COMPLETED with a CREDIT transaction of targetAmount (its id is the Pix E2E id) and OPERATION_COMPLETED fires. If the QR expires, it becomes FAILED with currentState.reason and OPERATION_FAILED. Both events carry the same payload as OPERATION_REQUESTED, with the new currentState.
The amounts 8.00 and 9.00 change the outcome; see Testing in the sandbox.
Unrequested deposits
A Pix sent straight to the account's key (see the funding instructions in Open an account) becomes a COMPLETED deposit nobody requested, with quote: null and externalId: null. Only OPERATION_COMPLETED fires. In Mimicr, simulate it like this:
npx mimicr action trace account.receive_pix accountId=<account-id> amount=1000.00 payerName="Test payer" npx mimicr action trace account.receive_crypto accountId=<account-id> asset=USDT amount=250.000000
It is also the quickest way to fund a test account.
Refund a deposit
Only COMPLETED deposits can be refunded.
curl --request POST \
--url https://trace.mimicr.dev/v1/operations/<operation-id>/refund \
--header 'Authorization: Bearer <token>' \
--header 'X-Idempotency-Key: <uuid>' \
--header 'Content-Type: application/json' \
--data '{
"motive": { "code": "CUSTOMER_REQUEST", "message": "Customer asked for the money back" }
}'The response is 202 with the operation in REFUNDING, the refund{motive, requestedAt} field and the OPERATION_REFUNDING webhook. motive.code accepts CUSTOMER_REQUEST or FRAUD. About 3 seconds later the operation becomes REFUNDED with a DEBIT transaction (Mimicr's choice) and OPERATION_REFUNDED. If the account no longer holds the amount, the refund stays REFUNDING.
Error (422 OPERATION_NOT_REFUNDABLE) | When |
|---|---|
| "Only deposit operations can be refunded" | Not a deposit |
| "Deposit must be in COMPLETED status to be refunded" | Deposit not completed yet |
| "Deposit has already been refunded" | Already refunded |
Reference: Refund a deposit.
Test the other side
Turn autoPayDeposits off so the QR waits, then decide as the payer:
curl --request POST \
--url https://api.mimicr.dev/v1/trace/actions/deposit.pay \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "operationId": "<operation-id>" }'deposit.pay: the payer pays now (also works for the8.00amount).deposit.expire: the QR expires now (FAILED,QR_CODE_EXPIRED).operation.settle: settles aREFUNDINGrefund whenautoSettleOperationsis off.
To wait in a test: npx mimicr wait trace delivery event=OPERATION_COMPLETED ref=<operation-id>.
Next steps
- Swap: convert the balance.
- Withdrawal: send funds to a beneficiary.