{
  "openapi": "3.1.0",
  "info": {
    "title": "Hyperjutsu API reference",
    "version": "1.0.0",
    "description": "Integration reference for signed private account queries, native-style trading actions and WebSocket messages. Configure the settlement chain ID, brokerVault address and API origin for the deployment. Private reads use per-request EIP-712 authorization; trading actions retain their native signed envelope. See /api/authentication for signing and /api/ws for WebSocket transport."
  },
  "tags": [
    {
      "name": "Account data"
    },
    {
      "name": "Trading"
    }
  ],
  "paths": {
    "/info": {
      "post": {
        "operationId": "queryPrivateAccount",
        "summary": "Query private customer data",
        "tags": [
          "Account data"
        ],
        "description": "Returns private customer account data. Sign a PrivateRequest EIP-712 message over method POST, path /info, keccak256 of the UTF-8 RFC 8785 canonical JSON request body, a millisecond timestamp and a fresh bytes32 nonce. Send the proof in the three required headers below. The domain uses name Hyperjutsu, version 1, the configured settlement chain ID and brokerVault as verifyingContract. The recovered signer must own the user account or hold a current read grant. Public market-data queries are rejected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InfoRequest"
              },
              "examples": {
                "accountState": {
                  "summary": "Private account query body",
                  "value": {
                    "type": "clearinghouseState",
                    "user": "0x1111111111111111111111111111111111111111"
                  },
                  "description": "Canonicalize this body with RFC 8785, hash its UTF-8 bytes with Keccak-256, sign PrivateRequest and supply the required X-Hyperjutsu-* headers. Signature metadata is not inserted into the query body."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful private query; response shape depends on type.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "additionalProperties": true
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  ],
                  "description": "The selected query returns its native-style account result, status or exit claim. Full field tables and examples are on the per-query pages under /api/info."
                }
              }
            }
          },
          "401": {
            "description": "Authentication or authorization denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported or invalid request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Private access capacity exhausted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Financial service unavailable; do not infer an execution outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-authentication": {
          "mechanism": "EIP-712 per-request wallet signature",
          "required": true,
          "description": "Owner or owner-approved reader signs PrivateRequest for this exact POST /info query. Supply X-Hyperjutsu-Timestamp, X-Hyperjutsu-Nonce and X-Hyperjutsu-Signature. Trading permission includes reads; a read proof does not authorize trading or withdrawals.",
          "documentation": "/api/authentication",
          "carrier": "HTTP headers; in the browser private channel, use the encrypted inner authorization object",
          "headers": {
            "timestamp": "X-Hyperjutsu-Timestamp",
            "nonce": "X-Hyperjutsu-Nonce",
            "signature": "X-Hyperjutsu-Signature"
          },
          "proofSchema": {
            "$ref": "#/components/schemas/PrivateRequestProof"
          },
          "domain": {
            "name": "Hyperjutsu",
            "version": "1",
            "chainId": "configured settlement chain ID",
            "verifyingContract": "configured brokerVault address"
          },
          "primaryType": "PrivateRequest",
          "types": {
            "PrivateRequest": [
              {
                "name": "method",
                "type": "string"
              },
              {
                "name": "path",
                "type": "string"
              },
              {
                "name": "payloadHash",
                "type": "bytes32"
              },
              {
                "name": "timestamp",
                "type": "uint64"
              },
              {
                "name": "nonce",
                "type": "bytes32"
              }
            ]
          },
          "message": {
            "method": "POST",
            "path": "/info",
            "payloadHash": "keccak256(UTF8(RFC8785(requestBody)))",
            "timestamp": "decimal value of X-Hyperjutsu-Timestamp",
            "nonce": "value of X-Hyperjutsu-Nonce"
          },
          "signature": {
            "algorithm": "secp256k1 EIP-712",
            "encoding": "0x-prefixed 65-byte r || s || v",
            "lowS": true,
            "recoveryValues": [
              27,
              28
            ]
          },
          "freshness": {
            "timestampUnit": "Unix milliseconds",
            "maximumAgeMilliseconds": 30000,
            "maximumFutureSkewMilliseconds": 5000,
            "nonceBytes": 32,
            "nonceReuse": "Rejected for the same signer and deployment"
          },
          "canonicalization": {
            "standard": "RFC 8785 JSON Canonicalization Scheme",
            "encoding": "UTF-8",
            "hash": "Keccak-256",
            "maximumInteger": 9007199254740991,
            "rules": "Reject duplicate object keys, non-finite numbers and numeric values outside the safe integer range; sign the native query body without authorization metadata."
          }
        },
        "parameters": [
          {
            "name": "X-Hyperjutsu-Timestamp",
            "in": "header",
            "required": true,
            "description": "Decimal Unix milliseconds, equal to PrivateRequest.timestamp. Accepted from 30 seconds in the past through 5 seconds in the future. Private-read timestamps and numeric body fields must be safe JSON integers (at most 9007199254740991).",
            "schema": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)$"
            },
            "example": "1796250000000"
          },
          {
            "name": "X-Hyperjutsu-Nonce",
            "in": "header",
            "required": true,
            "description": "Fresh cryptographically random 32-byte nonce, encoded as 0x plus 64 hex characters. Accepted once per signer and deployment. A new read attempt requires a fresh proof; it does not consume a trading nonce.",
            "schema": {
              "$ref": "#/components/schemas/Bytes32"
            },
            "example": "0x3333333333333333333333333333333333333333333333333333333333333333"
          },
          {
            "name": "X-Hyperjutsu-Signature",
            "in": "header",
            "required": true,
            "description": "EIP-712 signature of PrivateRequest, encoded as the 65-byte concatenation r || s || v with low-s and recovery byte 27 or 28. The signature is request-bound, not a bearer token.",
            "schema": {
              "$ref": "#/components/schemas/WalletSignature"
            },
            "example": "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b"
          }
        ]
      }
    },
    "/exchange": {
      "post": {
        "operationId": "submitSignedAction",
        "summary": "Submit a signed customer action",
        "tags": [
          "Trading"
        ],
        "description": "Supported perpetual order/cancel/leverage actions use a native-style signed envelope. A read-request signature does not authorize trading. requestWithdrawal is a separate owner-signed extension, with HyperEVM USDC as the current normal payout destination. Rejecting or losing an HTTP response does not prove that an action was not executed; reconcile before retrying.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/NativeExchangeRequest"
                  },
                  {
                    "$ref": "#/components/schemas/WithdrawalRequest"
                  }
                ]
              },
              "examples": {
                "cancel": {
                  "summary": "Signed cancellation body",
                  "description": "Replace the example nonce and signature with those produced by the authorized signer. A sample signature is not valid authorization.",
                  "value": {
                    "action": {
                      "type": "cancel",
                      "cancels": [
                        {
                          "a": 0,
                          "o": 123
                        }
                      ]
                    },
                    "nonce": 1800000000000,
                    "signature": {
                      "r": "0x1111111111111111111111111111111111111111111111111111111111111111",
                      "s": "0x2222222222222222222222222222222222222222222222222222222222222222",
                      "v": 27
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action result; inspect outer status and each child result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExchangeResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication or authorization denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Unsupported or invalid request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Private access capacity exhausted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Financial service unavailable; do not infer an execution outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-authentication": {
          "mechanism": "signed action body",
          "required": true,
          "description": "The owner or owner-approved trading agent signs the native trading envelope. requestWithdrawal requires the owner signature over its separate withdrawal intent; read or trading agents cannot withdraw. Native actions share the same signing and nonce rules over HTTP and WebSocket.",
          "documentation": "/api/authentication",
          "carrier": "signature field in the action envelope",
          "nativeTradingSchema": {
            "$ref": "#/components/schemas/NativeExchangeRequest"
          },
          "withdrawalSchema": {
            "$ref": "#/components/schemas/WithdrawalRequest"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{40}$",
        "description": "Ethereum wallet address."
      },
      "Bytes32": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{64}$"
      },
      "Cloid": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{32}$",
        "description": "128-bit client order ID."
      },
      "WalletSignature": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{128}(1[bBcC])$",
        "description": "Canonical 65-byte wallet signature; recovery byte 27 or 28."
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer"
          },
          "msg": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "msg"
        ],
        "additionalProperties": false
      },
      "NativeSignature": {
        "type": "object",
        "properties": {
          "r": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{1,64}$"
          },
          "s": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{1,64}$"
          },
          "v": {
            "type": "integer",
            "enum": [
              27,
              28
            ]
          }
        },
        "required": [
          "r",
          "s",
          "v"
        ],
        "additionalProperties": false
      },
      "LimitOrder": {
        "type": "object",
        "properties": {
          "a": {
            "type": "integer",
            "minimum": 0,
            "description": "Supported perpetual asset index.",
            "maximum": 9999
          },
          "b": {
            "type": "boolean",
            "description": "True for buy; false for sell."
          },
          "p": {
            "type": "string",
            "description": "Positive decimal limit price."
          },
          "s": {
            "type": "string",
            "description": "Positive decimal size."
          },
          "r": {
            "type": "boolean",
            "description": "Reduce-only flag."
          },
          "t": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "object",
                "properties": {
                  "tif": {
                    "type": "string",
                    "enum": [
                      "Gtc"
                    ],
                    "description": "Only Gtc is supported by the current financial planner."
                  }
                },
                "required": [
                  "tif"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "limit"
            ],
            "additionalProperties": false
          },
          "c": {
            "$ref": "#/components/schemas/Cloid"
          }
        },
        "required": [
          "a",
          "b",
          "p",
          "s",
          "r",
          "t"
        ],
        "additionalProperties": false
      },
      "OrderAction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "order"
          },
          "orders": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/components/schemas/LimitOrder"
            }
          },
          "grouping": {
            "type": "string",
            "const": "na"
          }
        },
        "required": [
          "type",
          "orders",
          "grouping"
        ],
        "additionalProperties": false
      },
      "CancelAction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "cancel"
          },
          "cancels": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "type": "object",
              "properties": {
                "a": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9999
                },
                "o": {
                  "type": "integer",
                  "format": "uint64",
                  "minimum": 1
                }
              },
              "required": [
                "a",
                "o"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "type",
          "cancels"
        ],
        "additionalProperties": false
      },
      "CancelByCloidAction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "cancelByCloid"
          },
          "cancels": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "type": "object",
              "properties": {
                "asset": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9999
                },
                "cloid": {
                  "$ref": "#/components/schemas/Cloid"
                }
              },
              "required": [
                "asset",
                "cloid"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "type",
          "cancels"
        ],
        "additionalProperties": false
      },
      "LeverageAction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "updateLeverage"
          },
          "asset": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9999
          },
          "isCross": {
            "type": "boolean",
            "const": true
          },
          "leverage": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "type",
          "asset",
          "isCross",
          "leverage"
        ],
        "additionalProperties": false
      },
      "NativeExchangeRequest": {
        "type": "object",
        "properties": {
          "action": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OrderAction"
              },
              {
                "$ref": "#/components/schemas/CancelAction"
              },
              {
                "$ref": "#/components/schemas/CancelByCloidAction"
              },
              {
                "$ref": "#/components/schemas/LeverageAction"
              }
            ]
          },
          "nonce": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0
          },
          "signature": {
            "$ref": "#/components/schemas/NativeSignature"
          },
          "vaultAddress": {
            "type": "null",
            "description": "Subaccount/vault routing is unsupported in this profile; omit or use null."
          },
          "expiresAfter": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Optional native expiry in Unix milliseconds."
          }
        },
        "required": [
          "action",
          "nonce",
          "signature"
        ],
        "additionalProperties": false
      },
      "WithdrawalIntent": {
        "type": "object",
        "properties": {
          "withdrawalId": {
            "$ref": "#/components/schemas/Bytes32"
          },
          "owner": {
            "$ref": "#/components/schemas/Address"
          },
          "recipient": {
            "$ref": "#/components/schemas/Address"
          },
          "asset": {
            "$ref": "#/components/schemas/Address"
          },
          "amount": {
            "type": "integer",
            "format": "uint64",
            "minimum": 1,
            "description": "USDC amount in six-decimal atomic units."
          },
          "maxFee": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0,
            "description": "Maximum fee in six-decimal USDC atomic units."
          },
          "destination": {
            "type": "integer",
            "const": 0,
            "description": "Current normal payout destination: HyperEVM USDC."
          },
          "nonce": {
            "$ref": "#/components/schemas/Bytes32"
          },
          "deadline": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0,
            "description": "Unix seconds, unlike native order nonce/expiry timestamps."
          }
        },
        "required": [
          "withdrawalId",
          "owner",
          "recipient",
          "asset",
          "amount",
          "maxFee",
          "destination",
          "nonce",
          "deadline"
        ],
        "additionalProperties": false
      },
      "WithdrawalRequest": {
        "type": "object",
        "properties": {
          "action": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "requestWithdrawal"
              },
              "intent": {
                "$ref": "#/components/schemas/WithdrawalIntent"
              }
            },
            "required": [
              "type",
              "intent"
            ],
            "additionalProperties": false
          },
          "signature": {
            "$ref": "#/components/schemas/WalletSignature"
          }
        },
        "required": [
          "action",
          "signature"
        ],
        "additionalProperties": false,
        "description": "Owner-signed withdrawal extension. This uses the withdrawal EIP-712 intent, not the native trading signature or a read/trade agent."
      },
      "ExchangeResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "err"
            ]
          },
          "response": {
            "description": "Native-style action-specific result or business-error string. An acknowledgement is not proof of a fill or completed payout.",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": true
              },
              {
                "type": "string"
              }
            ]
          }
        },
        "required": [
          "status",
          "response"
        ],
        "additionalProperties": false
      },
      "clearinghouseStateQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "clearinghouseState"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "dex": {
            "type": "string",
            "const": ""
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "openOrdersQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "openOrders"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "dex": {
            "type": "string",
            "const": ""
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "frontendOpenOrdersQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "frontendOpenOrders"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "dex": {
            "type": "string",
            "const": ""
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "orderStatusQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "orderStatus"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "oid": {
            "oneOf": [
              {
                "type": "integer",
                "format": "uint64",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "$ref": "#/components/schemas/Cloid"
              }
            ]
          }
        },
        "required": [
          "type",
          "user",
          "oid"
        ],
        "additionalProperties": false
      },
      "historicalOrdersQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "historicalOrders"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "userFillsQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "userFills"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "aggregateByTime": {
            "type": "boolean",
            "const": false
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "userFillsByTimeQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "userFillsByTime"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "startTime": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "endTime": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "aggregateByTime": {
            "type": "boolean",
            "const": false
          }
        },
        "required": [
          "type",
          "user",
          "startTime"
        ],
        "additionalProperties": false
      },
      "coreDepositStatusQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "coreDepositStatus"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "hash": {
            "$ref": "#/components/schemas/Bytes32"
          }
        },
        "required": [
          "type",
          "user",
          "hash"
        ],
        "additionalProperties": false
      },
      "withdrawalStatusQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "withdrawalStatus"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          },
          "withdrawalId": {
            "$ref": "#/components/schemas/Bytes32"
          }
        },
        "required": [
          "type",
          "user",
          "withdrawalId"
        ],
        "additionalProperties": false
      },
      "exitClaimQuery": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "exitClaim"
          },
          "user": {
            "$ref": "#/components/schemas/Address"
          }
        },
        "required": [
          "type",
          "user"
        ],
        "additionalProperties": false
      },
      "InfoRequest": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/clearinghouseStateQuery"
          },
          {
            "$ref": "#/components/schemas/openOrdersQuery"
          },
          {
            "$ref": "#/components/schemas/frontendOpenOrdersQuery"
          },
          {
            "$ref": "#/components/schemas/orderStatusQuery"
          },
          {
            "$ref": "#/components/schemas/historicalOrdersQuery"
          },
          {
            "$ref": "#/components/schemas/userFillsQuery"
          },
          {
            "$ref": "#/components/schemas/userFillsByTimeQuery"
          },
          {
            "$ref": "#/components/schemas/coreDepositStatusQuery"
          },
          {
            "$ref": "#/components/schemas/withdrawalStatusQuery"
          },
          {
            "$ref": "#/components/schemas/exitClaimQuery"
          }
        ]
      },
      "PrivateRequestProof": {
        "type": "object",
        "description": "Authorization metadata for a PrivateRequest EIP-712 signature. For HTTP /info, map these fields to the required X-Hyperjutsu-* headers (timestamp encoded in decimal). For WS subscribe/unsubscribe, place them in auth. The browser private-channel inner request uses authorization. See /api/authentication for the domain, canonicalization and exact typed fields.",
        "properties": {
          "timestamp": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Unix milliseconds. Must be no more than 30000 ms old or 5000 ms in the future."
          },
          "nonce": {
            "$ref": "#/components/schemas/Bytes32",
            "description": "Fresh cryptographically random nonce; accepted once for this signer and deployment."
          },
          "signature": {
            "$ref": "#/components/schemas/WalletSignature",
            "description": "65-byte EIP-712 signature r || s || v, low-s, v=27 or 28."
          }
        },
        "required": [
          "timestamp",
          "nonce",
          "signature"
        ],
        "additionalProperties": false
      },
      "WsActionPostRequest": {
        "type": "object",
        "description": "Signed native action carried over /ws. request.payload is exactly the HTTP trading envelope. Only order, cancel, cancelByCloid and updateLeverage are accepted; requestWithdrawal remains HTTP-only. The outer id is correlation metadata, not a nonce or idempotency key.",
        "properties": {
          "method": {
            "type": "string",
            "const": "post"
          },
          "id": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Client-selected request correlation ID; unique among outstanding requests on this connection."
          },
          "request": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "action"
              },
              "payload": {
                "$ref": "#/components/schemas/NativeExchangeRequest"
              }
            },
            "required": [
              "type",
              "payload"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "method",
          "id",
          "request"
        ],
        "additionalProperties": false
      },
      "WsActionPostResponse": {
        "type": "object",
        "description": "Correlated response to a WebSocket action post. An action payload retains the HTTP exchange response; error payloads are strings. A lost response does not establish rejection or permit blind resubmission.",
        "properties": {
          "channel": {
            "type": "string",
            "const": "post"
          },
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991,
                "description": "Echo of the request correlation ID."
              },
              "response": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "action"
                      },
                      "payload": {
                        "$ref": "#/components/schemas/ExchangeResponse"
                      }
                    },
                    "required": [
                      "type",
                      "payload"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "error"
                      },
                      "payload": {
                        "type": "string",
                        "description": "Request/transport error description."
                      }
                    },
                    "required": [
                      "type",
                      "payload"
                    ],
                    "additionalProperties": false
                  }
                ],
                "discriminator": {
                  "propertyName": "type"
                }
              }
            },
            "required": [
              "id",
              "response"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "channel",
          "data"
        ],
        "additionalProperties": false
      },
      "WsPrivateSubscriptionRequest": {
        "type": "object",
        "description": "Signed private subscribe/unsubscribe message. Hash RFC 8785 canonical JSON of {method,subscription}, excluding auth. Sign PrivateRequest with method WS and path /ws using the same deployment domain and freshness rules as private HTTP reads.",
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "subscribe",
              "unsubscribe"
            ]
          },
          "subscription": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "clearinghouseState"
                  },
                  "user": {
                    "$ref": "#/components/schemas/Address"
                  },
                  "dex": {
                    "type": "string",
                    "const": ""
                  }
                },
                "required": [
                  "type",
                  "user"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "openOrders"
                  },
                  "user": {
                    "$ref": "#/components/schemas/Address"
                  },
                  "dex": {
                    "type": "string",
                    "const": ""
                  }
                },
                "required": [
                  "type",
                  "user"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "userFills"
                  },
                  "user": {
                    "$ref": "#/components/schemas/Address"
                  },
                  "aggregateByTime": {
                    "type": "boolean",
                    "const": false
                  }
                },
                "required": [
                  "type",
                  "user"
                ],
                "additionalProperties": false
              }
            ],
            "discriminator": {
              "propertyName": "type"
            }
          },
          "auth": {
            "$ref": "#/components/schemas/PrivateRequestProof"
          }
        },
        "required": [
          "method",
          "subscription",
          "auth"
        ],
        "additionalProperties": false
      }
    }
  },
  "x-documentation-audience": "technical integrators",
  "x-websocket": {
    "path": "/ws",
    "documentation": "/api/ws",
    "description": "The same private connection carries signed trading submissions, authenticated subscriptions and connection controls. These schemas cover action post requests/results and signed subscribe/unsubscribe messages. Control and data-message fields are documented on /api/ws.",
    "messages": [
      {
        "title": "Signed action post request",
        "schema": {
          "$ref": "#/components/schemas/WsActionPostRequest"
        }
      },
      {
        "title": "Action post response",
        "schema": {
          "$ref": "#/components/schemas/WsActionPostResponse"
        }
      },
      {
        "title": "Signed private subscription request",
        "schema": {
          "$ref": "#/components/schemas/WsPrivateSubscriptionRequest"
        }
      }
    ]
  }
}
