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

POST /account/margin

Add or remove isolated margin on an open position

Add or remove isolated margin on an open position.

operationId: addMargin · CCXT method: addMargin

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

Authentication: agentAuth, hmacAuth.

Add or remove isolated margin on an open position

post
/account/margin
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
anyOptional
Responses
200

Updated allocated margin and account collateral after the adjustment.

application/json

Allocated margin and free collateral after an isolated-margin adjustment. A 200 means the adjustment is recorded, with the collateral and the allocated margin moved together, and all three fields are always present. Position reads can show the previous allocated margin until the engine's copy catches up.

market_idstringRequired

The market whose position was adjusted.

Example: BTC-USDX-PERP
allocated_marginstringRequired

Arbitrary-precision decimal serialized as a string (lossless). Parse with a decimal type, never a float.

collateralstringRequired

Arbitrary-precision decimal serialized as a string (lossless). Parse with a decimal type, never a float.

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

{
  "market_id": "BTC-USDX-PERP",
  "amount": "100",
  "direction": "add"
}
{
  "market_id": "BTC-USDX-PERP",
  "allocated_margin": "350.00",
  "collateral": "9900.00"
}

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


API version 0.9.122

Last updated