Repay MarginX Debt

Submit a repayment, interest first then principal. Main User Level TRANSFER required. LTP covers transaction fees; borrowing interest remains payable.

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

Submits a repayment against one MarginX debt. The payment first covers outstanding interest and then reduces principal. Select the actual paying DMA account or RapidX Portfolio exchange account in the same margin group as the debt.

Rate limit: 10 requests per minute per API key.

LTP covers any transaction fees incurred during borrowing and repayment. You do not pay these fees. Borrowing interest is charged separately under the applicable terms.

API key access

Requires a signed request with TRANSFER permission. See Authentication.

API key typeCan callScope
Main User Level API key (also the Main Portfolio key)YesRepay its debts using an eligible member account in the same group.
Sub-user Level API keyNoNot supported.
Dedicated Sub Portfolio Level API keyNoNot supported, even if it holds the debt or repayment funds.
Exchange-native API keyNoUse an LTP Main User Level API key.

READ alone does not authorize repayment. Repayment uses TRANSFER, not a separate lending-write permission.

Before repaying

  1. Query Get Outstanding Debts for the debtId, currency, outstanding principal and interest.
  2. Choose the same-group DMA wallet or RapidX Portfolio exchange account that will actually provide the funds. It can differ from the member carrying the debt. An LTP Funding account is not a supported source; a DMA exchange wallet named FUNDING, such as Bitget's Funding wallet, is a different account type.
  3. Check currency precision, minimum repayment quantity and source transferability. An account's generic available value is not a universal transferable balance. For RapidX, see Get Portfolio Assets Details and maxTransferable; DMA accounts depend on their exchange-native transfer rules. The server performs the final funds and route checks.
  4. Submit once and track every returned requestId through Get Borrowing and Repayment Orders. Recheck outstanding debt to confirm the reduction.

JSON body parameters

NameTypeRequiredDescription
clientOrderIdstringNoCustomer-supplied identifier for the repayment request. When supplied, exactly 18 ASCII letters or digits; case is preserved. Both resulting records share this value if repayment splits.
debtIdstringYesDebt identifier from the outstanding-debt endpoint, not a borrowing requestId, group ID or member ID.
amountstringYesPositive total repayment quantity in the debt's currency. Includes both interest and principal; it is not a principal-only instruction. Must satisfy applicable precision and minimum requirements.
fromPrimeTypestringYesdma or rapidx.
fromIdstringYesDMA account ID or RapidX Portfolio ID of the actual payer.
fromAccountTypestringYesPaying DMA wallet type, or the specific RapidX exchange. See Account Types.

Do not send groupId, currency, toId or a system requestId: the debt determines its group, currency and debt-carrying member. Enum input is case-insensitive; IDs and clientOrderId are preserved.

Amount allocation

Repayment is interest first, then principal. If a debt has principal 65 and interest 6.8, submitting 41 repays 6.8 interest and 34.2 principal, leaving principal 30.8 and interest 0.

A partial repayment reduces the existing debt. When borrowing requests have accumulated into the same debt, repayment does not target a selected original borrowing order. Account for existing interest when calculating how much principal a repayment will remove.

The contract rejects an amount exceeding the current repayable debt instead of silently reducing it. Other in-progress repayments may occupy part of that amount.

Response fields

FieldTypeDescription
codeinteger200 means the repayment request was accepted, not that funds were deducted or debt reduced.
messagestringResult message.
data.clientOrderIdstring or nullEcho of the customer identifier; null if omitted.
data.requestIdsarray of stringsAll system order identifiers generated for this request: one for a principal-only repayment, two when repayment covers both interest and principal.
data.statusstringInitial status in the submission receipt, NEW. Track each order for its actual execution state.
data.amountstringTotal repayment quantity accepted for the customer request, not the amount of each split record.
data.currencystringCurrency determined from the debt.

Split orders and actual funds movement

Record typeAmountfromto
REPAY_INTERESTInterest portion.Actual customer-selected paying account.Member whose interest debt is reduced.
REPAY_PRINCIPALPrincipal portion.Actual customer-selected paying account.Member whose principal debt is reduced.

For repayment, to identifies the account whose debt is reduced, not the destination receiving repayment funds. It is not LTP Lending Service. memberId always equals to.id; DMA to.accountType may be null when no destination wallet is identified.

Each split record has its own requestId, amount and execution status. They share clientOrderId and can share one transferId: the successful 41 repayment created two orders but only one 41 funds transfer. Do not count the same transfer twice. Repayment history records return debtId=null; retain the submitted debt ID separately.

Track all entries in requestIds, or query by clientOrderId and inspect every matching record. A single successful record is not proof that the entire split request succeeded. Execution statuses are NEW, PROCESSING, SUCCESS, FAIL; no extra orderId or nested items is returned.

Tracking and retries

After execution succeeds, query outstanding debts again. A fully cleared principal-and-interest debt is no longer returned; a partially repaid debt remains with its reduced amounts. Account-asset updates may arrive later than order status.

If submission times out, reconcile using the original customer identifier before another submission. Do not repeat a full repayment because one record is still processing or one split record failed; first check every order and the remaining debt to avoid another deduction.

Error codes

Check both HTTP status and JSON code. See Error Codes for shared errors. Field-validation messages are dynamic and can identify multiple fields.

CodeMeaning
1001Required fields are missing; inspect message.
1000Invalid JSON field type, such as an object instead of the amount string.
100400Invalid parameter value, such as zero, negative or non-numeric amount.
2000Signature verification failed.
2003The API key level cannot call this endpoint.
2004The key lacks a required permission; use TRANSFER.
100429Request rate exceeded the limit.

An accepted repayment can later become FAIL. Order history currently provides no execution failure reason; retain both system request IDs and the customer identifier for support. Do not assume a failed submission receipt and a failed execution order are the same event.

Body Params
string
length between 18 and 18
^[A-Za-z0-9]{18}$

Optional customer identifier, exactly 18 ASCII letters or digits; case preserved.

string
required

Debt ID from outstanding-debts, not an order or member ID.

string
required

Positive TOTAL repayment quantity, interest first then principal, in the debt currency.

string
enum
required

Actual paying account family; input is case-insensitive.

Allowed:
string
required

Actual paying DMA account ID or RapidX Portfolio ID in the debt group.

string
required

Actual paying DMA wallet or RapidX exchange. DMA FUNDING is not an LTP Funding account.

Headers
string
required

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

string
required

HMAC-SHA256 hex signature; see Authentication.

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