Skip to main content

Endpoint

POST /exchange

Description

Cancel one or more open orders by internal order ID.

Request Body

ParameterTypeDescription
action*objectSee below
action.type*stringMust be "cancel"
action.cancels*arraySee below
action.cancels[].a*string | numberAsset symbol or index (kept for compatibility), e.g., "BTC" or 0
action.cancels[].o*stringInternal order ID (128-bit hex string)
nonce*numberTimestamp in milliseconds for replay protection, e.g., 1701234567890
expiresAfternumberOptional expiration timestamp (ms)
signature*objectSee below
signature.r*stringFirst 32 bytes of signature (hex string), e.g., "0x1234..."
signature.s*stringSecond 32 bytes of signature (hex string), e.g., "0x5678..."
signature.v*numberRecovery ID (27 or 28)

Response

{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": [
        { "success": true }
      ]
    }
  },
  "metadata": {
    "results": [
      {
        "oid": "0x1a2b3c4d5e6f7890...",
        "status": "committed",
        "orderId": "0x1a2b3c4d5e6f7890..."
      }
    ]
  }
}

Response Fields

FieldTypeDescription
statusstring”ok” on success
response.data.statusesarrayStatus for each cancel request
statuses[].successbooleantrue if cancel was committed
statuses[].errorstringError message (if failed)
metadata.resultsarrayDetailed processing information
metadata.results[].oidstringInternal order ID from the request
metadata.results[].statusstring”committed”, “rejected”, “not_found”, etc.
metadata.results[].orderIdstringInternal order ID (if found)

Example Request

curl -X POST https://api.notional.xyz/exchange \
  -H "Content-Type: application/json" \
  -d '{
    "action": {
      "type": "cancel",
      "cancels": [{
        "a": "BTC",
        "o": "0x1a2b3c4d5e6f7890..."
      }]
    },
    "nonce": 1701234567890,
    "signature": {
      "r": "0x1234...",
      "s": "0x5678...",
      "v": 27
    }
  }'

Error Responses

{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": [
        { "error": "Order not found in local state" }
      ]
    }
  }
}

Notes

  • Orders must be in “open” or “partial” status to be canceled
  • Maximum 256 cancels per request
  • Confirmation comes via CancelConfirmed/CancelFailed events