Request Body
Unix timestamp in milliseconds. Must be within 30 seconds of the current time. Used to prevent replay attacks.
Signature of the message
api/2/perp/lighter/update-margin-{timestamp} signed with your wallet’s private key. The signature is used to verify your identity and associate with your Lighter account.The market ID where the position exists. This can be found in your open positions from the
/2/wallet/positions/perp/open endpoint.The amount of USDC to add or remove from the margin. Must be a positive number.
Set to
true to add margin (increase collateral), false to remove margin (decrease collateral). When set to false, the leverage will be automatically updated to the maximum allowed leverage for the market.Response
Always
true on successful margin update.Array of transaction execution details (optional). Each object contains:
Error Responses
400 Bad Request
Error message (e.g. “validation failed”)
Array of validation errors (Zod issues) if validation fails.
403 Forbidden
Error message
"timestamp expired"- The timestamp is more than 30 seconds old"no lighter account associated with the signer address"- The signature doesn’t match a registered Lighter account
500 Internal Server Error
Error message (e.g. “error updating margin”)
- The margin update fails on Lighter
- The position doesn’t exist or cannot be updated
- Market details cannot be retrieved (when decreasing margin)
- Other internal errors occur
Authentication
- Generate a current Unix timestamp in milliseconds
- Create the message string:
api/2/perp/lighter/update-margin-{timestamp} - Sign this message with your wallet’s private key
- Include both the
timestampandsignaturein the request body - The signature must be from a wallet address that has a registered Lighter account
Behavior
- When
increase: true: Adds USDC to the position’s margin, increasing the collateral available. - When
increase: false: Removes USDC from the position’s margin and automatically updates the leverage to the maximum allowed leverage for the market. This ensures the position remains within acceptable risk parameters after margin reduction.