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

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

parameter
type
required
description
base_currency
string
Yes
The base currency for the trade. Example: BTC
quote_currency
string
Yes
The quote currency for the trade. Example: USDT
side
string
Yes
The side of the trade. One of: buy or sell
quantity
string
Yes
The amount of base currency to trade. Example: 0.0001
price
string
Yes
The same price from the quote creation. Example: 88989.119625
quote_id
string
Yes
The quote ID from the create quote response
reference
string
No
Optional reference for your own tracking and logs

Example Request

Example Request

Successful Response (200 OK)

Response Body

Response Fields

field
type
description
id
string
Unique ID of the order
base_currency
string
The base currency for the trade (e.g., USDT)
quote_currency
string
The quote currency for the trade (e.g., BTC)
side
string
The side of the trade (BUY or SELL)
order_type
string
The type of order (e.g., limit)
quantity
string
The quantity of base currency ordered
price
string
The price at which the order was placed
order.status
string
Status of the order (filled, pending, cancelled)
created_at
string
ISO 8601 timestamp when order was created
updated_at
string
ISO 8601 timestamp when order was last updated
filled_quantity
string
The quantity that has been filled
remaining_quantity
string
The quantity remaining to be filled
quote_id
string
The quote ID used to lock the trade rate
id
string
Unique ID of the fill
order_id
string
The order ID this fill belongs to
counterparty_order_id
string
The counterparty order ID matched against this fill
quantity
string
The quantity filled
created_at
string
ISO 8601 timestamp when fill was executed
quote_id
string
The quote ID that was consumed by this trade
consumed_quantity
string
The quantity consumed from the quote
remaining_quantity
string
The quantity remaining on the quote
is_exhausted
boolean
Whether the quote has been fully consumed

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:

event
when it fires
trade.completed
When trade is successfully executed
trade.failed
If the trade fails due to quote, balance, or system errors

Errors

code
message
description
400
Quote expired
quoteId is no longer valid.
400
Invalid asset pair
Only usdt ↔ bitcoin 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.

Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?