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/cancel-order-{timestamp} signed with your wallet’s private key. The signature is used to verify your identity and associate with your Lighter account.
The index of the order to cancel. This can be found in your unfilled orders from the /2/wallet/positions/perp/unfilled endpoint.
The market ID where the order exists. This can be found in your unfilled orders from the /2/wallet/positions/perp/unfilled endpoint.
Response
Always true on successful cancellation.
Array of transaction execution details (optional). Each object contains: Show executionDetails Array Item
Transaction hash of the cancellation
Array of order statuses (optional). Each object contains: Show orderStatuses Array Item
Error Responses
400 Bad Request
Error message (e.g. “validation failed”)
Array of validation errors (Zod issues) if validation fails.
403 Forbidden
Possible messages:
"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 canceling order”)
This error occurs when:
The cancellation fails on Lighter
The order doesn’t exist or cannot be canceled
Other internal errors occur
Authentication
Generate a current Unix timestamp in milliseconds
Create the message string: api/2/perp/lighter/cancel-order-{timestamp}
Sign this message with your wallet’s private key
Include both the timestamp and signature in the request body
The signature must be from a wallet address that has a registered Lighter account
Important : The timestamp must be within 30 seconds of the current time. Older timestamps will be rejected to prevent replay attacks.
Example
const timestamp = Date . now ();
const message = `api/2/perp/lighter/cancel-order- ${ timestamp } ` ;
const signature = await wallet . signMessage ( message );
const response = await fetch ( 'https://api.mobula.io/api/2/perp/lighter/cancel-order' , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
timestamp ,
signature ,
orderIndex: 12345 ,
marketId: 1
})
});