Skip to main content

Execute Purchase

Execute a buy trade to purchase on-chain tokens using payment tokens (e.g. USDT/USDC).

info
  • Must call Get Trade Quote first to get a valid quote
  • Must display quote details to the user and obtain explicit confirmation before calling this endpoint
  • Pass quoteData, correctingCode, and gas from the quote response as-is
  • A 200 response is only an acknowledgment — use Get Order List to check the final order status
  • Idempotent based on quoteDataId — duplicate submissions return the same order number
  • On-chain confirmation typically takes 10–60 seconds

HTTP Request

POST/v5/alpha/trade/purchase

Request Parameters

ParameterRequiredTypeComments
fromTokenCodetruestringPayment token code (CEX_<id>), e.g. CEX_1 for USDT. Must match the quote request
fromTokenAmounttruestringPayment amount (positive decimal as string). Must match the quote request
toTokenCodetruestringTarget on-chain token code (DEX_<id>), e.g. DEX_123. Must match the quote request
slippagetruestringSlippage tolerance as decimal. 0.005 = 0.5%, 0.01 = 1%, 0.05 = 5%
quoteDatatruestringBase64-encoded quote data. Must pass as-is from the /quote response
gastruestringEstimated gas fee. Must pass as-is from the /quote response
quoteModetrueintegerQuote mode. Must be consistent with the /quote request. 0: Auto, 1: Price Priority, 2: Success Rate Priority
correctingCodetruestringMD5 checksum for data integrity. Must pass as-is from the /quote response
tenantfalsestringOptional tenant identifier

Response Parameters

ParameterTypeComments
orderNostringSystem-generated order number. Use this to query order status via Get Order List

Request Example

POST /v5/alpha/trade/purchase HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1704067200000
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"fromTokenCode": "CEX_1",
"fromTokenAmount": "100",
"toTokenCode": "DEX_123",
"slippage": "0.01",
"quoteData": "eyJhbGciOiJIUzI1NiJ9...",
"gas": "0.0003",
"quoteMode": 0,
"correctingCode": "a1b2c3d4e5f6"
}

Response Example

{
"retCode": 0,
"retMsg": "OK",
"result": {
"orderNo": "ORD_20240101_001"
},
"retExtInfo": {},
"time": 1704067200000
}