> For the complete documentation index, see [llms.txt](https://docs.hyperlink.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperlink.xyz/api/exchange-methods.md).

# Exchange Methods

Every HyperLink action and read query is a `POST /exchange` request. There is no separate `/info` host. This page covers the request format and the action families; the pages below it list each method's full request and response schema.

HyperLink is a prime broker for Hyperliquid and mirrors Hyperliquid's `/exchange` action format and signing, so existing trading tooling can point at the HyperLink base URL.

## Request format

Each request uses the standard [envelope](/api/setup.md#request-envelope): an `action`, an EIP-712 `signature`, and a millisecond `nonce`. Two signing domains apply: agent-signed for trading and queries, user-signed for withdrawals and transfers. See [Authentication & Keys](/api/api-keys.md).

* **Write actions** return a status wrapper.
* **Read queries** return raw JSON.

## Example: place a limit order

A GTC limit buy of `0.1` of asset index `0`, agent-signed. Order fields use Hyperliquid's short-form names (`a` asset, `b` buy, `p` price, `s` size, `r` reduceOnly, `t` type, `c` client order id). HyperLink **requires** a `c` (cloid) on every order.

```bash
curl -X POST https://api.hyperlink.xyz/exchange \
  -H "Content-Type: application/json" \
  -d '{
  "action": {
    "type": "order",
    "orders": [
      { "a": 0, "b": true, "p": "50000", "s": "0.1", "r": false, "t": { "limit": { "tif": "Gtc" } }, "c": "0x1234567890abcdef1234567890abcdef" }
    ],
    "grouping": "na"
  },
  "nonce": 1712140800000,
  "signature": { "r": "0x...", "s": "0x...", "v": 27 }
}'
```

A resting order returns its order ID:

```json
{ "status": "ok", "response": { "type": "order", "data": { "statuses": [ { "resting": { "oid": 77738308 } } ] } } }
```

Larger client batches are accepted and split automatically; each internal batch carries up to **256 orders**. HyperLink enforces no minimum order size; Hyperliquid enforces a notional minimum (\~$10). See the **order** method below for the full schema.

## Action families

Each method below has its full schema and examples.

### Trading

| Action          | Purpose                                             |
| --------------- | --------------------------------------------------- |
| `order`         | Place limit or trigger orders.                      |
| `cancel`        | Cancel resting orders by order ID (`oid`).          |
| `cancelByCloid` | Cancel resting orders by client order ID (`cloid`). |

### Margin

Leverage is **per-asset** (no single global cap); margin mode cannot change with an open position.

| Action                    | Purpose                                    |
| ------------------------- | ------------------------------------------ |
| `updateLeverage`          | Set leverage and margin mode (`is_cross`). |
| `updateIsolatedMargin`    | Add or remove isolated margin.             |
| `topUpIsolatedOnlyMargin` | Set isolated margin to a target leverage.  |

### Transfers & withdrawals

Withdrawals are **user-signed** and gasless: you sign the request, HyperLink submits it on-chain for you. Agents cannot withdraw. See [Deposits & Withdrawals](/trade/deposits.md).

| Action             | Signing | Purpose                                                                 |
| ------------------ | ------- | ----------------------------------------------------------------------- |
| `withdraw`         | User    | Request a gasless on-chain withdrawal.                                  |
| `sendAsset`        | User    | Transfer funds between your own DEX balances (spot, perp).              |
| `usdClassTransfer` | User    | Move funds between spot and perp balances (legacy; prefer `sendAsset`). |
| `agentSendAsset`   | Agent   | Transfer assets with agent authorization.                               |

### Queries (raw JSON, agent-signed)

| Query                         | Returns                                       |
| ----------------------------- | --------------------------------------------- |
| `clearinghouseState`          | Perp positions, margin summary, withdrawable. |
| `spotClearinghouseState`      | Spot balances.                                |
| `openOrders`                  | Open orders.                                  |
| `userFills`                   | Recent fills.                                 |
| `portfolio`                   | Account value and PnL history.                |
| `userHistoricalOrders`        | Historical orders.                            |
| `userFundings`                | Funding payments.                             |
| `userNonFundingLedgerUpdates` | Deposits, withdrawals, transfers.             |
| `userRateLimit`               | Rate-limit usage.                             |
| `activeAssetData`             | Per-asset leverage and margin context.        |
| `extraAgents`                 | Approved agents.                              |

## Streaming

For real-time data and signed actions over a persistent connection, use the [WebSocket API](/api/websocket.md) instead of polling.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hyperlink.xyz/api/exchange-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
