Guides
Quickstart
Activate the sandbox, get credentials and make a Pix deposit all the way to the OPERATION_COMPLETED webhook.
This guide takes a few minutes: you activate the simulator, get a token, create an account that is already active, quote and deposit BRL, and wait for the completion webhook.
Prerequisites
- A Mimicr organization and a write API key (
mk_…), created in the organization settings, "API keys" tab. - curl, or any HTTP client, and Node 18+ if you want to use the CLI.
- A public HTTPS URL to receive webhooks (optional, but needed in step 4).
1. Activate the Trace Finance sandbox
In the console, open your organization at https://app.mimicr.dev, go to Trace Finance and activate it. Or use the control API:
curl --request POST \ --url https://api.mimicr.dev/v1/trace/activate \ --header 'Authorization: Bearer mk_...'
Each organization has one Trace sandbox, which stands for one Trace customer with its own credentials. If it is already active, the call answers 409 trace_already_active.
2. Get the credentials
curl --url https://api.mimicr.dev/v1/trace \ --header 'Authorization: Bearer mk_...'
{
"active": true,
"host": "https://trace.mimicr.dev",
"token_url": "https://trace.mimicr.dev/v1/oauth/client/token",
"credentials": {
"client_id": "4324624c-c4bd-4edd-aa2a-7d0b6f885b74",
"client_secret": "VZ9YzjIm2GbWObIXNSc-lmo-EKPmWEgl"
},
"rates": { "USDT": "5.00", "USDC": "5.00" },
"homolog": { "autoApproveAccounts": true, "autoPayDeposits": true, "autoSettleOperations": true, "autoReviewInstructions": true }
}With the CLI: run npx mimicr login mk_... once, then npx mimicr status trace.
3. Get a token
curl --request POST \
--url https://trace.mimicr.dev/v1/oauth/client/token \
--header 'Content-Type: application/json' \
--data '{
"clientId": "<client_id>",
"clientSecret": "<client_secret>"
}'{
"accessToken": "eyJhbGciOiJSUzI1NiIs...",
"tokenType": "Bearer",
"expiresIn": 82800
}Send accessToken in the Authorization: Bearer <token> header of every following call. See Authentication.
4. Subscribe to webhooks
curl --request POST \
--url https://trace.mimicr.dev/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://your-server.example.com/trace-webhooks",
"includeAll": true,
"allowRetry": true
}'Mimicr only records deliveries for events that some subscription covers. Details in Webhooks.
5. Create an active account
Opening a real account goes through documents, UBOs and review (see Open an account). To test operations right away, ask Mimicr for an ACTIVE account with BRL, USDT and USDC:
curl --request POST \
--url https://api.mimicr.dev/v1/trace/actions/account.create_active \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{}'{
"ok": true,
"action": "account.create_active",
"message": "Conta 4383a293-dbff-4585-bd8c-ee73ab1a14e3 ACTIVE.",
"data": { "id": "4383a293-dbff-4585-bd8c-ee73ab1a14e3", "status": "ACTIVE", "assets": ["BRL:ACTIVE", "USDT:ACTIVE", "USDC:ACTIVE"] }
}Or: npx mimicr action trace account.create_active.
6. Quote and create the deposit
A quote is valid for 30 seconds, so create the deposit right after it.
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"
}'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 '{
"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 still null. About 1 second later it moves to PROCESSING with the QR code filled in and, about 4 seconds after that, the simulated payer pays and it becomes COMPLETED.
7. Wait for the webhook
npx mimicr wait trace delivery event=OPERATION_COMPLETED ref=<operation-id>
The command returns as soon as the delivery exists (up to 25 s by default, --timeout 50 at most). Without a subscription, wait for the object instead: npx mimicr wait trace object id=<operation-id> status=COMPLETED.
Check the balance:
curl --url https://trace.mimicr.dev/v1/accounts/<account-id>/balances \ --header 'Authorization: Bearer <token>'
Next steps
- Testing in the sandbox: force failures, rejections and pending states.
- Withdrawal and Swap: spend the balance you just received.
- Sandbox control: every action of the other side.