API reference ยท Orders
/v1/accounts/{account_id}/ordersPlace an order.
Read and tradeIdempotency-Key
Places an order on the account. A market order waits a moment for its fill. When the engine's answer is lost on the way, the answer is 202 with status unconfirmed: read the order again (Location) rather than placing it again.
Path parameters#
-
The account number.
Headers#
-
A unique value per action: a retry with the same value never does it twice.
Request body#
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
The order's side.
One of
buysell -
market: now, at the best price within your worst price. limit: at your price or better. stop_market: a market order once the last price reaches the stop. stop_limit: a limit once the last price reaches the stop.
One of
marketlimitstop_marketstop_limit -
sizedecimal stringThe size, in the base asset: a multiple of the market's size step. Give size or notional_usd.
-
notional_usddecimal stringThe size as a value in USD, rounded down to the size step.
-
limit_pricedecimal stringThe limit price (limit and stop_limit): a multiple of the tick size.
-
stop_pricedecimal stringThe trigger price (stop_market and stop_limit).
-
worst_pricedecimal stringMarket orders: the worst price you accept. Give worst_price or max_slippage_pct.
-
max_slippage_pctdecimal stringMarket orders: how far from the best price you accept, in percent (the default and bounds are in GET /v1/markets).
-
reduce_onlybooleanIt may only reduce or close your position, never open or add to one.
-
post_onlybooleanLimit orders: refused if it would fill at once.
-
time_in_forcestringgtc: until canceled. gtd: until expires_at. ioc and fok: fill now or end (a fill is always the whole order). Default: ioc for market orders, gtc otherwise.
One of
gtcgtdiocfok -
expires_atinteger, Unix msWith gtd: when it ends, from orders.gtd_min_seconds to orders.gtd_max_days ahead (GET /v1/limits).
-
client_order_idstringYour own id for the order: unique in this environment, 1 to 64 letters, digits and . _ : -
-
exitsOrderExitsExits placed when the order fills: the stop-loss for the filled size first, then the take-profits. From then on they are the position's exits. An empty object removes them.
Show 2 fields
-
take_profitarray of objectLimit orders on the profit side, each at price, or at distance or percent from the fill.
-
stop_lossobject or nullA stop on the loss side, at price, or at distance or percent from the fill; it may trail and move to break-even (as in a position's exits).
Show 7 fields
-
pricedecimal stringAn exact price.
-
distancedecimal stringA price difference from the fill price.
-
percentdecimal stringA percent of the fill price.
-
typestringThe stop's type (default stop_market).
One of
stop_marketstop_limit -
limit_offset_ticksintegerstop_limit: how many ticks past the stop its limit sits.
-
trailobjectAs a position's exits take it: { distance } or { percent }, with activation_price to start only once the price reaches it.
Show 3 fields
-
distancedecimal stringHow far behind the best price.
-
percentdecimal stringHow far behind, in percent of the best price.
-
activation_pricedecimal stringStart once the price reaches this.
-
-
break_evenobjectAs a position's exits take it: one of trigger_distance, trigger_percent, trigger_price, and offset_ticks.
Show 4 fields
-
trigger_distancedecimal stringHow far from the entry.
-
trigger_percentdecimal stringHow far from the entry, in percent.
-
trigger_pricedecimal stringOr this price.
-
offset_ticksintegerTicks beyond the entry, on the profit side.
-
-
-
Responses#
201Created
-
The order.
-
Your own id for it, when it was placed through the API.
-
The account number.
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
The order's side; null for an order placed elsewhere before the API saw it.
One of
buysell -
The order's type.
One of
marketlimitstop_marketstop_limittake_markettake_limit -
unconfirmed: the engine has not confirmed its last state yet.
One of
pendingworkingfilledcanceledrejectedexpiredunconfirmed -
The size, in the base asset.
-
How much filled.
-
Its limit price.
-
Its trigger price.
-
The average fill price.
-
The fee its fill paid.
-
It may only reduce a position; null when not known (placed elsewhere).
-
How long it rests.
One of
gtcgtdiocfok -
A gtd order: when it expires (it ends expired then); null otherwise.
-
It may only rest, never fill at once; null when not known (placed elsewhere).
-
Where it was placed: this API, an AI assistant (the MCP server), a trading platform, a strategy, a TradingView alert, or the system (a liquidation).
One of
apimcpplatformstrategytradingviewsystem -
The strategy that placed it (source strategy).
-
Exits attached to it (orders placed through the API).
-
Why it was canceled.
One of
usercancel_allflattenclose_allposition_closedposition_reversedclose_assistocoreplacedstrategykey_loss_stoprisk_rulesystem_restartexternal -
When it was placed.
-
When it filled.
-
When it was canceled.
-
updated_atinteger, Unix ms or nullIts latest change.
202Sent, but the engine's answer was lost on the way: read the order again (Location).
-
The order.
-
Your own id for it, when it was placed through the API.
-
The account number.
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
The order's side; null for an order placed elsewhere before the API saw it.
One of
buysell -
The order's type.
One of
marketlimitstop_marketstop_limittake_markettake_limit -
unconfirmed: the engine has not confirmed its last state yet.
One of
pendingworkingfilledcanceledrejectedexpiredunconfirmed -
The size, in the base asset.
-
How much filled.
-
Its limit price.
-
Its trigger price.
-
The average fill price.
-
The fee its fill paid.
-
It may only reduce a position; null when not known (placed elsewhere).
-
How long it rests.
One of
gtcgtdiocfok -
A gtd order: when it expires (it ends expired then); null otherwise.
-
It may only rest, never fill at once; null when not known (placed elsewhere).
-
Where it was placed: this API, an AI assistant (the MCP server), a trading platform, a strategy, a TradingView alert, or the system (a liquidation).
One of
apimcpplatformstrategytradingviewsystem -
The strategy that placed it (source strategy).
-
Exits attached to it (orders placed through the API).
-
Why it was canceled.
One of
usercancel_allflattenclose_allposition_closedposition_reversedclose_assistocoreplacedstrategykey_loss_stoprisk_rulesystem_restartexternal -
When it was placed.
-
When it filled.
-
When it was canceled.
-
updated_atinteger, Unix ms or nullIts latest change.
400The request is malformed.
{
"error": {
"type": "invalid_request",
"code": "invalid_request",
"message": "The request is not valid.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#invalid_request"
}
}401The request has no Authorization header.
{
"error": {
"type": "authentication",
"code": "missing_api_key",
"message": "No API key: send it as Authorization: Bearer <key>.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#missing_api_key"
}
}403The key only works from the addresses you listed.
{
"error": {
"type": "permission",
"code": "ip_not_allowed",
"message": "This address is not on the key's allowlist.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#ip_not_allowed"
}
}404The account does not exist in this environment, or the key does not reach it.
{
"error": {
"type": "not_found",
"code": "account_not_found",
"message": "No account with that id is reachable with this key.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_found"
}
}405The path exists, with other methods (see the Allow header).
{
"error": {
"type": "method",
"code": "method_not_allowed",
"message": "This route does not take that method.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#method_not_allowed"
}
}409The account exists but is not open on the trading engine yet.
{
"error": {
"type": "conflict",
"code": "account_not_ready",
"message": "This account is still being opened.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_ready"
}
}413The body is over the size limit.
{
"error": {
"type": "payload",
"code": "payload_too_large",
"message": "The body is too large.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#payload_too_large"
}
}414The URL is over the length limit.
{
"error": {
"type": "payload",
"code": "uri_too_long",
"message": "The address is too long.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#uri_too_long"
}
}415A body was sent without Content-Type: application/json.
{
"error": {
"type": "payload",
"code": "unsupported_media_type",
"message": "The body must be JSON.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#unsupported_media_type"
}
}422The account passed, failed, or was closed (details.reason).
{
"error": {
"type": "rule_rejection",
"code": "account_not_tradable",
"message": "This account cannot trade.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_tradable"
}
}429A request budget is used up (details.scope says which).
{
"error": {
"type": "rate_limit",
"code": "rate_limited",
"message": "Too many requests: slow down.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#rate_limited"
}
}500An error we did not expect.
{
"error": {
"type": "server",
"code": "internal_error",
"message": "Something went wrong on our side.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#internal_error"
}
}503A service this call needs did not answer.
{
"error": {
"type": "server",
"code": "temporarily_unavailable",
"message": "This cannot be done right now. Try again in a moment.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#temporarily_unavailable"
}
}Errors#
Codes this endpoint can return. Match on the code, never on the message.
- 401
missing_api_key - 401
invalid_api_key - 401
expired_api_key - 401
revoked_api_key - 401
invalid_token - 401
expired_token - 401
revoked_token - 401
wrong_resource - 401
wrong_environment - 403
ip_not_allowed - 403
api_disabled - 429
rate_limited - 503
temporarily_unavailable - 404
account_not_found - 409
account_not_ready - 422
account_not_tradable - 403
insufficient_permission - 400
invalid_request - 400
unknown_field - 400
idempotency_key_required - 400
invalid_idempotency_key - 400
idempotency_key_reused - 409
operation_in_progress - 503
state_unavailable - 503
stale_quote - 503
engine_unavailable - 503
engine_busy - 422
key_market_not_allowed - 404
market_not_found - 400
invalid_size_step - 400
invalid_price_tick - 422
price_out_of_band - 422
stop_already_triggered - 422
post_only_would_fill - 422
limit_inside_spread - 422
order_too_small - 422
working_order_cap - 422
key_reduce_only - 422
key_max_order_notional - 422
key_max_position_notional - 422
insufficient_margin - 422
exposure_cap_exceeded - 422
reduce_only_violation - 422
slippage_exceeded - 503
no_price - 422
market_closed - 422
market_not_offered - 422
market_option_held - 422
weekend_close - 422
market_halted - 422
position_liquidating - 422
account_paused - 422
insufficient_balance - 422
order_rejected - 409
client_order_id_conflict