Skip to content

Schedule Cancel (Dead Man's Switch)

Schedule an automatic cancel-all operation at a future time as a safety feature if you lose connectivity or system access.

Endpoint

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

Requests

Request Format

Schedule Cancel

{
  "params": {
    "action": "scheduleCancel",
    "subAccountId": "1867542890123456789",
    "timeoutSeconds": 300
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704067300,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Cancel Dead Man's Switch

{
  "params": {
    "action": "scheduleCancel",
    "subAccountId": "1867542890123456789",
    "timeoutSeconds": 0
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Request Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "scheduleCancel"
params.subAccountIdstringYesSubAccount ID
params.timeoutSecondsintegerYesTimeout in seconds; use 0 to cancel an existing schedule
nonceinteger (uint64)YesUnix milliseconds timestamp, incrementing
expiresAfterintegerNoOptional expiration timestamp in seconds
signatureobjectYesEIP-712 signature object

Time Requirements

  • Minimum timeout: 5 seconds (timeoutSeconds >= 5)
  • Maximum timeout: 86400 seconds (24 hours)
  • Cancel schedule: set timeoutSeconds: 0

Response

Success Response - Scheduled

{
  "status": "ok",
  "response": {
    "isActive": true,
    "message": "dead-man-switch armed",
    "timeoutSeconds": 300,
    "triggerTime": 1704067500000
  },
  "request_id": "5ccf215d37e3ae6d",
  "requestId": "5ccf215d37e3ae6d",
  "timestamp": 1704067200123
}

Success Response - Cancelled

{
  "status": "ok",
  "response": {
    "isActive": false,
    "message": "dead-man-switch disabled",
    "timeoutSeconds": 0
  },
  "request_id": "5ccf215d37e3ae6d",
  "requestId": "5ccf215d37e3ae6d",
  "timestamp": 1704067200456
}

Error Response

{
  "status": "error",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "timeoutSeconds must be less than or equal to 86400"
  },
  "request_id": "5ccf215d37e3ae6d",
  "requestId": "5ccf215d37e3ae6d",
  "timestamp": 1704067200000
}

Code Examples

Schedule Cancel in 5 Minutes

{
  "params": {
    "action": "scheduleCancel",
    "subAccountId": "1867542890123456789",
    "timeoutSeconds": 300
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Schedule Cancel in 1 Hour

{
  "params": {
    "action": "scheduleCancel",
    "subAccountId": "1867542890123456789",
    "timeoutSeconds": 3600
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704067300,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Dead Man's Switch Behavior

  • Automatic Trigger: All open orders are cancelled at the scheduled time
  • Single Use: Each schedule is used once and then removed
  • Overwrite: New schedule replaces existing one
  • Cancellation: Send timeoutSeconds: 0 to cancel an existing schedule

Use Cases

  • Trading Bot Safety: Cancel orders if bot loses connection
  • Manual Trading: Safety net for manual traders
  • Risk Management: Automatic order cancellation during volatile periods
  • Maintenance Windows: Clear orders before system maintenance

Validation Rules

  • nonce must be a timestamp in milliseconds and must be increasing
  • timeoutSeconds must be 0 (cancel) or between 5 and 86400 (inclusive)
  • Only one schedule can be active at a time; a new schedule overwrites the existing one
  • 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
timeoutSeconds too smallMust be 0 or at least 5
timeoutSeconds too largeExceeds maximum of 86400 seconds
Request expiredexpiresAfter timestamp has passed