Create Margin Group

Creates a MarginX margin group with eligible DMA accounts and/or RapidX Portfolio venues.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Creates a MarginX margin group and adds the specified DMA accounts and/or RapidX Portfolio venues. DMA-only, RapidX-only and mixed groups are supported.

Rate limit: 10 requests per minute per API key.

API key access

Requires a signed LTP Open API request with TRANSFER permission. Creating a group does not itself borrow or transfer funds.

API key typeCan callScope
Main User Level API key (also the Main Portfolio key)YesEligible accounts and Portfolios belonging to the main user, including those assigned to sub-users.
Sub-user Level API keyNoCannot create groups.
Dedicated Sub Portfolio Level API keyNoCannot create groups.
Exchange-native API keyNoUse an LTP Main User Level API key.

Body parameters

Send a JSON object. Both member arrays are required; use [] for the member type you are not adding.

NameTypeRequiredDescription
namestringYesGroup name, 1–64 characters after trimming leading and trailing whitespace. The name must be unique within the main user's groups.
dmaGroupMemberListarray of objectsYesDMA accounts to add. Each item contains memberId, the DMA account ID. Do not supply a venue for DMA members.
rxGroupMemberListarray of objectsYesRapidX members to add. Each item contains memberId, the Portfolio ID, and venue, its exchange, such as BINANCE or OKX.

Members and limits

  • Use Get Trading Account Assets V2 to find account and Portfolio IDs. memberId identifies an account or Portfolio; it is not a margin group ID.
  • The two arrays must contain 1–30 members in total. A main user can have up to 20 groups.
  • A DMA account is identified by memberId; a RapidX member is identified by memberId and venue. Do not submit duplicate members or members already belonging to another group.
  • Accounts must be eligible for MarginX. Frozen, restricted or external accounts cannot be added. Visibility in the account list alone does not establish eligibility.
  • If any member fails validation, the creation request fails; invalid members are not silently skipped.

Signing a body containing member arrays

Follow Authentication for the headers and HMAC-SHA256 algorithm. For this endpoint, the signature uses the following representation of nested body values; the HTTP body remains standard JSON:

ValueRepresentation in the signing string
Empty array[]
DMA array[{memberId=51001}]
RapidX array[{memberId=71001, venue=BINANCE}]
Multiple elements or object fieldsSeparate with a comma and one space: ,

Sort top-level parameter names alphabetically. Preserve array order and the order of fields within each member object. Exclude top-level fields with JSON null values from the signing string; required fields must still contain valid values.

For the request below, the HMAC input is:

dmaGroupMemberList=[{memberId=51001}]&name=Group Alpha&rxGroupMemberList=[{memberId=71001, venue=BINANCE}]&<nonce>

Runnable Python example (replace the example IDs with eligible accounts):

import hashlib
import hmac
import json
import os
import time
import urllib.request

payload = {
    "name": "Group Alpha",
    "dmaGroupMemberList": [{"memberId": "51001"}],
    "rxGroupMemberList": [{"memberId": "71001", "venue": "BINANCE"}],
}

def signing_value(value):
    if isinstance(value, list):
        return "[" + ", ".join(signing_value(item) for item in value) + "]"
    if isinstance(value, dict):
        return "{" + ", ".join(
            key + "=" + signing_value(item) for key, item in value.items()
        ) + "}"
    return str(value)

nonce = str(int(time.time()))
parameters = "&".join(
    key + "=" + signing_value(payload[key])
    for key in sorted(payload) if payload[key] is not None
)
signature = hmac.new(
    os.environ["LTP_SECRET_KEY"].encode(),
    (parameters + "&" + nonce).encode(),
    hashlib.sha256,
).hexdigest()

request = urllib.request.Request(
    "https://api.liquiditytech.com/api/v2/lending/marginx/groups",
    data=json.dumps(payload).encode(),
    headers={
        "Content-Type": "application/json",
        "X-MBX-APIKEY": os.environ["LTP_API_KEY"],
        "nonce": nonce,
        "signature": signature,
        "ts": str(time.time_ns() // 1000),
    },
    method="POST",
)
with urllib.request.urlopen(request, timeout=30) as response:
    print(response.read().decode())

Response fields

FieldTypeDescription
codeinteger200 means success; any other value indicates an error.
messagestringResult message; success for a successful request.
data.idstringID of the newly created margin group. Use this group ID for subsequent group operations, not a member ID.
data.namestringSaved group name, with leading and trailing whitespace removed.

Success and error examples are available in the response panel.

Error codes

Business errors can return HTTP 200 with a non-success JSON code. Check code, not HTTP status alone. See Error Codes for shared errors.

CodeWhen it occursWhat to do
1000A member array has the wrong JSON type, for example an object instead of an array.Send both lists as JSON arrays. Example message: Invalid JSON type for rxGroupMemberList.
1001A required field is missing, including name, either member array, memberId, or a RapidX member's venue.Supply the field identified by the message.
100400Invalid parameters, such as an empty/overlong name, empty member IDs, no members, duplicate members or an unsupported RapidX venue.Check the body parameters and member limits.
-1Business validation fails, such as a duplicate group name or an unavailable member. Messages may include Account data temporarily unavailable or MarginX group data unavailable.Check the group name, account/Portfolio IDs, venue, supported exchange and member eligibility. These messages do not necessarily mean a transient outage; do not blindly retry.
2000Signature verification fails.Check the nested-value signing rules above and the authentication headers.
2003The calling API key level is not allowed.Use a Main User Level API key.
2004The calling key lacks a required permission.Use a key with TRANSFER permission.
100429The rate limit is exceeded.Reduce the request rate.

If a creation request times out, check the group list for the submitted name before resubmitting it.

Body Params
string
required
length between 1 and 64

Unique group name, 1–64 characters after trimming.

dmaGroupMemberList
array of objects
required

DMA members. Use [] if none. The two lists contain 1–30 members in total; a main user can have up to 20 groups.

dmaGroupMemberList*
rxGroupMemberList
array of objects
required

RapidX members. Use [] if none.

rxGroupMemberList*
Headers
string
required

Current Unix timestamp in seconds, also used in the signature.

string
required

HMAC-SHA256 hex digest. See the nested member-array signing example on this page.

string
required

Current Unix timestamp in microseconds.

Response

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json