POST https://api.hyperliquid.xyz/exchange with Content-Type: application/json. Every request requires a signed action object, a nonce (current timestamp in milliseconds), and a signature. Optionally, vaultAddress routes the action to a subaccount or vault โ in that case the master account signs and sets vaultAddress to the target address.
Source: Hyperliquid exchange endpoint docs
updateLeverage
Updates cross or isolated leverage on a single coin.
Action schema:
{
"type": "updateLeverage",
"asset": <index of coin>,
"isCross": true | false,
"leverage": <integer>
}
| Field | Type | Description |
|---|---|---|
type | String | "updateLeverage" |
asset | Number | Perpetual asset index from meta universe. |
isCross | Boolean | true for cross-margin leverage, false for isolated. |
leverage | Integer | Target leverage value, subject to per-coin leverage constraints. |
{"status": "ok", "response": {"type": "default"}}
updateIsolatedMargin
Adds or removes USDC margin from an isolated position by a specific dollar amount.
Action schema:
{
"type": "updateIsolatedMargin",
"asset": <index of coin>,
"isBuy": true,
"ntli": <integer with 6 decimals>
}
| Field | Type | Description |
|---|---|---|
type | String | "updateIsolatedMargin" |
asset | Number | Perpetual asset index from the meta response. |
isBuy | Boolean | Currently has no effect. The docs note this parameter will matter once hedge mode is introduced. |
ntli | Integer | Amount to add or remove, encoded with 6 decimal places. For example, 1000000 = 1 USDC, 5000000 = 5 USDC. Use a negative value to remove margin. |
{
"type": "updateIsolatedMargin",
"asset": 0,
"isBuy": true,
"ntli": 10000000
}
Successful response:
{"status": "ok", "response": {"type": "default"}}
Like what you're reading? Try it yourself โ this link supports ChartedTrader at no cost to you.
Trade on Hyperliquid with a 4% fee discount on your first $25M volume (Vaults and sub-accounts excluded) โ
topUpIsolatedOnlyMargin
An alternate action for targeting a specific leverage value rather than specifying a USDC amount. The docs describe it as:
{
"type": "topUpIsolatedOnlyMargin",
"asset": <asset>,
"leverage": <float string>
}
This adjusts isolated margin to reach the given leverage target, rather than requiring the caller to calculate the USDC delta themselves. The leverage field is a float string (e.g. "5.0").
Common request fields
| Field | Required | Description |
|---|---|---|
action | Yes | The action object (see above). |
nonce | Yes | Current timestamp in milliseconds. |
signature | Yes | EIP-712 signature. See the Python SDK for signing details. |
vaultAddress | No | 42-character hex address of a subaccount or vault. When set, the master account signs. |
expiresAfter | No | Millisecond timestamp after which the action is rejected. Actions consuming a stale expiresAfter count 5ร against rate limits. |
Asset indexing
For perpetuals, asset is the integer index in the universe array returned by the meta info endpoint. See Hyperliquid Asset IDs.
Signing
Signatures use the Python SDK's EIP-712 helpers. The SDK also handles subaccount routing via vaultAddress. Refer to the basic_vault.py example in the SDK for a working pattern.
---
*If you're building on Hyperliquid, the referral link https://app.hyperliquid.xyz/join/RICH888 gives you a 4% fee discount on your first $25M of trading volume (Vaults and sub-accounts excluded). Disclosure: this site may earn a referral commission.*
Continue with Hyperliquid
Browse the Hyperliquid guide hub for the complete user journey.
Related: Hyperliquid vaultTransfer API: Deposit or Withdraw Vault Funds via POST /exchange