Skip to content

Place an order

POST https://rest.haasapi.com/v1/orders

Places a manual order on the account’s exchange - REAL MONEY on a real account; test against a simulated account first. Limit and market orders only in v1. Answers 201 with the created order’s id; the resting row is on GET /v1/accounts/{account_id}/orders. Send an Idempotency-Key so a retried request can never place twice.

Requires the trading scope.

{
"account_id": "af85799d-a214-4fd2-92ea-443c5eed18ad",
"market_tag": "GEMINI_BTC_USD",
"side": "buy",
"type": "limit",
"price": "39000",
"amount": "0.001"
}
Field Type Description
account_id string The account to trade on, from GET /v1/accounts.
market_tag string The market to trade, from GET /v1/markets. Must be a market of the account’s exchange.
side OrderSide buy or sell.
type OrderType limit or market. Other order types (stops, take-profits, trailing) are deliberately not part of v1 yet.
price string, nullable Limit price as a decimal string (“39000”). Required on limit orders; must be omitted on market orders.
amount string Amount to trade as a decimal string (“0.001”), in the market’s base currency. The exchange’s own minimum-amount and minimum-notional rules apply and refusals surface as 400s.
Terminal window
curl "https://rest.haasapi.com/v1/orders" \
-X POST \
-H "Authorization: Bearer hk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"account_id":"af85799d-a214-4fd2-92ea-443c5eed18ad","market_tag":"GEMINI_BTC_USD","side":"buy","type":"limit","price":"39000","amount":"0.001"}'

201 Created. Returns a OrderPlaced.

{
"order_id": "0f193c73-d5c2-4d13-8166-4e13c239a17b"
}
Field Type Description
order_id string The created order’s identifier - what DELETE /v1/orders/{order_id} takes.

All errors are RFC 9457 problem documents.

Status Description
400 The request is malformed (invalid limit, unusable cursor, …). (code: invalid_request) The trading engine or the exchange refused the order - the detail carries the engine’s own reason (minimum amount/notional, halted market, venue-specific refusals). A wallet that cannot cover the order answers 400 with code insufficient_funds; a missing or malformed field, a wrong price/type combination or an unsupported market_tag answers 400 with code invalid_request. (code: order_rejected)
401 Missing, malformed, disabled, or revoked API key. (code: invalid_api_key)
403 Your plan has lapsed - trading is not available. (code: forbidden)
404 No accessible account with that id. (code: account_not_found)
409 A request with this Idempotency-Key is still being processed. (code: idempotency_in_progress)
422 The Idempotency-Key was already used with a different request. (code: idempotency_key_reuse)
500 An unexpected error inside the API. Nothing about the request caused it; retry, and quote the instance value if it persists. (code: internal_error)
502 An internal service answered in a way the API could not serve. Retry. (code: upstream_error)
503 The request could not be served right now. Retry with the same key - do not discard it. (code: temporarily_unavailable)
504 An internal service did not answer within the deadline. Retry with backoff. (code: upstream_timeout)
{
"type": "https://docs.haasapi.com/errors/invalid_request",
"title": "Invalid request",
"status": 400,
"detail": "The request is malformed (invalid limit, unusable cursor, …).",
"code": "invalid_request"
}