Trade stablecoins and pesos from your own systems
Ask for a firm price, confirm it, fund the trade and receive the payout. Pesos move by SPEI, stablecoins on-chain, and every step reaches you as a signed webhook.
https://sandbox-api.blockens.tech/v1Simulated prices and settlement. No real money. Keys start with bk_test_.
https://api.blockens.tech/v1Real money. Keys start with bk_live_, issued after go-live.
What you can trade
| Pair | Price is | Moves on |
|---|---|---|
USDT/MXN | MXN per 1 USDT | USDT: Tron, Ethereum, Solana, Polygon · MXN: SPEI |
USDC/MXN | MXN per 1 USDC | USDC: Ethereum, Solana, Polygon, Tron · MXN: SPEI |
BTC/USDT, BTC/USDC | USDT or USDC per 1 BTC | BTC: Bitcoin · on request |
ETH/USDT, ETH/USDC | USDT or USDC per 1 ETH | ETH: Ethereum · on request |
Every price is all-in: it already includes your agreed terms. The minimum is 25,000 USD per trade, measured on the stablecoin side. GET /v1/pairs lists the pairs enabled for your account.
Quickstart
Your first sandbox trade, end to end. You need the sandbox key Blockens sent you.
- Store your key as a secret.
Keep it in an environment variable such as
BLOCKENS_API_KEY, never in source code. - Make a signed request.
Use the helper below; it signs every call. Try
GET /v1/pairs. - Ask for a quote.
POST /v1/quoteswith a pair, a side and an amount. The price holds untilexpires_at. - Confirm it.
POST /v1/tradeswith thequote_idand one of yourdestination_ids. You get funding instructions and apay_bytime. - Move the trade forward.
In the sandbox,
POST /v1/sandbox/trades/{id}/simulateplays the funding and the payout, and fires the webhooks you would get in production.
// Node 18+. No packages needed. import crypto from 'node:crypto'; const BASE = 'https://sandbox-api.blockens.tech'; const KEY = process.env.BLOCKENS_API_KEY; // Signs and sends one request. Pass the same idempotencyKey when you retry a POST. export async function blockens(method, path, body, idempotencyKey = crypto.randomUUID()) { const raw = body === undefined ? '' : JSON.stringify(body); const ts = String(Math.floor(Date.now() / 1000)); const signature = crypto.createHmac('sha256', KEY) .update(`${ts}.${method}.${path}.${raw}`).digest('hex'); const headers = { Authorization: `Bearer ${KEY}`, 'X-Blockens-Timestamp': ts, 'X-Blockens-Signature': signature, }; if (method === 'POST') { headers['Content-Type'] = 'application/json'; headers['Idempotency-Key'] = idempotencyKey; } const res = await fetch(BASE + path, { method, headers, body: raw || undefined }); const data = await res.json(); if (!res.ok) throw Object.assign(new Error(data.error.message), data.error); return data; } const quote = await blockens('POST', '/v1/quotes', { pair: 'USDT/MXN', side: 'buy', send_amount: '1000000.00' }); const trade = await blockens('POST', '/v1/trades', { quote_id: quote.quote_id, destination_id: 'dst_test_tron', client_reference: 'ORDER-1001' }); console.log(trade.id, trade.status, trade.funding);
# Python 3.8+. Standard library only. import hashlib, hmac, json, os, time, uuid, urllib.request, urllib.error BASE = "https://sandbox-api.blockens.tech" KEY = os.environ["BLOCKENS_API_KEY"] def blockens(method, path, body=None, idempotency_key=None): """Signs and sends one request. Pass the same idempotency_key when you retry a POST.""" raw = "" if body is None else json.dumps(body, separators=(",", ":")) ts = str(int(time.time())) signature = hmac.new(KEY.encode(), f"{ts}.{method}.{path}.{raw}".encode(), hashlib.sha256).hexdigest() headers = {"Authorization": f"Bearer {KEY}", "X-Blockens-Timestamp": ts, "X-Blockens-Signature": signature} if method == "POST": headers["Content-Type"] = "application/json" headers["Idempotency-Key"] = idempotency_key or str(uuid.uuid4()) req = urllib.request.Request(BASE + path, data=raw.encode() if raw else None, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=30) as res: return json.load(res) except urllib.error.HTTPError as e: error = json.load(e)["error"] raise RuntimeError(f"{e.code} {error['code']}: {error['message']} ({error['request_id']})") quote = blockens("POST", "/v1/quotes", {"pair": "USDT/MXN", "side": "buy", "send_amount": "1000000.00"}) trade = blockens("POST", "/v1/trades", {"quote_id": quote["quote_id"], "destination_id": "dst_test_tron", "client_reference": "ORDER-1001"}) print(trade["id"], trade["status"], trade["funding"])
# bash with curl and openssl. Good for a first test. BASE="https://sandbox-api.blockens.tech" BODY='{"pair":"USDT/MXN","side":"buy","send_amount":"1000000.00"}' TS=$(date +%s) SIG=$(printf '%s' "$TS.POST./v1/quotes.$BODY" | openssl dgst -sha256 -hmac "$BLOCKENS_API_KEY" -hex | sed 's/^.* //') curl -sS -X POST "$BASE/v1/quotes" \ -H "Authorization: Bearer $BLOCKENS_API_KEY" \ -H "X-Blockens-Timestamp: $TS" \ -H "X-Blockens-Signature: $SIG" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "$BODY"
Authentication
Every request carries your API key and a signature. Blockens stores only a hash of your key, so nobody at Blockens can read it; if you lose it, ask for a new one.
Authorization: Bearer <your API key> X-Blockens-Timestamp: <Unix time in seconds> X-Blockens-Signature: <hex HMAC-SHA256 of the signing string, keyed with your API key>
The signing string joins four parts with a dot:
- Timestamp
- The same value as
X-Blockens-Timestamp. Within 300 seconds of our clock. - Method
- Upper case:
GETorPOST. - Path
- Starts at
/v1and includes the query string, exactly as sent. - Body
- The exact bytes you send. Empty for GET (the string still ends with a dot).
- Sign the bytes you send. Serialize the JSON once and send that same string; re-serializing after signing changes the bytes.
- IP allowlist. Production keys work only from the server IPs you registered with Blockens. Calls from anywhere else get
403 ip_not_allowed. - Key rotation. When Blockens issues you a new key, the old one keeps working for 24 hours so you can switch without downtime. A key that may have leaked is stopped at once.
Idempotency
Every POST needs an Idempotency-Key header: 8 to 80 letters, digits, - or _. A UUID is ideal. It makes retries safe: a confirm retried after a timeout can never create two trades.
| You send the same key… | You get |
|---|---|
| with the same request, within 24 hours | The first response again, with the header Idempotent-Replayed: true. This includes refusals: a request refused once is refused the same way. |
| with a different body or path | 409 idempotency_conflict. Use a new key for a new request. |
| while the first request is still running | 409 request_in_progress. Wait a moment and retry with the same key. |
Generate the key once per intended action, store it with your order, and reuse it for every retry of that action.
Conventions and limits
- JSON over HTTPS. Send
Content-Type: application/jsonon POST. Bodies up to 64 KB. - Amounts are decimal strings, such as
"1000000.00", never floats. Decimals: MXN 2, USDT and USDC 6, BTC and ETH 8. - Times are ISO 8601 in UTC, such as
2026-10-20T16:21:05.000Z. - IDs: quotes
q_…, tradesT-000123(TS-000123in the sandbox), webhook eventsevt_…, requestsreq_…. - Every response carries
X-Request-Id. Quote it when you contact us.
Rate limits
| What | Limit, per key |
|---|---|
POST /v1/quotes | 60 per minute |
POST /v1/trades | 30 per minute |
| All requests | 300 per minute |
Over a limit you get 429 rate_limited with Retry-After: 60. Back off; do not retry in a tight loop. Need more? Tell us your peak.
GET/v1/pairs
The pairs enabled for your account, with their minimum, networks and decimals.
{
"data": [
{
"pair": "USDT/MXN", "base": "USDT", "quote": "MXN", "min_usd": "25000",
"networks": { "USDT": ["tron", "ethereum", "solana", "polygon"], "MXN": null },
"decimals": { "USDT": 6, "MXN": 2 }
}
]
}GET/v1/destinations
Where Blockens can pay you: your approved wallets and CLABEs. New destinations are added with Blockens, never through the API; each wallet is approved and receives a small test transfer first.
{
"data": [
{ "id": "6f1c2a9e-…", "kind": "wallet", "network": "tron", "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "bank": null, "label": "Treasury" },
{ "id": "0b7d41c3-…", "kind": "clabe", "network": null, "address": "012180001234567899", "bank": "BBVA México", "label": "Operations" }
]
}In the sandbox you get test destinations: dst_test_tron, dst_test_ethereum, dst_test_solana, dst_test_polygon, dst_test_bitcoin and dst_test_clabe.
POST/v1/beneficiaries
To pay pesos to your customers in Mexico, register each one once and send its file (below). Blockens pays on your behalf, reviews each beneficiary before its first payout and tells you by webhook (beneficiary.documents_complete, beneficiary.approved, beneficiary.rejected or beneficiary.file_requested).
| Field | Required | Meaning |
|---|---|---|
kind | yes | "person" or "company". |
name | yes | Full legal name, as on the bank account. |
tax_id | yes | RFC (companies, people) or CURP (people). |
clabe | yes | 18-digit CLABE in the beneficiary's own name. |
email | no | For the payment notice. |
client_reference | no | Your own ID for this beneficiary. |
POST/v1/beneficiaries/{id}/documents
The beneficiary's file, one document per call, before its first payout. A live beneficiary is approved once its file is complete. Files are stored sealed and never returned.
| Field | Required | Meaning |
|---|---|---|
type | yes | Company: articles_of_incorporation, tax_id (RFC or EIN), csf, proof_of_address, ubo_id, ubo_proof_of_address. Person: id, proof_of_address. |
file_name | no | Your file's name. Not kept: file names often carry a person's name, so we store the document as its type and extension (for example "id.pdf"). |
data_base64 | yes | The file (PDF, PNG or JPEG), base64-encoded, up to 2.5 MB. |
The answer is the beneficiary with documents (what was received) and documents_missing (what is still needed).
{
"id": "ben_4Fq9xLm2Tz8Wk3Pa",
"environment": "live",
"kind": "person",
"clabe_last4": "0004",
"bank": "BBVA México",
"client_reference": "CUST-881",
"status": "pending_review",
"review_note": null,
"created_at": "2026-10-21T18:02:11.000Z"
}GET /v1/beneficiarieslists yours;GET /v1/beneficiaries/{id}shows one. Names, tax IDs and full CLABEs are never returned: Blockens keeps them sealed.- A CLABE can be registered once (
beneficiary_existsreturns the existing id). In the sandbox, beneficiaries are approved at once.
POST/v1/quotes
A firm, all-in price for one trade. Give what you send or what you want to receive; Blockens returns the other side.
| Field | Required | Meaning |
|---|---|---|
pair | yes | One of your pairs, such as "USDT/MXN". |
side | yes | "buy": you buy the first asset (pay with the second). "sell": you sell the first asset (receive the second). |
send_amount | one of the two | The amount you send, as a decimal string. |
receive_amount | one of the two | The amount you want to receive. Blockens works out what you send, rounded up to the asset's decimals. |
send_network | no | When you send crypto: the network you send it on (such as "tron"). Defaults to the asset's first network. |
markup | no | Your own charge to your customer, on top of Blockens' price: {"type":"bps","value":"25"} (up to 1000) or {"type":"fixed","value":"150.00"} in the asset received. It is taken from what is received, shown as markup in the quote and the trade, and paid to you by Blockens. |
{ "pair": "USDT/MXN", "side": "buy", "send_amount": "1000000.00" }{
"quote_id": "q_7Hk2mP9xQe4T",
"environment": "sandbox",
"pair": "USDT/MXN",
"side": "buy",
"price": "18.474102",
"send": { "asset": "MXN", "amount": "1000000.00", "network": null },
"fee": { "asset": "MXN", "amount": "0.00", "bps": "0" },
"receive": { "asset": "USDT", "amount": "54129.829964" },
"expires_at": "2026-10-20T16:21:35.000Z"
}priceis the second asset per 1 of the first (MXN per USDT here).feeis your agreed service fee, taken from what you send (zero if none).- A quote binds nothing until you confirm it. Always read
expires_at; how long a price holds depends on the market (30 seconds in the sandbox). - Errors you should handle:
below_minimum,pair_not_enabled,invalid(withfields),over_limit(your limits per trade, per day or unfunded),liquidity_unavailable. Live quotes last up to 30 seconds: confirm promptly. If the market moved meaningfully since your quote, confirming answers409 price_changed: ask for a new quote.
POST/v1/trades
Confirms a quote. From this moment the price is locked and the trade must be funded by pay_by.
| Field | Required | Meaning |
|---|---|---|
quote_id | yes | From POST /v1/quotes, before it expires. |
destination_id | one of the two | Where you are paid: a wallet on a network the received asset uses, or a CLABE for pesos. |
beneficiary_id | one of the two | Pesos paid to an approved beneficiary (by SPEI) on behalf of your customer. |
on_behalf_of | no | Optional, with beneficiary_id: who sends behind you, {"name":"…","reference":"…"}. The name is kept sealed and never returned; the reference is echoed. |
client_reference | no | Your own ID, up to 64 characters (letters, digits, . _ : / -). Echoed in every response and webhook. |
{
"id": "TS-000123",
"environment": "sandbox",
"status": "confirmed",
"client_reference": "ORDER-1001",
"pair": "USDT/MXN",
"side": "buy",
"price": "18.474102",
"send": { "asset": "MXN", "amount": "1000000.00", "network": null },
"fee": { "asset": "MXN", "amount": "0.00", "bps": "0" },
"receive": { "asset": "USDT", "amount": "54129.829964", "network": "tron", "destination_id": "dst_test_tron" },
"funding": { "method": "spei", "bank": "Sandbox Bank", "clabe": "000180000000000001", "reference": "0000123" },
"pay_by": "2026-10-20T20:21:05.000Z",
"created_at": "2026-10-20T16:21:05.000Z",
"steps": [ { "name": "confirmed", "at": "2026-10-20T16:21:05.000Z", "proof": null } ],
"completed_at": null,
"penalty": null
}- When you send crypto,
fundingis{ "method": "onchain", "asset": "USDT", "network": "tron", "address": "T…" }. - Pay pesos only from your registered CLABE, with the 7-digit
referencein the SPEI concept. Send crypto only from your whitelisted wallets. Funds from anywhere else are returned, not applied. - Errors you should handle:
quote_expiredandquote_used(ask for a new quote),over_limit(fund open trades first),destination_not_active.
GET/v1/trades/{id}
One trade, as above, with every step so far. Each step has name, at and proof (the SPEI tracking key or transaction hash, when there is one). A completed trade also has proof and completed_at; a trade that was not completed has penalty: { "pct": "10", "asset": "MXN", "amount": "100000.00" }.
GET/v1/trades
Your trades, newest first, 50 per page.
| Query | Meaning |
|---|---|
status | Only trades in this status. |
from, to | Created at or after from, before to (ISO 8601). |
cursor | The next_cursor of the previous page. |
{ "data": [ { "id": "TS-000124", "status": "completed", … } ], "next_cursor": null }Remember to sign the path with its query string: /v1/trades?status=completed.
POST/v1/sandbox/trades/{id}/simulate
Sandbox only. Moves a test trade forward as if the money had moved, and sends the matching webhook.
{ "event": "funds_received" }| event | Allowed when the trade is | Result |
|---|---|---|
funds_received | confirmed | Your funds arrived. |
completed | funds_received | Settled and paid out, with a test proof. |
not_completed | confirmed | Not funded in time; the 10% penalty is shown. |
cancelled | confirmed | Closed before any money moved. |
Anything else returns 409 invalid_state.
Collect
Collect gives your company accounts abroad in its own name (EUR, USD, GBP and more). Your customers abroad pay you there by local transfer or international wire; you choose how each payment settles: USDT to one of your approved wallets, or pesos by SPEI to one of your approved CLABEs, at one all-in rate shown before it is paid. It runs by itself:
- A payment arrives:
collect.needs_instruction(or, with a standing instruction, straight to pricing). - Say how it settles:
collect.pricing, then within secondscollect.pricedwith what you receive, the rate, aprice_idandprice_valid_until(10 minutes). - Confirm the price with its
price_id. Pesos to your approved CLABE go out at once:collect.sending→collect.paid. USDT to your wallet is released by the Blockens team:collect.confirmed→collect.sending→collect.paid.
Collect works with your live key once Blockens enables it for your account. In the sandbox, make a payment arrive and run the same flow at fixed rates.
GET/v1/collect
Your accounts (with the details to give your payers), the payments received and how each one settles.
{
"enabled": true,
"accounts": [
{ "id": "8a2c…", "currency": "EUR", "country": "GB", "method": "international_wire", "status": "active",
"payer_details": { "holder": "Importadora del Norte SA de CV", "iban": "GB29 NWBK 6016 1331 9268 19", "bank": "…", "codes": { "swift_code": "…" } },
"created_at": "2026-10-28T18:00:00.000Z" }
],
"account_requests": [ { "id": "1f0e…", "currency": "USD", "status": "open", "created_at": "2026-10-28T18:10:00.000Z" } ],
"payments": [
{ "id": "3c9d…", "reference": "CR-000014", "amount": "12500.00", "currency": "EUR", "status": "received", "received_at": "2026-10-28T19:41:00.000Z",
"settlement": { "to": null, "destination_id": null, "status": "needs_instruction", "price_id": null, "receive": null, "receive_currency": null, "rate": null,
"price_valid_until": null, "confirmed_at": null, "paid_at": null } }
],
"standing_instruction": { "to": "USDT", "destination_id": "6f1c2a9e-…" }
}| Field | Values |
|---|---|
accounts[].status | opening, active (payer details shown), unavailable |
payments[].status | arriving, received, failed |
settlement.status | waiting_funds, needs_instruction, pricing, priced (confirm it), price_expired and price_unavailable (send the instruction again), confirmed (USDT: the team releases it), sending, paid, in_review, cancelled |
settlement.receive, rate | What you receive and the all-in rate, once priced. |
settlement.price_id, price_valid_until | What you confirm, and until when. |
POST/v1/collect/payments/{id}/instruction
How one received payment settles, and a request for its price. to is "USDT" (to a wallet) or "MXN" (to a CLABE); destination_id comes from GET /v1/destinations. The settlement moves to pricing, then priced (webhook collect.priced, or read GET /v1/collect/payments/{id}). Send it again for a new price once one expires.
{ "to": "MXN", "destination_id": "0b7d41c3-…" }{ "id": "3c9d…", "reference": "CR-000014", "amount": "12500.00", "currency": "EUR", "status": "received",
"settlement": { "to": "MXN", "destination_id": "0b7d41c3-…", "status": "pricing", … } }Errors: not_found, already_settling (409), pricing (409: a price is on its way), invalid_destination (USDT settles to a wallet, MXN to a CLABE), product_not_enabled.
GET/v1/collect/payments/{id}
One payment and its settlement, the same object the collect.* webhooks carry.
{ "id": "3c9d…", "reference": "CR-000014", "amount": "12500.00", "currency": "EUR", "status": "received", "received_at": "2026-11-11T19:41:00.000Z",
"settlement": { "to": "MXN", "destination_id": "0b7d41c3-…", "status": "priced", "price_id": "prc_4f1c9a0b2d3e5f67",
"receive": "248701.12", "receive_currency": "MXN", "rate": "19.896090", "price_valid_until": "2026-11-11T19:52:10.000Z",
"confirmed_at": null, "paid_at": null } }POST/v1/collect/payments/{id}/confirm
Accept the price. Pesos to your approved CLABE are sent at once (sending, then paid); USDT moves to confirmed until the Blockens team releases it.
{ "price_id": "prc_4f1c9a0b2d3e5f67" }Response 200: the payment. Errors: not_priced, price_changed (confirm the latest price_id), price_expired (send the instruction again), invalid_destination (the destination is no longer approved).
POST/v1/collect/standing-instruction
Settle every new payment the same way, without an instruction each time. Send {"to": null} to remove it.
{ "to": "USDT", "destination_id": "6f1c2a9e-…" }POST/v1/collect/accounts
Ask for an account in another currency. Blockens opens it and it appears in GET /v1/collect as opening, then active with the details for your payers.
{ "currency": "USD", "note": "Customers in the US" }{ "currency": "USD", "status": "requested" }Errors: already_exists, already_requested, validation_error, product_not_enabled. Like every POST, these need an Idempotency-Key.
POST/v1/sandbox/collect/payments
Sandbox only: a payment arrives (USD, EUR or GBP). Then use the instruction (with a sandbox destination: dst_test_clabe for MXN, dst_test_tron and the other sandbox wallets for USDT) and confirm, exactly as live: priced at once at fixed rates, paid at once, with the same webhooks.
{ "amount": "1000.00", "currency": "USD" }Payouts abroad
Pay your suppliers abroad (EUR, USD, GBP, CNY and more) in pesos. You price the payout, confirm it with the invoice, send the pesos by SPEI with the reference Blockens gives you, and the rest runs by itself: you get a webhook at each step until the supplier is paid. Payouts abroad work with your live key once Blockens enables them for your account; the sandbox simulates everything.
- Add the supplier and its documents (once). Blockens checks it (documents and sanctions) and approves it:
supplier.approved. - Price a payout: what you pay in MXN for the supplier to receive an amount in its currency. Valid 10 minutes.
- Confirm it with the invoice: you get the CLABE, the numeric reference and the exact amount to send by SPEI, and the deadline.
- Send the SPEI.
payout.funds_received→payout.converting→payout.sending→payout.paid.
POST/v1/suppliers
{ "name": "Teile GmbH", "country": "DE", "bank_name": "Deutsche Bank", "bank_country": "DE", "swift": "DEUTDEFF",
"account": "DE89370400440532013000", "currency": "EUR", "client_reference": "sup-001" }{ "id": "5d2e…", "name": "Teile GmbH", "currency": "EUR", "account_last4": "3000", "status": "pending_review",
"documents": [], "documents_missing": ["registration", "bank_proof"], "client_reference": "sup-001", … }POST /v1/suppliers/{id}/documents with { "type": "registration" | "bank_proof" | "contract", "file": { "data_base64": "…" } } (PDF, PNG or JPEG, up to 2.5 MB). GET /v1/suppliers and /v1/suppliers/{id}. Statuses: pending_review, approved, blocked; webhooks supplier.approved and supplier.blocked. In the sandbox suppliers are approved at once.
POST/v1/payouts/quotes
{ "supplier_id": "5d2e…", "amount": "10000.00", "currency": "EUR" }{ "id": "9f1a…", "status": "ready", "supplier_id": "5d2e…",
"receive": { "amount": "10000.00", "currency": "EUR" }, "pay": { "amount": "206567.80", "currency": "MXN" },
"fee": { "amount": "1027.71", "currency": "MXN" }, "rate": "20.65678", "speed": "same_day", "expires_at": "2026-11-11T18:10:00.000Z" }pay is everything you send (fee included). Live prices come back within seconds; if the answer is 202 with "status": "pending", read it with GET /v1/payouts/quotes/{id}. A failed quote says why in error. Errors: supplier_not_approved, product_not_enabled.
POST/v1/payouts
{ "quote_id": "9f1a…", "client_reference": "INV-2026-0042", "purpose": "Machine parts", "invoice": { "data_base64": "JVBERi0x…" } }{ "id": "c41b…", "number": "EV-000043", "status": "awaiting_funds", "client_reference": "INV-2026-0042",
"receive": { "amount": "10000.00", "currency": "EUR" }, "pay": { "amount": "206567.80", "currency": "MXN" },
"funding": { "method": "spei", "clabe": "646180…", "holder": "Blockens", "reference": "4821937", "amount": "206567.80" },
"pay_by": "2026-11-11T22:00:00.000Z", "steps": [ { "name": "awaiting_funds", "at": "…" } ], … }Send exactly funding.amount by SPEI to funding.clabe with the numeric reference before pay_by; after that the payout expires (payout.expired). The invoice is required (PDF, PNG or JPEG). Each quote confirms once (quote_used); client_reference is unique per payout.
GET/v1/payouts/{id} · /v1/payouts?status=…&before=…
| status | Meaning |
|---|---|
awaiting_funds | Waiting for your SPEI (see funding). |
funds_received | Your pesos arrived. |
converting | Blockens is converting them. |
sending | Sent to the supplier’s bank. |
paid | The supplier’s bank confirmed it (paid_at). |
in_review | Blockens is looking at it; nothing to do on your side. |
expired, cancelled | Not paid in time, or cancelled. |
Each status change is a webhook payout.<status> whose data is the full payout.
POST/v1/sandbox/payouts/{id}/simulate
Sandbox only: move a payout to its next step, with its webhook. { "event": "funds_received" }, then converting, sending, paid in that order; in_review at any time, expired while waiting for funds.
Trade lifecycle
A confirmed trade only moves forward; it is never edited. Blockens pays out only after your funds have arrived.
| Status | Meaning | Webhook |
|---|---|---|
executing | Live only: your confirmation is being executed at the quoted price. Usually lasts milliseconds; if it takes longer, POST /v1/trades answers 202 with this status and the webhook follows. | none |
not_filled | Live only: the quoted price could not be executed. Nothing is owed; ask for a new quote. POST /v1/trades answers 409 not_filled with the trade_id. | trade.not_filled |
confirmed | Price locked; waiting for your funds until pay_by. The response carries funding: where to send them. | trade.confirmed |
funds_received | Your SPEI or on-chain transfer arrived. | trade.funds_received |
settling | Blockens is settling the trade (a step in steps; live trades keep the status funds_received until completed). | trade.settling (live) |
completed | Paid out to your destination, with its proof. | trade.completed |
not_completed | No funds by pay_by; the agreed 10% penalty applies. | trade.not_completed |
cancelled | Closed before any money moved. | trade.cancelled |
Your unfunded trades count against an exposure limit agreed with you. A confirm that would pass it returns 422 over_limit.
Webhooks
Blockens sends each trade step to the HTTPS address you registered, so you never need to poll.
X-Blockens-Event: trade.completed
X-Blockens-Timestamp: 1729450942
X-Blockens-Signature: 4f2a…c91e
{
"id": "evt_3Qm8yK2pLsW7xa",
"type": "trade.completed",
"created_at": "2026-10-20T17:05:42.000Z",
"data": { "id": "TS-000123", "status": "completed", "client_reference": "ORDER-1001", "proof": "7f3c…e91a", … }
}- Events:
trade.confirmed,trade.not_filled,trade.funds_received,trade.settling,trade.completed,trade.not_completed,trade.cancelled,beneficiary.created,beneficiary.approved,beneficiary.rejected,beneficiary.file_requested(with anotesaying what Blockens needs),beneficiary.documents_complete,supplier.approved,supplier.blocked,payout.awaiting_funds,payout.funds_received,payout.converting,payout.sending,payout.paid,payout.in_review,payout.expired,payout.cancelled,collect.<status>for every Collect settlement status above (collect.needs_instruction,collect.pricing,collect.priced,collect.price_unavailable,collect.confirmed,collect.sending,collect.paid,collect.in_review, …), andping(a test Blockens can send at any time). For trades,datais the full trade. - Verify every webhook. The signature is hex HMAC-SHA256 of
timestamp + "." + raw body, keyed with your webhook secret (whsec_…, separate from your API key). Reject anything older than 300 seconds. - Answer 2xx within 10 seconds. Otherwise Blockens retries after 1, 2, 5, 10 and 30 minutes, then 1, 2, 4 and 6 hours: 10 attempts in all. Redirects are not followed.
- At least once. The same event can arrive twice: ignore repeats by
id. Order is not guaranteed: truststatusandGET /v1/trades/{id}.
import crypto from 'node:crypto'; // rawBody: the request body exactly as received (a Buffer or string), before any JSON parsing. export function verifyBlockensWebhook(headers, rawBody, secret = process.env.BLOCKENS_WEBHOOK_SECRET) { const ts = headers['x-blockens-timestamp']; const given = String(headers['x-blockens-signature'] || ''); if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; const expected = crypto.createHmac('sha256', secret).update(`${ts}.`).update(rawBody).digest('hex'); return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected)); }
Errors
Every error has the same shape, with a stable code your software can act on, a message for people, and a request_id to quote to us. Validation errors add fields, one message per field.
{ "error": { "code": "quote_expired", "message": "The quote expired at 16:21:35Z. Ask for a new one.", "request_id": "req_9Xw2kQ7mLp" } }| HTTP | code | What to do |
|---|---|---|
| 400 | bad_request | Fix the request: the body is not a JSON object, or a POST has no valid Idempotency-Key. (A body over 64 KB gets the same code with HTTP 413.) |
| 401 | unauthorized | Missing, unknown or revoked key, or a production key before go-live. |
| 401 | bad_signature | Rebuild the signing string: timestamp, method, path with query, body, joined by dots. |
| 401 | timestamp_out_of_window | Your server clock is more than 300 seconds off. Sync it (NTP). |
| 403 | ip_not_allowed | Call from a registered IP, or ask Blockens to register this one. |
| 403 | pair_not_enabled | Ask Blockens to enable the pair. |
| 404 | not_found | Unknown trade, quote or path. |
| 405 | method_not_allowed | Use the method shown for the endpoint. |
| 409 | quote_expired, quote_used | Ask for a new quote. |
| 409 | idempotency_conflict, request_in_progress | See Idempotency. |
| 409 | invalid_state | Sandbox: simulate the steps in order. |
| 422 | invalid | Read fields and fix each one. |
| 422 | below_minimum | Trade at least 25,000 USD. |
| 422 | over_limit | Fund your open trades before confirming new ones. |
| 422 | destination_not_active | Use an id from GET /v1/destinations. |
| 409 | beneficiary_exists | That CLABE is already registered: use the beneficiary_id returned. |
| 422 | beneficiary_not_approved | Wait for beneficiary.approved before paying that beneficiary. |
| 429 | rate_limited | Wait Retry-After seconds. |
| 503 | liquidity_unavailable | Pricing is paused (market hours or volatility). Retry later. |
| 500 | internal_error | Retry with the same Idempotency-Key; contact us with the request_id if it persists. |
Sandbox
The sandbox behaves like production with simulated money. Build your whole integration there, unhappy paths included.
- Prices move every 5 seconds. Quotes hold 30 seconds.
- The 25,000 USD minimum and an exposure limit on unfunded trades apply, so you can test both errors.
- Test destinations (
dst_test_…) and test funding instructions; nothing is ever paid. - Trades are numbered
TS-…and move forward only with simulate.
The checks Blockens sees pass
Blockens sees these tick off as your system does them. All of them are needed before production.
- A signed request is accepted.
- A wrongly signed request is refused with
401 bad_signature. - A quote is confirmed for a
buy, and another for asell. - A confirm retried with the same
Idempotency-Keyreturns the same trade. - An expired quote is refused with
409 quote_expired, and your system asks for a new one. - The exposure limit is reached (
422 over_limit) and handled without retry storms. - A webhook is delivered to your address and answered with 2xx.
- A trade is followed to
completed, and another tonot_completed.
Going live
- Onboarding is complete.
KYB approved, agreement signed, and your terms (fee, limit, payment window) approved by Blockens.
- Your payout destinations are approved.
Each wallet is approved and receives a small test transfer; each CLABE is verified.
- Your production details are registered.
The public IPs of your production servers, your production webhook address and an on-call contact.
- All sandbox checks have passed.
- You receive your production key.
Through a one-time secure link, after two Blockens partners approve. We watch your first live trade with you.
Support
Write to your Blockens contact with the request_id from the response or the X-Request-Id header, the time, and what you expected. With the request id we can see exactly what reached us.