> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trusset.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Collateral

> Post additional collateral to an existing loan

Adds security tokens to an open loan, raising its health factor without repaying debt. This is the fastest way for a borrower to move a position away from liquidation.

`CUSTODY` markets require an approval on the collateral token first, returned as an explicit step. `FREEZE` markets do not.

## Path Parameters

<ParamField path="marketId" type="string" required>Market ID.</ParamField>

## Body Parameters

<ParamField body="loanId" type="integer" required>
  On-chain loan ID. Must be a positive integer sent as a JSON number.
</ParamField>

<ParamField body="amount" type="string" required>
  Security tokens to add, as a decimal string. Parsed at the collateral token's decimals.
</ParamField>

<ParamField body="txHash" type="string">
  Hash of the transaction you broadcast for this operation. Send it to confirm the transaction and record the result. Omit it to receive the calldata.
</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="txHash" type="string">Transaction hash. Returned when confirming with `txHash`.</ResponseField>
    <ResponseField name="loanId" type="integer">Loan ID, echoed back. Returned when confirming with `txHash`.</ResponseField>
    <ResponseField name="amount" type="string">Collateral added, echoed back. Returned when confirming with `txHash`.</ResponseField>
    <ResponseField name="action" type="string">`SIGN_TRANSACTIONS` when `txHash` is omitted.</ResponseField>
    <ResponseField name="steps" type="array">One step in `FREEZE` markets, two in `CUSTODY` markets where an `approve` precedes `addCollateral`.</ResponseField>
    <ResponseField name="mode" type="string">`FREEZE` or `CUSTODY`. Returned when `txHash` is omitted.</ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Adding collateral is bounded by the market's `maxUserCollateral` and `maxTotalCollateral` caps. Check headroom with [Get Supply Caps](/endpoints/external-securities-lending/get-supply-caps) if either is set, since exceeding a cap reverts on-chain with no preflight.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-external-securities/api/positions/{marketId}/add-collateral" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{"loanId": 5, "amount": "200"}'
  ```
</RequestExample>

<ResponseExample>
  ```json Confirmed Response theme={null}
  {
    "success": true,
    "data": {
      "txHash": "0xabc...def",
      "loanId": 5,
      "amount": "200"
    }
  }
  ```

  ```json Calldata Response (CUSTODY) theme={null}
  {
    "success": true,
    "data": {
      "action": "SIGN_TRANSACTIONS",
      "mode": "CUSTODY",
      "steps": [
        {
          "action": "SIGN_TRANSACTION",
          "transaction": { "to": "0xabc...def", "data": "0x..." },
          "functionName": "approve",
          "description": "Approve the custody adapter to pull collateral"
        },
        {
          "action": "SIGN_TRANSACTION",
          "transaction": { "to": "0x70A0...", "data": "0x..." },
          "functionName": "addCollateral"
        }
      ]
    }
  }
  ```
</ResponseExample>
