Cancel All Orders
Cancel all open orders for specific market(s) or all markets
Endpoint
POST https://papi.synthetix.io/v1/tradeRequest
Request Format
{
"params": {
"action": "cancelAllOrders",
"subAccountId": "1867542890123456789",
"symbols": ["BTC-USDT", "ETH-USDT"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"expiresAfter": 1704067300000
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
params | object | Yes | Parameters object containing method details |
params.action | string | Yes | Must be "cancelAllOrders" |
params.subAccountId | string | Yes | SubAccount ID to cancel orders for |
params.symbols | array | Yes | Array of market symbols to cancel. Empty array [] cancels all markets |
| Parameter | Type | Required | Description |
|---|---|---|---|
nonce | uint64 | Yes | Unix milliseconds timestamp (must be monotonically increasing) |
signature | object | Yes | EIP-712 signature object |
expiresAfter | uint64 | No | Unix 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).
:::
Response
Success Response
{
"status": "ok",
"response": [
{
"orderId": "1958787130134106112",
"message": "Order cancelled successfully"
},
{
"orderId": "1958787130134106113",
"message": "Order cancelled successfully"
}
],
"request_id": "5ccf215d37e3ae6d",
"timestamp": "2025-01-01T00:00:00Z"
}Error Response
{
"status": "error",
"error": {
"message": "Failed to unmarshal cancel all orders request",
"code": "INVALID_FORMAT"
},
"request_id": "5ccf215d37e3ae6d",
"timestamp": "2025-01-01T00:00:00Z"
}Code Examples
Cancel All Markets
To cancel all orders across all markets, provide an empty symbols array:
{
"params": {
"action": "cancelAllOrders",
"subAccountId": "1867542890123456789",
"symbols": []
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"expiresAfter": 1704067300000
}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": 1704067300000
}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:
- Retrieves all open orders for the authenticated subaccount
- Iterates through each order and attempts to cancel it individually
- Returns an array of cancellation statuses for each processed order
- Each successful cancellation includes the orderId in the response
Validation Rules
noncemust be a timestamp in milliseconds and must be increasingsymbolsarray must contain valid market symbols or be empty for all markets- 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 current timestamp in milliseconds as nonce
- Each nonce must be greater than the previous one
- Recommended: Use
Date.now()or equivalent - If nonce conflicts occur, increment by 1 and retry
Error Handling
Common error scenarios:
| Error | Description |
|---|---|
| Invalid signature | EIP-712 signature validation failed |
| Invalid market symbol | Market symbol not recognized |
| Nonce already used | Nonce must be greater than previous value |
| Rate limit exceeded | Too many requests in time window |
| Request expired | expiresAfter timestamp has passed |
| Error | Description |
|---|---|
| Invalid market symbol | Market symbol not recognized |
| No orders found | No open orders to cancel |
| Request expired | expiresAfter timestamp has passed |