Execute Trade

Convert stablecoins to Bitcoin or Bitcoin to stablecoins.

This endpoint allows you to perform a real-time asset conversion between supported assets. You can execute at current market rate or lock pricing using a previously generated quote ID.

Endpoint

Endpoint

POST /trades/execute


Purpose

Use this endpoint to:

Execute a USDTBitcoin trade for a user or system wallet

Lock in pricing using a valid quote (quoteId)

Route funds directly to your Bitnob wallet for the destination asset

Track every trade via reference ID and webhooks

Request Body Parameters

ParameterTypeRequiredDescription
fromstringYesAsset to convert from (usdt or bitcoin)
tostringYesAsset to convert to (usdt or bitcoin)
amountintegerYesAmount to convert (in cents if from USDT, sats if from BTC)
referencestringYesUnique ID for idempotency and traceability
quoteIdstringNoOptional. If provided, the rate is locked; otherwise, market rate is used
descriptionstringNoOptional description for your own logs or ledger

Example Request

POST /trades/execute

Successful Response (200 OK)

Response Body

Response Fields

FieldTypeDescription
tradeIdstringUnique ID of the executed trade
referencestringYour submitted reference ID
fromstringSource asset type
tostringDestination asset type
inputAmountintegerAmount converted (input)
outputAmountintegerResulting amount received (output)
rateintegerExecuted exchange rate
walletIdstringWallet where the resulting funds were deposited
statusstringStatus of trade (completed, failed, pending)
createdAtstringISO 8601 timestamp of execution

Trade Behavior

If quoteId is provided:

The rate is locked

If the quote is expired, trade will fail (quote_expired)

If quoteId is omitted:

The trade is executed at live market rate

Final output may vary slightly depending on real-time pricing

Idempotency

You must submit a unique reference for each trade attempt. Reusing the same reference will return the original trade object — preventing accidental double execution.

Webhooks

On completion, Bitnob will emit:

EventWhen it Fires
trade.completedWhen trade is successfully executed
trade.failedIf the trade fails due to quote, balance, or system errors

Errors

CodeMessageDescription
400"Quote expired"quoteId is no longer valid.
400"Invalid asset pair"Only usdtbitcoin supported.
400"Missing or invalid amount"Must be > 0 and in proper unit.
409"Duplicate reference"Trade with that reference already exists.
422"Insufficient balance"Source wallet doesn’t have enough funds.
500"Execution failed"Internal issue; retry or contact support.
Did you find this page useful?