Create Trade
POST
/ver1/tradesCreates a new trade.
This endpoint supports creating market and limit trades, including optional conditional triggers, trailing stops, timeouts, and leverage settings (for OKX Futures).
Request Parameters
ID of the exchange account. Use GET /ver1/accounts
to retrieve available accounts.
Details of the trade order.
Hide child parametersShow child parameters
Amount to buy or sell.
Price settings, required for limit orders.
Optional conditional order configuration.
Hide child parametersShow child parameters
Optional trailing stop configuration.
Optional timeout for conditional trades.
Optional leverage configuration (OKX Futures only).
Example Trade Types
Market Buy
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "buy"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": false
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Market Sell
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "sell"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": false
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Limit Buy
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "limit",
"side": "buy"
},
"units": {
"value": "1.0"
},
"price": {
"value": "10000.0"
},
"conditional": {
"enabled": false
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Limit Sell
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "limit",
"side": "sell"
},
"units": {
"value": "1.0"
},
"price": {
"value": "100000.0"
},
"conditional": {
"enabled": false
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Conditional Market Buy
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "buy"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": true,
"value": "less_or_equal",
"price": {
"value": "10000.0",
"type": "last"
}
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Conditional Limit Sell
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "limit",
"side": "sell"
},
"units": {
"value": "1.0"
},
"price": {
"value": "100000.0"
},
"conditional": {
"enabled": true,
"value": "greater_or_equal",
"price": {
"value": "90000.0",
"type": "last"
}
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Conditional Trailing Sell
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "sell"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": true,
"value": "greater_or_equal",
"price": {
"value": "90000.0",
"type": "last"
}
},
"trailing": {
"enabled": true,
"percent": "1.0"
},
"timeout": {
"enabled": false
}
}
Conditional + Timeout
{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "sell"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": true,
"value": "greater_or_equal",
"price": {
"value": "90000.0",
"type": "last"
}
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": true,
"value": 300
}
}
Example Request
POST
/ver1/trades{
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "buy"
},
"units": {
"value": "1.0"
},
"conditional": {
"enabled": false
},
"trailing": {
"enabled": false
},
"timeout": {
"enabled": false
}
}
Response Parameters
If successful, the response includes trade ID, current status, and other metadata (not fully documented).
Example Responses
- 201 Created
- 422 Unprocessable Entity
- 403 Forbidden
{
"uuid": "a6f1c3d2-9d1a-4db7-9ad4-f7a8e2f98765",
"account_id": 1,
"pair": "USDT_BTC",
"order": {
"type": "market",
"side": "buy"
},
"units": {
"value": "1.0"
},
"status": {
"value": "to_process",
"error": null
},
"filled": {
"units": "0.0",
"total": "0.0",
"price": null
},
"created_at": 1727871936,
"closed_at": null,
"price": {
"value": null
},
"conditional": {
"enabled": false,
"value": null,
"price": {
"value": null,
"type": null
}
},
"trailing": {
"enabled": false,
"value": null,
"percent": null
},
"timeout": {
"enabled": false,
"value": null
}
}
{
"error": "invalid_request",
"error_description": "Missing or invalid parameters"
}
{
"error": "Forbidden",
"error_description": "Api key not authorized for this action"
}