Skip to content

Get Orders History

Retrieve orders history for the authenticated subaccount with comprehensive filtering, sorting, and pagination capabilities, providing access to orders in any status with flexible query options.

Endpoint

POST https://papi.synthetix.io/v1/trade

Request

Request Format

{
  "params": {
    "action": "getOrderHistory",
    "subAccountId": "1867542890123456789",
    "status": ["placed", "filled"],
    "fromTime": 1730160000000,
    "toTime": 1730764800000,
    "limit": 100
  },
  "expiresAfter": 1704067500,
  "signature": {
    "v": 28,
    "r": "0x19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef",
    "s": "0xabcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600"
  }
}

Request Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getOrderHistory"
params.subAccountIdstringYesSubAccount ID to retrieve orders for
params.statusstring[]NoFilter by order status: ["started", "placed", "partially filled", "filled", "cancelling", "cancelled", "rejected", "modifying", "modified", "unknown"]
params.symbolstringNoFilter by specific trading pair symbol (e.g., "BTC-USDT")
params.sidestringNoFilter by order side: "buy" or "sell"
params.typestringNoFilter by order type (e.g., "LIMIT", "MARKET")
params.startTimeintegerNoStart timestamp in milliseconds (inclusive). Max 7-day range. Preferred over fromTime
params.endTimeintegerNoEnd timestamp in milliseconds (inclusive). Max 7-day range. Preferred over toTime
params.fromTimeintegerNoStart timestamp in milliseconds (inclusive). Deprecated — use startTime instead
params.toTimeintegerNoEnd timestamp in milliseconds (inclusive). Deprecated — use endTime instead
params.limitintegerNoMaximum number of orders to return (no default specified, max: 1000)
params.clientOrderIdstringNoFilter by client-provided order ID. Must not contain leading or trailing whitespace
ParameterTypeRequiredDescription
nonceuint64Yes*Positive integer nonce (must be incrementing and unique per request)
signatureobjectYesEIP-712 signature object
expiresAfteruint64NoUnix milliseconds expiration timestamp (5x rate limit on stale cancels)

:::info Common Parameters These are top-level request parameters. The subAccountId parameter is specified within the params object (see each endpoint's parameter table). :::

:::info SubAccountAction Endpoints Endpoints using SubAccountAction signing (getPositions, getOpenOrders, getOrdersHistory, getTrades, getFundingPayments, getSubAccount, getSubAccounts, getDelegatedSigners, getBalanceUpdates) do not require the nonce parameter. Only signature and optional expiresAfter are needed. :::

Filter Combinations

The endpoint supports powerful filter combinations:

  • All Orders: Omit status to get orders in any status
  • Historical Orders: "status": ["filled", "cancelled"] with time range
  • Recent Activity: Use startTime without endTime for orders since a specific time
  • Symbol-Specific: Combine symbol with any other filters
  • Client Order Lookup: Use clientOrderId to retrieve a specific order by its client-assigned ID

Response

Response Structure

FieldTypeDescription
statusstringAlways "ok" for successful requests or "error" for failures
responsearrayArray of order objects matching filter criteria (omitted when status is "error")
errorobjectError details (only present when status is "error")
request_idstringRequest tracking identifier

Success Response Examples

Multiple Orders with Various Statuses

{
  "status": "ok",
  "response": [
    {
      "order": {
        "venueId": "1958787130134106112",
        "clientId": "cli-1958787130134106112"
      },
      "orderId": "1958787130134106112",
      "symbol": "BTC-USDT",
      "side": "buy",
      "type": "LIMIT",
      "status": "FILLED",
      "quantity": "0.1",
      "price": "45000.00",
      "timeInForce": "GTC",
      "createdTime": 1755846234000,
      "updateTime": 1755846290000,
      "filledQuantity": "0.1",
      "filledPrice": "44998.50",
      "triggeredByLiquidation": false,
      "reduceOnly": false,
      "postOnly": false
    },
    {
      "order": {
        "venueId": "1958787130134106113",
        "clientId": "cli-1958787130134106113"
      },
      "orderId": "1958787130134106113",
      "symbol": "ETH-USDT",
      "side": "sell",
      "type": "LIMIT",
      "status": "PARTIALLY_FILLED",
      "quantity": "2.0",
      "price": "2800.00",
      "timeInForce": "GTC",
      "reduceOnly": false,
      "postOnly": false,
      "createdTime": 1755846235000,
      "updateTime": 1755846291000,
      "filledQuantity": "0.5",
      "filledPrice": "2801.25",
      "triggeredByLiquidation": false
    },
    {
      "order": {
        "venueId": "1958787130134106114",
        "clientId": "cli-1958787130134106114"
      },
      "orderId": "1958787130134106114",
      "symbol": "BTC-USDT",
      "side": "buy",
      "type": "LIMIT",
      "status": "NEW",
      "timeInForce": "GTC",
      "quantity": "0.05",
      "price": "44000.00",
      "reduceOnly": false,
      "postOnly": false,
      "createdTime": 1755846236000,
      "updateTime": 1755846236000,
      "filledQuantity": "0.0",
      "filledPrice": "0.0",
      "triggeredByLiquidation": false
    }
  ],
  "request_id": "5ccf215d37e3ae6d"
}

Empty Result Set

{
  "status": "ok",
  "response": [],
  "request_id": "5ccf215d37e3ae6f"
}

Order Object

FieldTypeDescription
orderobjectCanonical composite order identifier
order.venueIdstringVenue-generated order identifier
order.clientIdstringOptional client-provided order identifier
orderIdstringDeprecated legacy order identifier
symbolstringTrading pair symbol (e.g., "BTC-USDT")
sidestringOrder side: "buy" or "sell"
typestringOrder type: "LIMIT", "MARKET", "STOP_LOSS", "TAKE_PROFIT"
statusstringOrder status: "open", "filled", "partially_filled", "cancelled", "rejected"
quantitystringOriginal order quantity
pricestringOrder price (empty for market orders)
filledPricestringAverage fill price (empty if not filled)
triggerPricestringTrigger price for conditional orders
triggerPriceTypestringTrigger price type: "mark", "last", or "index"
timeInForcestringTime in force: "GTC", "IOC", or "FOK"
reduceOnlybooleanWhether order only reduces existing position
postOnlybooleanWhether order must be maker (no immediate match)
triggeredByLiquidationbooleanWhether order was triggered by a liquidation
createdTimeintegerOrder creation timestamp (Unix milliseconds)
updatedTimeintegerLast update timestamp (Unix milliseconds)
filledQuantitystringQuantity that has been filled
takeProfitOrderobjectLinked take-profit order identifier object
takeProfitOrderIdstringDeprecated linked take-profit venue identifier
stopLossOrderobjectLinked stop-loss order identifier object
stopLossOrderIdstringDeprecated linked stop-loss venue identifier
closePositionbooleanWhether order closes entire position

Migration Note: Use order.venueId as the canonical order identifier. orderId is deprecated and returned for compatibility.

Error Response

{
  "status": "error",
  "error": {
    "message": "Invalid time range: fromTime must be less than or equal to toTime",
    "code": "VALIDATION_ERROR"
  },
  "request_id": "5ccf215d37e3ae6d"
}

Advanced Filtering

Time-based Queries

// Orders from last 24 hours
"startTime": Date.now() - 86400000
 
// Orders in specific date range
"startTime": 1704067200000,
"endTime": 1704153600000
 
// Orders since specific time (no end)
"startTime": 1704067200000

fromTime and toTime are deprecated aliases for startTime and endTime respectively and are still accepted.

EIP-712 Signature

const domain = {
  name: "Synthetix",
  version: "1",
  chainId: 1,
  verifyingContract: "0x0000000000000000000000000000000000000000"
};
 
const types = {
  SubAccountAction: [
    { name: "subAccountId", type: "uint256" },
    { name: "action", type: "string" },
    { name: "expiresAfter", type: "uint256" }
  ]
};
 
const message = {
  subAccountId: "1867542890123456789",
  action: "getOrderHistory",
  expiresAfter: 0
};
 
const signature = await signer._signTypedData(domain, types, message);

Implementation Notes

  • Authentication requires signature by account owner or authorized delegate
  • Time range cannot exceed 7 days (604,800,000 milliseconds)
  • Time range filtering supports inclusive bounds with startTimeendTime validation
  • Use startTime/endTime for time range filtering; fromTime/toTime are deprecated aliases
  • Pagination: Use limit parameter (no default specified, max: 1000)
  • Status filtering accepts multiple values
  • clientOrderId filter must not contain leading or trailing whitespace

Signing

All trading methods are signed using EIP-712. Each successful trading request will contain:

  • A piece of structured data that includes the sender address
  • A signature of the hash of that structured data, signed by the sender

For detailed information on EIP-712 signing, see EIP-712 Signing.

Nonce Management

The nonce system prevents replay attacks and ensures order uniqueness:

  • Use any positive integer as nonce
  • Each nonce must be greater than the previous one (incrementing)
  • Date.now() is a convenient option, not a requirement
  • If nonce conflicts occur, increment by 1 and retry

:::note SubAccountAction Exception SubAccountAction endpoints (getPositions, getOpenOrders, getOrdersHistory, getTrades, getFundingPayments, getSubAccount, getSubAccounts, getDelegatedSigners, getBalanceUpdates) do not require a nonce. Only the signature and optional expiresAfter parameters are needed. :::

Error Handling

Common error scenarios:

Error CodeDescriptionRetryable
UNAUTHORIZEDEIP-712 signature validation failedNo
VALIDATION_ERRORRequest validation failedNo
MISSING_REQUIRED_FIELDRequired field is missingNo
INVALID_FORMATField format is invalidNo
INVALID_VALUEInvalid parameter valueNo
RATE_LIMIT_EXCEEDEDToo many requests in time windowYes
INSUFFICIENT_MARGINNot enough margin for tradeNo
ORDER_NOT_FOUNDOrder does not existNo
OPERATION_TIMEOUTOperation timed outYes
ErrorDescription
Invalid request formatRequest payload could not be parsed
Internal errorFailed to retrieve orders
Invalid time rangestartTime is greater than endTime, or time range exceeds 7 days
Invalid clientOrderIdclientOrderId contains leading or trailing whitespace
Invalid statusSpecified status is not recognized
Invalid symbolSpecified symbol is not recognized
Invalid sort fieldSpecified sortBy field is invalid
Invalid paginationLimit or offset out of valid range
Subaccount not foundSpecified subaccount does not exist