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",
"orderIds": ["1948058938469519360"]
},
"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 "cancelOrders" |
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 milliseconds expiration timestamp (5x rate limit on stale cancels) |
Response
Success Response
{
"status": "ok",
"response": {
"statuses": [
{
"canceled": {
"id": "1948058938469519360"
}
}
]
},
"request_id": "5ccf215d37e3ae6d",
"timestamp": "2025-01-01T00:00:00Z"
}Success Response - Multiple Orders
{
"status": "ok",
"response": {
"statuses": [
{
"canceled": {
"id": "1948058938469519360"
}
},
{
"canceled": {
"id": "1948058938469519361"
}
}
]
},
"request_id": "5ccf215d37e3ae6d",
"timestamp": "2025-01-01T00:00:00Z"
}Error Response
{
"status": "error",
"error": {
"message": "Order not found",
"code": "VALIDATION_ERROR"
},
"request_id": "5ccf215d37e3ae6d",
"timestamp": "2025-01-01T00:00:00Z"
}Code Examples
Cancel Single Order
{
"action": {
"action": "cancelOrders",
"orderIds": ["1948058938469519360"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
}
}Cancel Multiple Orders
{
"action": {
"action": "cancelOrders",
"orderIds": ["1948058938469519360", "1948058938469519361"]
},
"nonce": 1704067200000,
"signature": {
"v": 28,
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
}
}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
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 |