Cancel Orders
Cancel one or more existing orders by their unique order IDs
Endpoint
POST https://papi.synthetix.io/v1/tradeRequest
Request Format
{
"params": {
"action": "cancelOrders",
"subAccountId": "1867542890123456789",
"orderIds": ["1948058938469519360"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"expiresAfter": 1704067300
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
params | object | Yes | Parameters object containing method details |
params.action | string | Yes | Must be "cancelOrders" |
params.subAccountId | string | Yes | SubAccount ID to cancel orders for |
params.orderIds | array | Yes | Array of orderId to cancel |
| 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 seconds 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, getDelegatedSigners, getBalanceUpdates) do not require the nonce parameter. Only signature and optional expiresAfter are needed.
:::
EIP-712 Type Definition
const CancelOrdersTypes = {
CancelOrders: [
{ name: "subAccountId", type: "uint256" },
{ name: "orderIds", type: "uint256[]" },
{ name: "nonce", type: "uint256" },
{ name: "expiresAfter", type: "uint256" }
]
}Note: orderIds is uint256[] in EIP-712, but sent as string[] in the JSON request body.
Response
Success Response
{
"status": "ok",
"response": {
"statuses": [
{
"canceled": {
"id": "1948058938469519360"
}
}
]
},
"request_id": "5ccf215d37e3ae6d"
}Success Response - Multiple Orders
{
"status": "ok",
"response": {
"statuses": [
{
"canceled": {
"id": "1948058938469519360"
}
},
{
"canceled": {
"id": "1948058938469519361"
}
}
]
},
"request_id": "5ccf215d37e3ae6d"
}Error Response
{
"status": "error",
"error": {
"message": "Order not found",
"code": "VALIDATION_ERROR"
},
"request_id": "5ccf215d37e3ae6d"
}Code Examples
Cancel Single Order
{
"params": {
"action": "cancelOrders",
"subAccountId": "1867542890123456789",
"orderIds": ["1948058938469519360"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"expiresAfter": 1704067300
}Cancel Multiple Orders
{
"params": {
"action": "cancelOrders",
"subAccountId": "1867542890123456789",
"orderIds": ["1948058938469519360", "1948058938469519361"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"expiresAfter": 1704067300
}Cancel Behavior
- Only OPEN/PARTIALLY_FILLED orders can be cancelled
- Filled portions of partially filled orders remain executed
- Cancellation is immediate upon validation
- Freed margin becomes available instantly
Order States
| State | Can Cancel |
|---|---|
| OPEN | ✅ Yes |
| PARTIALLY_FILLED | ✅ Yes (remaining quantity) |
| FILLED | ❌ No |
| CANCELLED | ❌ No |
| EXPIRED | ❌ No |
Validation Rules
noncemust be a timestamp in milliseconds and must be increasingorderIdsarray must contain at least one order ID- Each order ID must be a valid integer
- Orders must belong to the requesting account
- Must be signed by order 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
:::note SubAccountAction Exception
SubAccountAction endpoints (getPositions, getOpenOrders, getOrdersHistory, getTrades, getFundingPayments, getSubAccount, getDelegatedSigners, getBalanceUpdates) do not require a nonce. Only the signature and optional expiresAfter parameters are needed.
:::
Error Handling
Common error scenarios:
| Error | Description |
|---|---|
| Order not found | Order ID does not exist or not owned by user |
| Order already cancelled | Order was previously cancelled |
| Order already filled | Order was completely filled |
| Empty orderIds array | Must specify at least one order to cancel |
| 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 |