orderHistory query returns your account’s terminated orders: fully filled, cancelled, rejected, or conditional orders that have triggered or been cancelled. Orders that are still resting or only partially filled do not appear here — query those with userOrders.
“Rejected” covers only orders rejected after an order ID was assigned, such as for insufficient margin. An order command rejected during validation — for example, outside the price band, reduce-only with no position, or a duplicate nonce — never receives an orderId and does not appear here; its result is returned in the response to the order request.
It shares its request parameters, pagination contract, error set, and value conventions with userFills and userFundingFlows.
Request
string
required
type (required) — Must be "orderHistory".string
required
accountId (required) — Your account ID. Must be greater than zero. A numeric value is also accepted.int
contractId — Restrict results to one contract. Use 0 or omit for all contracts.int64
startTime — Inclusive start of the time window, in Unix milliseconds. 0 or omitted means unbounded.int64
endTime — Inclusive end of the time window, in Unix milliseconds. 0 or omitted means unbounded. A startTime later than endTime returns 400 BAD_REQUEST.int
limit — Maximum rows in this page, from 1 to 1000. Defaults to 1000. A value outside the range returns HTTP 400 with code INVALID_PARAM, errors[].field "limit" and errors[].reason "OUT_OF_RANGE". See Errors for the shared error set.Response
Envelope fields
string
Always
"orderHistory".string
The account ID from the request.
int
Echoes the
contractId filter that was applied. 0 means no filter.int
Number of rows in this page. When
count equals your limit, another page may be available.boolean
true when the response has an upper bound on its size and the page was cut at a row boundary, so it holds fewer than limit rows while more rows remain. Continue paginating from the last row. false when the page was not cut.object[]
The terminated orders in this page, in ascending
updatedTimeMs order. Each element carries the fields below.Order object fields
number
Time the order reached its final state, in Unix milliseconds. This is the field you page on.
number
Block height at which the order was finalized.
number
Sequence number within the block.
string
Exchange-assigned order ID.
string | null
The client order ID you assigned at placement, or
null when none was set.number
Contract the order was placed on.
number
Market deployer the contract belongs to.
string
"B" for buy, "S" for sell.string
L, M, SL, SM, TPL, or TPM. See the enum table below.string
Gtc, Alo, Ioc, or Fok.boolean
true when the order could only reduce an existing position.string
Trigger price for a conditional or TP/SL order (raw integer string).
"0" for an ordinary order.number
Which price feed the trigger watched:
0 for mark price, 1 for oracle price.string
Limit price of the order (raw integer string).
string
Original order quantity (raw integer string).
string
Quantity filled over the order’s lifetime (raw integer string).
string
Remaining quantity (raw integer string). Always
"0" on a terminated row. The three quantities describe the whole life of the order: an order for 10 that filled 3 and was then canceled reports 10 / 3 / 0. The canceled quantity is origQty − filledQty.string
Open, Filled, Canceled, or Untriggered.string
How the order came about. See the enum table below.
number
Signed cancellation reason.
-1 indicates a cancellation internal to the matching engine.number
Rejection code for a rejected order.
number
Time the order was created, in Unix milliseconds.
number | null
Index of the originating transaction within its block. Together with
height, (height, txIndex) identifies that transaction. null when not available.There is no order-level fee or realized-PnL total in this response. Derive both by summing the matching rows in
userFills for the same orderId.Pagination
Rows come back in ascendingupdatedTimeMs order, at most limit per page. Pass the last row’s updatedTimeMs as the next request’s startTime; because startTime is inclusive, deduplicate the repeated boundary rows by orderId. When count equals limit, or truncated is true, another page may be available. See userFills for the full walkthrough.
