{
  "openapi": "3.1.0",
  "info": {
    "title": "Account REST API",
    "description": "\n\nWelcome to the **Hibachi.xyz Account API** - your gateway to building powerful crypto trading tools on top of our platform. Whether you want to automate strategies, access account data, or analyze market activity, our API gives you the access you need.\n\n---\n\nTo use the Hibachi.xyz API, you'll need a few credentials:\n\n- **API Key**  \n  Your API key is used to authenticate requests. You can generate and manage your API keys from your [Account Settings](https://hibachi.xyz/trade).\n\n- **Account ID**  \n  This unique identifier represents your trading account and is required for authenticated API operations. You can find your Account ID in the same account settings page.\n\n> ⚠️ **Note**: All endpoints under the `Account` and `Trade` API sections require authentication using your API key and account ID.\n",
    "license": {
      "name": ""
    },
    "version": "0.0.1"
  },
  "servers": [
    {
      "url": "https://api.hibachi.xyz",
      "description": "Production server"
    }
  ],
  "paths": {
    "/capital/balance": {
      "get": {
        "tags": [
          "Capital"
        ],
        "summary": "Balance",
        "description": "Get the balance of your account.\nThe returned balance is your net equity which includes unrealized PnL.",
        "operationId": "Balance",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account Capital Balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountBalanceResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/capital/history": {
      "get": {
        "tags": [
          "Capital"
        ],
        "summary": "History",
        "description": "Get the deposit and withdraw history of your account.\nIt will return most recent up to 100 deposit and 100 withdraw.",
        "operationId": "History",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Capital History",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountCapitalHistoryResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/capital/withdraw": {
      "post": {
        "tags": [
          "Capital"
        ],
        "summary": "Withdrawal",
        "description": "Submit a withdraw request.\n\n#### Signing\n\nSIGNATURE IS REQUIRED!\nUse `signature` field (65 bytes) to sign the message.\nRefer to the [Signing section](/api/signing) for more context.\n- assetId (4 bytes)\n- quantity (8 bytes): should be no more than maximalWithdraw returned by /trade/account/info endpoint, otherwise it will be rejected.\n- maxFees (8 bytes): should be at least returned by /market/exchange-info endpoint, otherwise it will be rejected.\n- withdrawalAddress (20 bytes)\n\n",
        "operationId": "Withdraw",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WithdrawRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WithdrawRequestBodyResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/capital/transfer": {
      "post": {
        "tags": [
          "Capital"
        ],
        "summary": "Transfer",
        "description": "Submit a transfer request.\n\n",
        "operationId": "Transfer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Capital Transfer Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapitalTransferResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/capital/deposit-info": {
      "get": {
        "tags": [
          "Capital"
        ],
        "summary": "Deposit Info",
        "description": "Get deposit address",
        "operationId": "Deposit Info",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          },
          {
            "name": "publicKey",
            "in": "query",
            "description": "The public key of the account",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
          }
        ],
        "responses": {
          "200": {
            "description": "Capital Deposit Info",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDepositInfoResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/trade/account/info": {
      "get": {
        "tags": [
          "Trade"
        ],
        "summary": "Account Info",
        "description": "Get account information/details\n\n# Key Response Fields\n- `balance` (net equity) and `maximalWithdraw`\n- (collateral) `assets`\n- `positions`\n- risk related summary: `totalOrderNotional`, `totalPositionNotional`, `totalUnrealizedPnl`\n- The `entryNotional` in `positions` is: entry price multiply by quantity.\n- `totalOrderNotional` does not count orders that will reduce your position.\n\n",
        "operationId": "Account Info",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Trade Account Info",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountInfoResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/trade/account/trades": {
      "get": {
        "tags": [
          "Trade"
        ],
        "summary": "Account Trades",
        "description": "Get the trades history of your account.\n\nIt will return most recent up to 100 records.\n\n### Optional Query Parameter\n- `page`:  this is optional, if not supply, it will default to 0 and return 100 trades. If suppy 100 trades in each page\n\n",
        "operationId": "Account Trades",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "this is optional, if not supply, it will default to 0 and return 100 trades. If suppy 100 trades in each page",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "example": "0"
          }
        ],
        "responses": {
          "200": {
            "description": "Trades",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountTradesResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/trade/account/settlements_history": {
      "get": {
        "tags": [
          "Trade"
        ],
        "summary": "Settlements History",
        "description": "This endpoint returns history of funding events.\n\n",
        "operationId": "Settlements History",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account Settlements History",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSettlementsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/trade/order": {
      "get": {
        "tags": [
          "Trade"
        ],
        "summary": "Get Order",
        "description": "Get the details about your one particular order.",
        "operationId": "Get Order",
        "parameters": [
          {
            "name": "orderIdVariant",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OrderIdVariant"
            }
          },
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      },
      "put": {
        "tags": [
          "Trade"
        ],
        "summary": "Modify Order",
        "description": "Modify an existing order.\n\n### Notes\n- ⚠️ You **cannot** modify an order that has been partially matched.\n- You can only update quantity and price. The symbol must remain the same.\n- A new unique nonce timestamp (same as if you were placing a new order).",
        "operationId": "Modify Order",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModifyOrderRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModifyOrderResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      },
      "post": {
        "tags": [
          "Trade"
        ],
        "summary": "Create Order",
        "description": "Submit a new order.\n\nIn the response, it will return the **order id** for this new order.",
        "operationId": "Create Order",
        "requestBody": {
          "description": "New order data",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrderRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Trade Order Create Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrderResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Trade"
        ],
        "summary": "Delete Order",
        "description": "Remove an existing order.\n\n##### Signing\n\n Include the following fields when creating the signature:\n\n* `accountId`\n* `orderId` OR `nonce`\n\n",
        "operationId": "Delete Order",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelOrderRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Trade Order Delete Response"
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    },
    "/trade/orders": {
      "get": {
        "tags": [
          "Trade"
        ],
        "summary": "Get Orders",
        "description": "Get the pending orders of your account.",
        "operationId": "Get Orders",
        "parameters": [
          {
            "name": "accountId",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AccountID"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Order"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      },
      "post": {
        "tags": [
          "Trade"
        ],
        "summary": "Batch Orders",
        "description": "Submit multiple new order requests for an account. Supports `place`, and `modify`.\n\nThe format is identical to **POST** `/trade/order` the only differences are:\n- `accountId` is specified in the top-level only once rather than for each order\n- each `order` element needs to have an `action` field which can be either `place` or `modify`\n\nIt will return a list of responses – one for each order in the input.",
        "operationId": "Batch Orders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBatchOrderRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Trade Order Delete Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateBatchOrderResultBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Trade"
        ],
        "summary": "Delete Orders",
        "description": "Allows you to batch cancel all open orders for an account.",
        "operationId": "Delete Orders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelAllOrdersRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteOrdersResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "api_key": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AccountBalanceResponse": {
        "type": "object",
        "required": [
          "balance"
        ],
        "properties": {
          "balance": {
            "type": "string"
          }
        }
      },
      "AccountCapitalHistoryResponse": {
        "type": "object",
        "required": [
          "transactions"
        ],
        "properties": {
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapitalTransaction"
            }
          }
        }
      },
      "AccountDepositInfoResponse": {
        "type": "object",
        "required": [
          "depositAddressEvm"
        ],
        "properties": {
          "depositAddressEvm": {
            "type": "string",
            "example": "0x0000000000000000000000000000000000000000"
          }
        }
      },
      "AccountID": {
        "type": "integer",
        "title": "AccountId",
        "format": "int64",
        "description": "You MUST make one Deposit to your account.\nYour Account ID will not be generated until your first deposit;\nthis ID is required for a lot of endpoints\nAccount ID: you will see `ID: XXX` below your API Key Name\nFor more information see [Pre-requisites](https://hibachi-docs.redocly.app/api/prerequisites)",
        "example": 140,
        "minimum": 0
      },
      "AccountInfoResponse": {
        "type": "object",
        "required": [
          "balance",
          "numFreeTransfersRemaining",
          "maximalWithdraw",
          "totalUnrealizedPnl",
          "totalUnrealizedFundingPnl",
          "totalUnrealizedTradingPnl",
          "totalPositionNotional",
          "totalOrderNotional",
          "assets",
          "positions"
        ],
        "properties": {
          "assets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Asset"
            },
            "description": "collateral"
          },
          "balance": {
            "type": "string",
            "description": "net equity of the account",
            "example": "14.186087"
          },
          "maximalWithdraw": {
            "type": "string",
            "description": "maximum amount that can be withdrawn from the account",
            "example": "4.152340"
          },
          "numFreeTransfersRemaining": {
            "type": "integer",
            "format": "int64",
            "example": 96,
            "minimum": 0
          },
          "positions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Position"
            }
          },
          "totalOrderNotional": {
            "type": "string",
            "description": "does not count orders that will reduce your position.",
            "example": "8.670066"
          },
          "totalPositionNotional": {
            "type": "string",
            "example": "14.246782"
          },
          "totalUnrealizedFundingPnl": {
            "type": "string",
            "example": "0.000000"
          },
          "totalUnrealizedPnl": {
            "type": "string",
            "example": "0.055460"
          },
          "totalUnrealizedTradingPnl": {
            "type": "string",
            "example": "0.055460"
          },
          "tradeMakerFeeRate": {
            "type": [
              "string",
              "null"
            ],
            "example": null
          },
          "tradeTakerFeeRate": {
            "type": [
              "string",
              "null"
            ],
            "example": null
          }
        }
      },
      "AccountSettlementsResponse": {
        "type": "object",
        "required": [
          "settlements"
        ],
        "properties": {
          "settlements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SettlementHistoryRow"
            }
          }
        }
      },
      "AccountTradesResponse": {
        "type": "object",
        "required": [
          "trades"
        ],
        "properties": {
          "trades": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Trade"
            }
          }
        }
      },
      "ApiOrderType": {
        "type": "string",
        "enum": [
          "LIMIT",
          "MARKET"
        ]
      },
      "Asset": {
        "type": "object",
        "required": [
          "symbol",
          "quantity"
        ],
        "properties": {
          "quantity": {
            "type": "string",
            "example": "13.130626"
          },
          "symbol": {
            "type": "string",
            "example": "USDT"
          }
        }
      },
      "BatchAction": {
        "type": "string",
        "enum": [
          "place",
          "modify",
          "cancel"
        ]
      },
      "CancelAllOrdersRequestBody": {
        "type": "object",
        "required": [
          "accountId",
          "signature",
          "nonce"
        ],
        "properties": {
          "accountId": {
            "type": "integer",
            "format": "int32",
            "example": 10,
            "minimum": 0
          },
          "nonce": {
            "type": "integer",
            "format": "int64",
            "example": 17147016,
            "minimum": 0
          },
          "signature": {
            "$ref": "#/components/schemas/SignatureDoc"
          }
        }
      },
      "CancelOrderRequestBody": {
        "allOf": [
          {
            "$ref": "#/components/schemas/OrderIdVariant"
          },
          {
            "type": "object",
            "required": [
              "accountId",
              "signature"
            ],
            "properties": {
              "accountId": {
                "$ref": "#/components/schemas/AccountID"
              },
              "signature": {
                "$ref": "#/components/schemas/SignatureDoc"
              }
            }
          }
        ]
      },
      "CapitalTransaction": {
        "oneOf": [
          {
            "type": "object",
            "title": "deposit",
            "required": [
              "id",
              "assetId",
              "blockNumber",
              "transactionHash",
              "quantity",
              "status",
              "timestamp",
              "transactionType"
            ],
            "properties": {
              "assetId": {
                "type": "integer",
                "format": "int32"
              },
              "blockNumber": {
                "type": "integer",
                "format": "int64"
              },
              "chain": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "etaTsSec": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "type": "integer",
                "format": "int32"
              },
              "quantity": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "timestamp": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "token": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "transactionHash": {
                "type": "string"
              },
              "transactionType": {
                "type": "string",
                "enum": [
                  "deposit"
                ]
              }
            }
          },
          {
            "type": "object",
            "title": "withdrawal",
            "required": [
              "id",
              "assetId",
              "withdrawalAddress",
              "quantity",
              "status",
              "timestamp",
              "isInstantWithdrawal",
              "transactionType"
            ],
            "properties": {
              "assetId": {
                "type": "integer",
                "format": "int32"
              },
              "etaTsSec": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "type": "integer",
                "format": "int32"
              },
              "instantWithdrawalChain": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "instantWithdrawalToken": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "isInstantWithdrawal": {
                "type": "boolean"
              },
              "quantity": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "timestamp": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "transactionHash": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "transactionType": {
                "type": "string",
                "enum": [
                  "withdrawal"
                ]
              },
              "withdrawalAddress": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "title": "transfer-in",
            "required": [
              "id",
              "assetId",
              "quantity",
              "status",
              "srcAccountId",
              "timestamp",
              "transactionType"
            ],
            "properties": {
              "assetId": {
                "type": "integer",
                "format": "int32"
              },
              "id": {
                "type": "integer",
                "format": "int32"
              },
              "quantity": {
                "type": "string"
              },
              "srcAccountId": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "srcAddress": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string"
              },
              "timestamp": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "transactionType": {
                "type": "string",
                "enum": [
                  "transfer-in"
                ]
              }
            }
          },
          {
            "type": "object",
            "title": "transfer-out",
            "required": [
              "id",
              "assetId",
              "quantity",
              "status",
              "timestamp",
              "transactionType"
            ],
            "properties": {
              "assetId": {
                "type": "integer",
                "format": "int32"
              },
              "id": {
                "type": "integer",
                "format": "int32"
              },
              "quantity": {
                "type": "string"
              },
              "receivingAccountId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int64",
                "minimum": 0
              },
              "receivingAddress": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string"
              },
              "timestamp": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              },
              "transactionType": {
                "type": "string",
                "enum": [
                  "transfer-out"
                ]
              }
            }
          }
        ]
      },
      "CapitalTransferResult": {
        "type": "object"
      },
      "CreateBatchOrderRequestBody": {
        "type": "object",
        "required": [
          "accountId",
          "orders"
        ],
        "properties": {
          "accountId": {
            "$ref": "#/components/schemas/AccountID"
          },
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderBatchPlace"
            }
          }
        }
      },
      "CreateBatchOrderResultBody": {
        "type": "object",
        "required": [
          "orders"
        ],
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderCreateModifyResult"
            }
          }
        }
      },
      "CreateOrderRequestBody": {
        "type": "object",
        "description": "Documentation for creating a new order.",
        "required": [
          "accountId",
          "nonce",
          "symbol",
          "side",
          "orderType",
          "quantity",
          "price",
          "signature",
          "maxFeesPercent"
        ],
        "properties": {
          "accountId": {
            "$ref": "#/components/schemas/AccountID"
          },
          "creationDeadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "optional"
          },
          "maxFeesPercent": {
            "type": [
              "string",
              "null"
            ],
            "description": "should be at least the returned value of /market/exchange-info endpoint. Otherwise, it will be rejected."
          },
          "nonce": {
            "type": "integer",
            "format": "int64",
            "description": "should be a unix timestamp either ms or us unique to this order",
            "minimum": 0
          },
          "orderFlags": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OrderFlags",
                "description": "optional"
              }
            ]
          },
          "orderType": {
            "$ref": "#/components/schemas/ApiOrderType"
          },
          "price": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantity": {
            "type": "string"
          },
          "side": {
            "$ref": "#/components/schemas/Side"
          },
          "signature": {
            "$ref": "#/components/schemas/SignatureDoc"
          },
          "symbol": {
            "type": "string",
            "description": "should be one of the symbol from one of the futureContracts returned by [/marketapi/market/exchange-info](/marketapi/market/exchange%20info) API"
          },
          "triggerPrice": {
            "type": [
              "string",
              "null"
            ],
            "description": "optional"
          },
          "twapConfig": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TWAPConfig",
                "description": "optional"
              }
            ]
          }
        }
      },
      "CreateOrderResult": {
        "type": "object",
        "required": [
          "orderId"
        ],
        "properties": {
          "orderId": {
            "$ref": "#/components/schemas/u64"
          }
        }
      },
      "DeleteOrdersResponse": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/Status"
          }
        }
      },
      "Direction": {
        "type": "string",
        "enum": [
          "Short",
          "Long"
        ]
      },
      "ModifyOrderRequestBody": {
        "allOf": [
          {
            "$ref": "#/components/schemas/OrderIdVariant",
            "description": "the order_id returned by /trade/order or /trade/orders API.\n(Currently we do not support using nonce as an identifier for modification.\nWe are working on a new Client-ID feature to enable this.)"
          },
          {
            "type": "object",
            "required": [
              "nonce",
              "accountId",
              "updatedQuantity",
              "updatedPrice",
              "signature",
              "maxFeesPercent"
            ],
            "properties": {
              "accountId": {
                "$ref": "#/components/schemas/AccountID"
              },
              "maxFeesPercent": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "should be at least the returned value of /marketapi/market/exchange-info endpoint. Otherwise, it will be rejected.",
                "example": "0.00045"
              },
              "nonce": {
                "type": "integer",
                "format": "int64",
                "description": "A new unique nonce timestamp (same as if you were placing a new order).",
                "minimum": 0
              },
              "signature": {
                "$ref": "#/components/schemas/SignatureDoc"
              },
              "updatedPrice": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "You can only update quantity and price. The symbol must remain the same.",
                "example": "3500.1"
              },
              "updatedQuantity": {
                "type": "string",
                "description": "You can only update quantity and price. The symbol must remain the same.",
                "example": "0.1"
              },
              "updatedTriggerPrice": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "You can only update quantity and price. The symbol must remain the same.",
                "example": "3500.1"
              }
            }
          }
        ]
      },
      "ModifyOrderResult": {
        "type": "object"
      },
      "Order": {
        "type": "object",
        "description": "! FOR DOCUMENTATION ONLY",
        "required": [
          "orderId",
          "contractId",
          "accountId",
          "side",
          "orderType",
          "symbol",
          "status",
          "totalQuantity",
          "availableQuantity"
        ],
        "properties": {
          "accountId": {
            "type": "integer",
            "format": "int64",
            "example": 10,
            "minimum": 0
          },
          "availableQuantity": {
            "type": "string",
            "example": "0.389560448"
          },
          "contractId": {
            "type": "integer",
            "format": "int32",
            "example": 1,
            "minimum": 0
          },
          "creationTime": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1748632398977,
            "minimum": 0
          },
          "finishTime": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1748632398977,
            "minimum": 0
          },
          "numOrdersRemaining": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "numOrdersTotal": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "orderId": {
            "type": "integer",
            "format": "int32",
            "example": 1234,
            "minimum": 0
          },
          "orderType": {
            "$ref": "#/components/schemas/OrderTypeInfo"
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "example": "3500.01"
          },
          "side": {
            "$ref": "#/components/schemas/Side"
          },
          "status": {
            "$ref": "#/components/schemas/OrderState"
          },
          "symbol": {
            "type": "string",
            "example": "ETH/USDT-P"
          },
          "totalQuantity": {
            "type": "string",
            "example": "0.389560448"
          },
          "triggerPrice": {
            "type": [
              "string",
              "null"
            ],
            "example": "1234.5432"
          }
        }
      },
      "OrderBatchPlace": {
        "type": "object",
        "required": [
          "action",
          "contractId",
          "symbol",
          "side",
          "orderType",
          "quantity",
          "signature",
          "maxFeesPercent"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/BatchAction"
          },
          "contractId": {
            "type": "integer",
            "format": "int32",
            "example": 1,
            "minimum": 0
          },
          "creationDeadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "optional"
          },
          "maxFeesPercent": {
            "type": [
              "string",
              "null"
            ],
            "description": "should be at least the returned value of /market/exchange-info endpoint. Otherwise, it will be rejected."
          },
          "nonce": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "should be a unix timestamp either ms or us unique to this order",
            "example": 1748632398977,
            "minimum": 0
          },
          "orderFlags": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OrderFlags",
                "description": "optional"
              }
            ]
          },
          "orderType": {
            "$ref": "#/components/schemas/OrderTypeInfo"
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "example": "3500.01"
          },
          "quantity": {
            "type": "string",
            "example": "5.0000"
          },
          "side": {
            "$ref": "#/components/schemas/Side"
          },
          "signature": {
            "$ref": "#/components/schemas/SignatureDoc"
          },
          "symbol": {
            "type": "string",
            "description": "should be one of the symbol from one of the futureContracts returned by /market/exchange-info API",
            "example": "ETH/USDT-P"
          },
          "triggerPrice": {
            "type": [
              "string",
              "null"
            ],
            "description": "optional",
            "example": "1234.5432"
          }
        }
      },
      "OrderCreateModifyResult": {
        "type": "object",
        "properties": {
          "nonce": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Unique identifier for the transaction. Either nonce OR order_id must be provided, but not both.",
            "minimum": 0
          },
          "orderId": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/u64",
                "description": "Order identifier. Either order_id OR nonce must be provided, but not both."
              }
            ]
          }
        }
      },
      "OrderFlags": {
        "type": "string",
        "enum": [
          "POST_ONLY",
          "IOC"
        ]
      },
      "OrderIdVariant": {
        "oneOf": [
          {
            "type": "object",
            "title": "nonce",
            "description": "Should be the `nonce`` used when creating the order.",
            "required": [
              "nonce"
            ],
            "properties": {
              "nonce": {
                "type": "integer",
                "format": "int64",
                "description": "Should be the `nonce`` used when creating the order.",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "title": "orderId",
            "description": "The `order id` returned by `/trade/order` or `/trade/orders` API.",
            "required": [
              "orderId"
            ],
            "properties": {
              "orderId": {
                "$ref": "#/components/schemas/u64",
                "description": "The `order id` returned by `/trade/order` or `/trade/orders` API."
              }
            }
          }
        ],
        "description": "Provide either a nonce or an order ID, but not both."
      },
      "OrderState": {
        "type": "string",
        "enum": [
          "PENDING",
          "SCHEDULED_TWAP",
          "PLACED",
          "REJECTED",
          "CANCELLED",
          "PARTIALLY_FILLED",
          "FILLED"
        ]
      },
      "OrderTypeInfo": {
        "type": "string",
        "enum": [
          "LIMIT",
          "MARKET"
        ]
      },
      "Position": {
        "type": "object",
        "required": [
          "symbol",
          "quantity",
          "direction",
          "notionalValue",
          "entryNotional",
          "unrealizedTradingPnl",
          "unrealizedFundingPnl",
          "openPrice"
        ],
        "properties": {
          "direction": {
            "$ref": "#/components/schemas/Direction"
          },
          "entryNotional": {
            "type": "string",
            "description": "entry price multiply by quantity.",
            "example": "10.302213"
          },
          "markPrice": {
            "type": [
              "string",
              "null"
            ],
            "example": "1234.5678"
          },
          "notionalValue": {
            "type": "string",
            "example": "10.225008"
          },
          "openPrice": {
            "type": "string",
            "example": "1234.5678"
          },
          "quantity": {
            "type": "string",
            "example": "0.004310550"
          },
          "symbol": {
            "type": "string",
            "example": "ETH/USDT-P"
          },
          "unrealizedFundingPnl": {
            "type": "string",
            "example": "0.077204"
          },
          "unrealizedTradingPnl": {
            "type": "string",
            "example": "0.000000"
          }
        }
      },
      "SettlementHistoryRow": {
        "type": "object",
        "title": "SettlementHistory",
        "required": [
          "symbol",
          "quantity",
          "indexPrice",
          "direction",
          "settledAmount",
          "timestamp"
        ],
        "properties": {
          "direction": {
            "$ref": "#/components/schemas/Direction"
          },
          "indexPrice": {
            "type": "string"
          },
          "quantity": {
            "type": "string"
          },
          "settledAmount": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "Side": {
        "type": "string",
        "enum": [
          "ASK",
          "BID"
        ]
      },
      "SignatureDoc": {
        "type": "string",
        "title": "Signature",
        "description": "SIGNATURE IS REQUIRED!\nUse `signature` field (65 bytes) to sign the message.\nRefer to the [Signing section](/api/signing) for more context.",
        "example": "0000000000000000000000000000000000000000000000000000000000000000"
      },
      "Status": {
        "type": "string",
        "enum": [
          "success",
          "failed"
        ]
      },
      "TWAPConfig": {
        "type": "object",
        "required": [
          "twapDurationMinutes",
          "twapQuantityMode"
        ],
        "properties": {
          "twapDurationMinutes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "twapQuantityMode": {
            "$ref": "#/components/schemas/TWAPQuantityMode"
          }
        }
      },
      "TWAPQuantityMode": {
        "type": "string",
        "enum": [
          "RANDOM",
          "FIXED"
        ]
      },
      "Trade": {
        "type": "object",
        "required": [
          "side",
          "bidAccountId",
          "askAccountId",
          "symbol",
          "quantity",
          "price",
          "timestamp",
          "id",
          "realizedPnl",
          "fee"
        ],
        "properties": {
          "askAccountId": {
            "$ref": "#/components/schemas/u64"
          },
          "askOrderId": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/u64"
              }
            ]
          },
          "bidAccountId": {
            "$ref": "#/components/schemas/u64"
          },
          "bidOrderId": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/u64"
              }
            ]
          },
          "fee": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "orderType": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "string"
          },
          "quantity": {
            "type": "string"
          },
          "realizedPnl": {
            "type": "string"
          },
          "side": {
            "$ref": "#/components/schemas/Side"
          },
          "symbol": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "TransferRequestBody": {
        "type": "object",
        "required": [
          "accountId",
          "coin",
          "dstPublicKey",
          "signature",
          "nonce",
          "quantity",
          "fees"
        ],
        "properties": {
          "accountId": {
            "$ref": "#/components/schemas/AccountID"
          },
          "coin": {
            "type": "string",
            "example": "USDT"
          },
          "dstPublicKey": {
            "type": "string",
            "description": "receivingAddress",
            "example": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
          },
          "fees": {
            "type": "string",
            "example": "0.02"
          },
          "nonce": {
            "type": "integer",
            "format": "int64",
            "example": 172851534,
            "minimum": 0
          },
          "quantity": {
            "type": "string",
            "example": "1"
          },
          "signature": {
            "$ref": "#/components/schemas/SignatureDoc"
          }
        }
      },
      "WithdrawRequestBody": {
        "type": "object",
        "required": [
          "accountId",
          "coin",
          "withdrawAddress",
          "signature",
          "network",
          "quantity"
        ],
        "properties": {
          "accountId": {
            "$ref": "#/components/schemas/AccountID"
          },
          "coin": {
            "type": "string",
            "example": "USDT"
          },
          "maxFees": {
            "type": [
              "string",
              "null"
            ],
            "description": "should be at least returned by /market/exchange-info endpoint, otherwise it will be rejected.",
            "example": "0.0113592"
          },
          "network": {
            "type": "string",
            "example": "arbitrum"
          },
          "quantity": {
            "type": "string",
            "description": "should be no more than maximalWithdraw returned by /trade/account/info endpoint, otherwise it will be rejected.",
            "example": "2.0113592"
          },
          "selfWithdrawal": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "signature": {
            "$ref": "#/components/schemas/SignatureDoc"
          },
          "withdrawAddress": {
            "type": "string"
          }
        }
      },
      "WithdrawRequestBodyResponse": {
        "type": "object"
      },
      "u32": {
        "type": "integer",
        "format": "int32",
        "minimum": 0
      },
      "u64": {
        "type": "integer",
        "format": "int64",
        "minimum": 0
      }
    },
    "securitySchemes": {
      "api_key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Authorization: APIKEY"
      }
    }
  },
  "security": [],
  "tags": [
    {
      "name": "Capital",
      "description": "\nWith the Capital endpoints manage your trading account, monitor and manage your portfolio including:\n- Balances\n- Positions\n- Transaction history\n- General account settings\n"
    },
    {
      "name": "Trade",
      "description": "\nUse the Trade endpoint to programmatically control your trades:\n- Submit new orders\n- Cancel existing ones\n- Track open orders and execution history\n"
    }
  ]
}