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.
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.
HMAC API key authentication. Send three headers:
X-API-Key: your key ID (e.g.nx_a1b2c3...)X-Timestamp: current time in unix millisecondsX-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.
Selects the market context for the effective-mode response; the stored default remains account-wide.
The updated account default and selected market status as of the same actor turn.
True only when POST can change the effective result through the account default.
Malformed JSON request body.
Authentication failed. All 401 responses return the same opaque body to prevent information leakage. A credential minted on a different network is one of the causes it hides — by design, so that a key id cannot be probed for existence on another network. Do not retry it against another host.
Refused by a jurisdiction control. Permanent for the caller's origin — do not retry. Branch on the code (identical to the x-nexus-block-reason header): US_RESTRICTED for the US write restriction, GEO_UNRESOLVED when the origin could not be resolved and the write failed closed, or RESTRICTED_JURISDICTION for the sanctions list. Reads are never refused by the write restriction. See “Jurisdiction restrictions” in the API description.
MarketNotFound — no such market.
Request data is semantically invalid, includes unknown fields, or supplies a margin_mode other than cross or isolated. Malformed JSON is rejected as 400.
Rate limit exceeded. Retryable — honour retry-after and back off; this is what separates a 429 from the permanent 403 jurisdiction refusals. Branch on the body's code, which is always RATE_LIMIT_EXCEEDED, and on bucket to learn WHICH budget bottlenecked — the buckets are independent, so a caller at its read ceiling can still submit orders and should not back off the whole client. Do not parse message: it is a diagnostic whose wording is not stable. Requests are charged by weight, so exhausting a budget takes fewer heavy calls than x-ratelimit-limit suggests. See “Rate limits” in the API description.
An unexpected internal error while persisting the account default.
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

