Guides
Mimicr

Sandbox control

Mimicr's control API, CLI and MCP to play the payer, the bank, the SPI and the back office, wait for events, move the clock and inject failures.

The GO 2.0 API only lets you act as the merchant. To test end to end, Mimicr also lets you act as the other side: the payer, their bank, the SPI and Pay4Fun's back office. All of it lives in the control API, at https://api.mimicr.dev/v1/pay4fun, and the same commands exist in the console, the CLI and the MCP server.

Authentication

Use an organization API key (mk_…), created in the organization settings, "Chaves de API" tab. Read keys only query; actions, clock, chaos, homologation and reset need a write key.

bash
curl --url https://api.mimicr.dev/v1/pay4fun \
  --header 'Authorization: Bearer mk_...'

With the CLI (Node 18+):

bash
npx mimicr login mk_...
npx mimicr status pay4fun

The key can also come from --key or the MIMICR_API_KEY variable. Output is JSON and the exit code is 1 on an HTTP error.

Routes

Method and pathPurpose
GET /v1/pay4funState: host, credentials, merchant and Pix key, balances of both accounts (in cents), homologation, chaos and clock; {"active": false} if not activated
POST /v1/pay4fun/activateActivates the organization's sandbox (201); if already active, 409 pay4fun_already_active
POST /v1/pay4fun/resetDeletes intents, keys, requests, contacts and webhooks; keeps credentials and configuration and sets the clock back to real time
POST /v1/pay4fun/sweepRuns the due steps now (payments, expirations, refunds, keys) and the webhook retries
GET /v1/pay4fun/waitWaits until an object or a notification shows up (long poll)
GET /v1/pay4fun/clockSandbox time and offset
POST /v1/pay4fun/clock/advanceMoves the clock forward and runs the steps that became due
GET /v1/pay4fun/objectsLists sandbox objects
GET /v1/pay4fun/objects/{kind}/{id}One object
GET /v1/pay4fun/deliveriesLists the webhooks sent
GET /v1/pay4fun/deliveries/{id}One webhook
POST /v1/pay4fun/deliveries/{id}/resendTries to deliver it again now
GET /v1/pay4fun/actionsLists the actions and their parameters
POST /v1/pay4fun/actions/{id}Runs an action
GET /v1/pay4fun/chaosChaos configuration per area
PUT /v1/pay4fun/chaos/{area}Changes the chaos of deposit, payment or account
PUT /v1/pay4fun/homologTurns autoProcessPayments on or off

Control API errors use {"error": {...}} with lower-case codes (for example pay4fun_not_active, unknown_action, action_failed, wait_timeout), different from Pay4Fun's shapes.

Objects and notifications

kind is one of deposit_intent, payment_intent, pix_key, limit_request or contact. id is the Pay4Fun API id (the intent, request or contact id; for keys, {conta}:{value}), and status uses the write vocabulary (Pending, Released, PendingPSP, Completed, Error…).

/objects filterExample
kindkind=deposit_intent,payment_intent
statusstatus=Released,Completed
idid=<intent-id>
external_idexternal_id=deposito-456
sincesince=2026-11-05T20:00:00Z (updated since)
limit50 by default, up to 200
/deliveries filterExample
kindkind=deposit or kind=payment
eventevent=Success,FAILED (Success, Rejected, FAILED, RETURNED, Expired, Released, Declined)
statusstatus=failed (pending, success, failed, skipped)
refref=<intent-id>
since, limitas above

Filters take several comma-separated values.

Wait

GET /v1/pay4fun/wait answers as soon as something matches the filters, or 408 wait_timeout. Parameters: on (object or delivery), the filters above (at least one of id, external_id, kind, status, event and ref) and timeout in seconds (default 25, maximum 50). While waiting, the simulator runs the due steps.

bash
curl --url 'https://api.mimicr.dev/v1/pay4fun/wait?on=delivery&kind=deposit&event=Success&ref=<intent-id>&timeout=30' \
  --header 'Authorization: Bearer mk_...'
bash
npx mimicr wait pay4fun object kind=payment_intent external_id=pedido-123 status=Completed
npx mimicr wait pay4fun delivery kind=payment event=Declined ref=<intent-id> --timeout 50

Actions of the other side

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/pay4fun/actions/deposit.pay \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "intentId": "deposito-456", "payer": "carla" }'
json
{
  "ok": true,
  "action": "deposit.pay",
  "message": "Intent 596a71a0-72de-4f09-8b5f-05b0e9230adc: Error. Webhook de depósito enviado.",
  "data": { "id": "596a71a0-72de-4f09-8b5f-05b0e9230adc", "externalId": "deposito-456", "status": "Error" }
}

In the CLI: npx mimicr action pay4fun deposit.pay intentId=deposito-456 payer=carla (true and false become booleans). Intent ids also accept the externalId. An action that doesn't apply to the current state answers 422 action_failed with the reason.

ActionParametersEffect
deposit.payintentId (required), depositId (default: the first pending one), payer (ana default, bruno, carla, davi; for Pix-ITP the default is the holder of data.document), or document and nameThe payer pays a deposit; the outcome follows the rules in Sandbox testing and the webhook is sent
deposit.failintentId, kind (Rejected or Failed) (required), depositIdThe bank refuses (Rejected, AM02) or the screening fails it (FAILED, DEP-114)
deposit.expireintentId (required), depositIdA pending deposit's QR Code expires now (expiry webhook)
deposit.complete_refundintentId (required)The bank completes the requested refund now: RETURNED webhook and a statement debit
payment.processpaymentId (required)Moves one step now: Pending → validation → PendingPSP; PendingRetry → new attempt; PendingPSP → Completed
payment.settlepaymentId (required)The SPI confirms a PendingPSP payment: Completed, debit, fee and Released webhook
payment.declinepaymentId (required), code (default AC03), descriptionThe SPI refuses a payment in flight: Error, withdraw-errors and Declined webhook
pixkey.confirmaccount (transactional or owner), key (required)Confirms ownership of an EMAIL or PHONE key (PENDING → ACTIVE)
limit.reviewrequestId, approve (required), reasonThe review approves (the limit becomes the requested amount) or refuses an increase request

Hosted pages

The pay4fun.mimicr.dev host serves, without a token, the pages the API responses point to:

  • /checkout/{intentId} (the intent's url): shows the pending deposits with the copy-and-paste code and pays with the chosen test payer.
  • /itp/{depositId} (the reference of a Pix-ITP): the payer's bank, with Authorize and Refuse, which then returns to the redirectUrl.

Homologation

bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/pay4fun/homolog \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "autoProcessPayments": false }'
SwitchOn (default)Off
autoProcessPaymentsPayments settle on their own ~3 s after being sent to the SPIThey stop at PendingPSP until payment.settle or payment.decline

Or with the CLI: npx mimicr put /v1/pay4fun/homolog autoProcessPayments=false.

Clock

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/pay4fun/clock/advance \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "minutes": 10 }'

The body takes seconds, minutes, hours and days, added up, up to 400 days per call. After moving forward, the due steps run at once. In the CLI: npx mimicr clock pay4fun +30m, +2h or +1d.

Common uses:

  • Expire a Pix-QrDynamic (300 s by default).
  • Expire the token (300 s) and test the 401.
  • Make payment retries (1 min with onFailRetry) and webhook retries due.
  • Turn over the daily window of the account limits.

A reset sets the clock back to real time.

Chaos

bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/pay4fun/chaos/deposit \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "enabled": true, "apiErrorRate": 20, "apiErrorStatus": 503, "latencyMinMs": 500, "latencyMaxMs": 2000, "opsFailRate": 10, "opsFailCode": "FAILED" }'
FieldMeaning
enabledTurns the area on or off
apiErrorRate% of calls that answer an error
apiErrorStatus500, 503 or 429
apiErrorWhenbefore (nothing is processed) or after (processes and answers an error)
latencyMinMs, latencyMaxMsExtra latency, up to 20,000 ms
opsFailRate, opsFailCode% of operations that fail: in deposit, Rejected or FAILED (when the deposit is paid); in payment, AC03, AM04, AB03 or RR04 (when sent to the SPI, with the same retry rule as the amount table: AB03 and AM04 are recoverable, AC03 and RR04 decline); account has none
webhookFailRate% of notifications whose first attempt fails (deposit and payment)
webhookDuplicateRate% of notifications delivered twice (deposit and payment)

The areas cover /deposit/... (deposit), /payment/... (payment) and everything else (account: account, configurations, profile, billings, currencies and Pix). /auth and the hosted pages are not affected by chaos. Fields you don't send keep their current value.

MCP server

Agents can use https://api.mimicr.dev/mcp (Streamable HTTP, same mk_… key). The tools cover overview, reference, control API calls, simulated API calls, actions, waiting and moving the clock. npx mimicr mcp prints the command to connect it in Claude Code and the JSON for other clients.

End-to-end test example

bash
npx mimicr reset pay4fun
# your app creates the deposit intent "pedido-42" on https://pay4fun.mimicr.dev
npx mimicr action pay4fun deposit.pay intentId=pedido-42 payer=ana
npx mimicr wait pay4fun delivery kind=deposit event=Success
# your app pays the customer R$ 20.11, which Mimicr declines
npx mimicr wait pay4fun delivery kind=payment event=Declined