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

# POST /leverage

Set per-market leverage for the connected account.

`operationId`: `setLeverage` · CCXT method: `setLeverage`

**Authentication:** `hmacAuth`.

Stores the account's leverage for one market. It is a standing setting, not an order parameter: initial margin for every subsequent order in that market is `notional / leverage`, so raising it lowers the margin an order requires and lowering it raises it.

Accepts any whole number in `1..=max`, where `max` is the market's effective ceiling — `min(max_leverage, floor(1 / initial_margin_rate))`, because the market's margin rate floors margin and so also caps leverage. Read `max_leverage` from `GET /markets/{market_id}/risk-params`. There is no fixed tier set; the preset chips a frontend offers (3x / 5x / 10x / 20x) are its own choice on top of this range.

Leverage left unset behaves as the market maximum, so a client need not call this before its first order. It changes the initial margin a NEW order requires; it does not move the projected liquidation price, which `POST /orders/preview` reports identically at any leverage because that price is set by the maintenance-margin rate.

## Request body

**Required.** `application/json`. **The contract declares no schema for this body** — only the example below, so a generated client gets an untyped body here.

```json
{
  "market_id": "BTC-USDX-PERP",
  "leverage": 10
}
```

## Responses

| Status | Body                     | Meaning                                                                                                                                                                                  |
| ------ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200`  | — *(no schema declared)* | The stored setting, echoed back.                                                                                                                                                         |
| `400`  | — *(no schema declared)* | `InvalidLeverage` — below the 1x floor (including `0`); or `LeverageExceedsMax` — above the market's effective ceiling, whose message carries both the requested value and that ceiling. |
| `401`  | — *(no schema declared)* | —                                                                                                                                                                                        |
| `403`  | — *(no schema declared)* | —                                                                                                                                                                                        |
| `404`  | — *(no schema declared)* | `MarketNotFound` — no such market.                                                                                                                                                       |
| `429`  | — *(no schema declared)* | —                                                                                                                                                                                        |

## Example

```bash
curl -X POST 'https://exchange.nexus.xyz/api/exchange/leverage' \
  -H 'X-API-Key: nx_7f3a1b...' \
  -H 'X-Timestamp: 1776033911836' \
  -H 'X-Signature: <hmac-sha256>' \
  -H 'Content-Type: application/json'
```

***

<sub>Generated from</sub> <sub></sub><sub>`eng/apps/exchange/api/openapi.json`</sub> <sub></sub><sub>(spec</sub> <sub></sub><sub>`0.9.27`</sub><sub>). Do not edit by hand — regenerate with</sub> <sub></sub><sub>`python3 product/docs/tools/api-reference/generate.py`</sub><sub>. Hand-authored context lives in the Guides pages.</sub>


---

# 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.nexus.xyz/api-reference/account/set-leverage.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.
