For the complete documentation index, see llms.txt. This page is also available as Markdown.

POST /account/margin-mode

Set the account default margin mode

Set the account default margin mode.

operationId: setMarginMode · CCXT method: setMarginMode

Declared server: https://api.testnet.nexus.xyz/v1. See Networks.

Authentication: hmacAuth.

Set the account default margin mode

post
/account/margin-mode

Changes the account-level default used when a new core-market position opens. A successful call changes this account default; it does not convert an open position or override forced market policy. If the selected market is owned by an open position or forced policy, that market remains in its current effective mode after the call. The response reports that unchanged effective mode and its source. The supplied market selects effective-mode context; the stored default remains account-wide.

Authorizations
X-API-KeystringRequired

HMAC API key authentication. Send three headers:

  • X-API-Key: your key ID (e.g. nx_a1b2c3...)
  • X-Timestamp: current time in unix milliseconds
  • X-Signature: hex(hmac_sha256(secret, timestamp + "\n" + METHOD + "\n" + path + "\n" + query + "\n" + sha256_hex(body)))

Timestamp must be within 30 seconds of server time.

The key is network-scoped; the signature is not. The canonical string above has no network component, so the same signed request is byte-identical on every host. What stops a testnet key from authenticating against mainnet is that the key does not exist in that host's key store — sign only for the host that minted the key, and never replay a signed payload against another network. Presented to the wrong host, a key is refused with the same opaque 401 as an unknown key and must not be retried there. See “API keys are bound to one network” in the API description.

Body
market_idstringRequired

Selects the market context for the effective-mode response; the stored default remains account-wide.

margin_modestring · enumRequiredPossible values:
Responses
200

The updated account default and selected market status as of the same actor turn.

application/json
market_idstringRequired
account_defaultstring · enumRequiredPossible values:
effective_modestring · enumRequiredPossible values:
sourcestring · enumRequiredPossible values:
mutablebooleanRequired

True only when POST can change the effective result through the account default.

post/account/margin-mode
POST /v1/account/margin-mode HTTP/1.1
Host: api.testnet.nexus.xyz
X-API-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 42

{
  "market_id": "text",
  "margin_mode": "cross"
}
{
  "market_id": "text",
  "account_default": "cross",
  "effective_mode": "cross",
  "source": "account_default",
  "mutable": true
}

Test it cannot sign this request. X-Signature is an HMAC computed per call: see Authentication, or use an SDK.


API version 0.9.131

Last updated