Modify Order
Modify existing orders by changing their price and/or quantity. This is essentially a cancel-and-replace operation that maintains the order's position in the queue while updating its parameters.
Endpoint
POST https://papi.synthetix.io/v1/tradeRequest
Request Format
{
"params": {
"action": "modifyOrder",
"subAccountId": "1867542890123456789",
"orderId": "12345",
"price": "45000.50",
"quantity": "2.50"
},
"nonce": 1703123456789,
"signature": {
"v": 27,
"r": "0x5a3c2b1d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789",
"s": "0x1a2b3c4d5e6f7890abcdef0123456789abcdef0123456789abcdef0123456789"
},
"expiresAfter": 1703123456789
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
params | object | Yes | Action object containing modification details |
params.action | string | Yes | Must be "modifyOrder" |
params.subAccountId | string | Yes | SubAccount ID that owns the order |
params.orderId | string | Yes | Order ID to modify (string for JS BigInt compatibility) |
params.price | string | No* | New price as decimal string |
params.quantity | string | No* | New quantity as decimal string |
params.triggerPrice | string | No* | New trigger price for conditional orders (triggerSl, triggerTp) |
nonce | number | Yes | Timestamp in milliseconds for signature uniqueness |
signature | object | Yes | EIP-712 signature components |
expiresAfter | number | No | Optional expiration timestamp in milliseconds |
*At least one of price, quantity, or triggerPrice must be provided for the modification to be valid. |
Response
Success Response
{
"status": "ok",
"response": {
"orderId": "12345",
"status": "modified",
"price": "45000.50",
"quantity": "2.50"
},
"request_id": "req-123456789",
"timestamp": "2025-01-01T00:00:00Z"
}Error Response
{
"status": "error",
"error": {
"code": "VALIDATION_ERROR",
"message": "Order not found or does not belong to this subaccount",
"details": null
},
"request_id": "req-123456789",
"timestamp": "2025-01-01T00:00:00Z"
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | Always "ok" for successful requests or "error" for failures |
response | object | Contains operation results (omitted when status is "error") |
response.orderId | string | The modified order ID |
response.status | string | Always "modified" for successful operations |
response.price | string | New price (only if modified) |
response.quantity | string | New quantity (only if modified) |
error | object | Error details (only present when status is "error") |
requestId | string | Request tracking identifier |
timestamp | integer | Unix milliseconds timestamp |
Code Examples
Modify Order Price Only
{
"params": {
"action": "modifyOrder",
"orderId": "12345",
"price": "49000.00"
},
"nonce": 1703123456789,
"signature": {
"v": 27,
"r": "0x5a3c2b1d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789",
"s": "0x1a2b3c4d5e6f7890abcdef0123456789abcdef0123456789abcdef0123456789"
},
"subAccountId": "1",
}Modify Order Quantity Only
{
"params": {
"action": "modifyOrder",
"orderId": "12346",
"quantity": "0.50"
},
"nonce": 1703123466789,
"signature": {
"v": 27,
"r": "0x5a3c2b1d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789",
"s": "0x1a2b3c4d5e6f7890abcdef0123456789abcdef0123456789abcdef0123456789"
},
"subAccountId": 1
}Modify Both Price and Quantity
{
"params": {
"action": "modifyOrder",
"orderId": "12347",
"price": "95.50",
"quantity": "5.00"
},
"nonce": 1703123476789,
"signature": {
"v": 27,
"r": "0x5a3c2b1d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789",
"s": "0x1a2b3c4d5e6f7890abcdef0123456789abcdef0123456789abcdef0123456789"
},
"subAccountId": "1",
"expiresAfter": 1703123506789
}Important Behavior
- Queue Position: The operation preserves the order's position in the queue when possible
- Atomic Operation: The modify operation is atomic - either the entire modification succeeds or fails
- Partial Modification: If only one field (price or quantity) is provided, the other field retains its current value
- Precision: All monetary values use string representation to avoid floating-point precision issues
Validation Rules
Request Validation
- Action Type: Must be exactly
"modifyOrder" - Order ID: Must be a valid positive integer string
- Modification Fields: At least one of
price,quantity, ortriggerPricemust be provided - Price Format: If provided, must be a valid decimal string
- Quantity Format: If provided, must be a valid decimal string
- Trigger Price Format: If provided, must be a valid decimal string
- Order Existence: The order must exist and belong to the specified subaccount
- Signature Verification: EIP-712 signature must be valid for the request parameters
Business Logic Validation
- Order must be in an open/active state
- Cannot modify orders that are already filled or cancelled
- Price/quantity changes must comply with market rules
- Account must have sufficient margin for the modification
Authentication & Authorization
- Request must include valid EIP-712 signature using the ModifyOrder typed data structure
noncemust be a timestamp in milliseconds and must be increasing per address- Each nonce can only be used once (replay protection)
expiresAftertimestamp must be in the future (if provided)
{
"name": "Synthetix",
"version": "1",
"chainId": 1,
"verifyingContract": "0x0000000000000000000000000000000000000000"
}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 Code | Description |
|---|---|
VALIDATION_ERROR | Request validation failed (invalid format, missing fields, etc.) |
INVALID_FORMAT | Request body is not valid JSON |
INTERNAL_ERROR | Server-side processing error |
UNAUTHORIZED | Authentication failed |
FORBIDDEN | Wallet does not own the specified subaccount |
| Invalid signature | EIP-712 signature verification failed |
| Signature address mismatch | Signature address does not match wallet address |
| Nonce already used | Nonce has been used in a previous request (replay protection) |
| Request expired | expiresAfter timestamp has passed |
| Order not found | Order ID does not exist or not owned by user |
| Order not modifiable | Order is filled, cancelled, or not a limit order |
| Invalid order parameters | New order parameters are invalid |