Skip to content

Cancel an order

DELETE https://rest.haasapi.com/v1/orders/{order_id}

Cancels an open order. Orders are account-scoped - the channel routes the cancel through the account’s exchange connection, and an order id alone does not locate one - so account_id is a required query parameter. Answers 204 with no body. Naturally idempotent - no Idempotency-Key needed: cancelling the same order again answers 404, and nothing new is ever created.

Requires the trading scope.

Parameter Type Required Description
account_id string yes The account holding the order, from GET /v1/accounts.
Terminal window
curl "https://rest.haasapi.com/v1/orders/{order_id}?account_id=af85799d-a214-4fd2-92ea-443c5eed18ad" \
-X DELETE \
-H "Authorization: Bearer hk_live_YOUR_KEY"

204 Deleted - no content.

All errors are RFC 9457 problem documents.

Status Description
400 The request is malformed (invalid limit, unusable cursor, …). (code: invalid_request)
401 Missing, malformed, disabled, or revoked API key. (code: invalid_api_key)
404 No open order with that id on this account - unknown, already filled, or already cancelled. An unknown account_id answers 404 with code account_not_found. (code: order_not_found)
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"
}