X-Api-Key in a backend service, job runner, or secure internal tool. Never expose it in browser, mobile, desktop, or user-controlled code.
0. Configure Your Environment
Create a staging API key in the Stabyl staging app, then configure your server-side environment:webhooks:manage, webhooks:view, or wallets:withdraw. Step 1 below
needs webhooks:manage, and step 8 needs wallets:withdraw. Scopes cannot be
added to an existing key, so a key created without them must be replaced.
Use staging keys against staging URLs. Production API access requires completed
KYB and an explicit invitation from Stabyl; staging access does not grant
production access. After invitation, use production credentials only against
the production URL. Treat cross-environment authentication failures as
configuration errors, not transient failures.
1. Subscribe to webhooks
Create your HTTPS receiver before initiating asynchronous activity:whsec_... secret immediately; it is shown only once. See
Webhooks for signature verification and durable deduplication.
2. List supported chains
3. Request a Tron deposit address
chain, optional slug, address, and memo exactly as returned.
4. Read balances
balances, withdrawable, and credit. Use
withdrawable when deciding how much can be withdrawn right now. Use
balances[].available for other spendable-balance decisions such as order
sizing, and balances[].locked to explain funds committed to pending activity.
5. Create an order
order_id,
status: "pending", and created_at; it means the request was accepted for
processing, not that the order is filled. Idempotency-Key must be a UUID. Set
client_order_id in the body if you need to find the order again from your own
records.
6. Receive order status changes
Use exchange webhooks for durable lifecycle events. Use private WebSocket topics when your application also needs low-latency order and fill streams. REST order detail remains available for startup recovery, missed-event repair, and operator lookups:7. Reconcile wallet activity
next_cursor is null.
Run this as periodic reconciliation and after webhook downtime rather than as a
per-transaction polling loop. Reconciliation jobs should be restartable and
should tolerate records arriving after confirmation or settlement updates.
8. Submit a withdrawal
Follow Withdrawal examples to quote, sign, and submit NGN or stablecoin withdrawals. Persist the returned transaction ID and complete the workflow fromwithdrawal.success, withdrawal.partial, or
withdrawal.failed; use the
transaction detail route only for targeted recovery and reconciliation.