Skip to content

Cancel All Orders

Cancel all open orders for specific market(s), or all markets with the wildcard symbol.

Endpoint

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

Request

Request Format

{
  "params": {
    "action": "cancelAllOrders",
    "subAccountId": "1867542890123456789",
    "symbols": ["BTC-USDT", "ETH-USDT"],
    "source": "direct"
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  },
  "expiresAfter": 1704067300
}

Request Parameters

ParameterTypeRequiredDescription
paramsobjectYesParameters object containing method details
params.actionstringYesMust be "cancelAllOrders"
params.subAccountIdstringYesSubAccount ID to cancel orders for
params.symbolsarrayYesArray of symbols to cancel. Use ["*"] to cancel across all markets. [] is rejected. ["*", "ETH-USDT"] is rejected
params.sourcestringNoRequest source identifier for tracking and rebates (max 100 characters). Use "direct" for generic integrations
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. :::

EIP-712 Type Definition

const CancelAllOrdersTypes = {
  CancelAllOrders: [
    { name: "subAccountId", type: "uint256" },
    { name: "symbols", type: "string[]" },
    { name: "nonce", type: "uint256" },
    { name: "expiresAfter", type: "uint256" }
  ]
}

Wildcard Rules for symbols

  • ["*"]: Cancel all open orders across all markets
  • ["BTC-USDT", "ETH-USDT"]: Cancel only those markets
  • []: Rejected
  • ["*", "ETH-USDT"]: Rejected (wildcard must be used alone)

Response

Success Response

{
  "status": "ok",
  "response": [
    {
      "order": {
        "venueId": "1958787130134106112",
        "clientId": "cli-1958787130134106112"
      },
      "orderId": "1958787130134106112",
      "message": "",
      "symbol": "BTC-USDT"
    },
    {
      "order": {
        "venueId": "1958787130134106113",
        "clientId": "cli-1958787130134106113"
      },
      "orderId": "1958787130134106113",
      "message": "",
      "symbol": "ETH-USDT"
    }
  ],
  "request_id": "5ccf215d37e3ae6d"
}

Error Response

{
  "status": "error",
  "error": {
    "message": "Failed to unmarshal cancel all orders request",
    "code": "INVALID_FORMAT"
  },
  "request_id": "5ccf215d37e3ae6d"
}

Code Examples

Cancel All Markets

To cancel all orders across all markets, pass the wildcard symbol as a single-item array:

{
  "params": {
    "action": "cancelAllOrders",
    "subAccountId": "1867542890123456789",
    "symbols": ["*"]
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  },
  "expiresAfter": 1704067300
}

Cancel Specific Markets

To cancel orders for specific markets only:

{
  "params": {
    "action": "cancelAllOrders",
    "subAccountId": "1867542890123456789",
    "symbols": ["BTC-USDT", "ETH-USDT"]
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  },
  "expiresAfter": 1704067300
}

Cancel Behavior

  • Immediate Effect: Orders are cancelled immediately upon validation
  • Margin Release: Freed margin becomes available instantly
  • Partial Fills: Partially filled orders are cancelled for remaining quantity
  • All Order Types: Cancels limit, market, and trigger orders
  • Atomic Operation: All specified orders are cancelled together

Implementation Details

The API performs the following steps:

  1. Retrieves all open orders for the authenticated subaccount
  2. Iterates through each order and attempts to cancel it individually
  3. Returns an array of cancellation statuses for each processed order
  4. Each successful cancellation includes a canonical order object (venueId, optional clientId)

Migration Note: Use order.venueId as canonical. orderId remains deprecated for compatibility.

The message field contains an error description when cancellation fails for a specific order, and is empty on success. Do not treat a non-empty message as a success confirmation.

Validation Rules

  • nonce must be a positive integer, incrementing and unique per request
  • symbols array must contain valid market symbols or be empty for all markets
  • ["*"] cancels all markets and cannot be combined with other symbols
  • [] is invalid
  • Market symbols must be valid trading pairs
  • Must be signed by account owner or authorized delegate

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
Symbols must be non-emptysymbols array cannot be empty
Invalid wildcard usage* must be used alone as ["*"]
Invalid market symbolMarket symbol not recognized
No orders foundNo open orders to cancel
Request expiredexpiresAfter timestamp has passed