Guides
API principles

Envelopes and errors

Each Bloquo service answers in its own shape; know which one to expect on each route.

The Bloquo Platform API is made of several services, and each one has its own success shape. Errors, on the other hand, share one shape. The simulator reproduces exactly the shape that Bloquo's response schemas declare for each route.

Success responses

RoutesShape
Customer Service: /customer, /customer/me, /customer/{id}, /account…, /balances, /counterparty…, /customerCounterparty…, /childrenList, currencies, blockchains and types{"status": true, "statusCode": <http>, "result": …, "message": null}
Authentication, transactions, balance by account, trade, notifications, whitelist and sub-accounts{"status": true, "result": …, "message": null}
Deposit, withdrawal and FX payment ordersthe order itself, with no envelope
Named accounts (/accounts), fees (/fee/account/{id}) and FX payment historybare array
Reports (/transaction/report, /notification/report)CSV (text/csv)

Customer Service example:

json
{ "status": true, "statusCode": 200, "result": { "id": 1001, "name": "Acme Pagamentos Ltda" }, "message": null }

Order example (deposit), with no envelope:

json
{ "orderCreated": true, "id": 1043, "status": "PENDING_DEPOSIT", "currency": "BRL", "totalAmount": 1000 }

Some deletions and actions answer with result: null and a text in message, such as {"status": true, "statusCode": 200, "result": null, "message": "Customer removed with success"}.

Many examples in Bloquo's documentation are auto-generated and contradict the schemas (UUIDs in int64 fields, "status": "active", dates in statusCode). Mimicr follows the schemas. Write your parser per route, not one parser for everything.

Errors

Every error has the same shape:

json
{ "status": false, "result": null, "message": "Insufficient balance to process order." }
HTTPWhen
400Validation and business rules, in most cases
401Wrong credentials or a missing, invalid or expired token
403Customer outside the hierarchy, direct quote for a non-Institutional customer, documents for a non-child
404Balance of an unknown account, unknown FX payment, /accounts with no customer, no preferences, unknown route
422Trade execution (invalid, expired or used quote, or no balance) and FX payment with an unapproved counterparty
501Bloquo route outside the simulated core; see Out of scope
500, 503, 429Only when you turn chaos on in the sandbox

A missing required field answers 400 "<Field> is required.", for example FeatureFlags is required. or TaxId is required.. A non-integer id answers 400 "The value '<value>' is not valid for <field>.", and a body that isn't JSON, 400 The request body is not valid JSON..

Bloquo doesn't document the shape of validation failures. The "<Field> is required." message is a Mimicr decision.

Handle errors

  • Decide on the HTTP status and use message for logs and for operators. Messages are English text, with no error code.
  • Handle a trade execution 422 by requesting a new quote.
  • On 401, authenticate again and retry the call once.
  • On 5xx and 429, retry with increasing backoff.

To trigger 500, 503 and 429 on purpose, configure chaos through the control API (see Sandbox control). The bodies use the same error envelope: An unexpected error occurred., Service unavailable. and Too many requests..