Skip to main content

Request Body

timestamp
number
required
Unix timestamp in milliseconds. Must be within 30 seconds of the current time. Used to prevent replay attacks.
signature
string
required
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.
orderIndex
number
required
The index of the order to cancel. This can be found in your unfilled orders from the /2/wallet/positions/perp/unfilled endpoint.
marketId
number
required
The market ID where the order exists. This can be found in your unfilled orders from the /2/wallet/positions/perp/unfilled endpoint.

Response

ok
boolean
Always true on successful cancellation.
executionDetails
array
Array of transaction execution details (optional). Each object contains:

Error Responses

400 Bad Request

message
string
Error message (e.g. “validation failed”)
errors
array
Array of validation errors (Zod issues) if validation fails.

403 Forbidden

message
string
Error message
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

message
string
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

  1. Generate a current Unix timestamp in milliseconds
  2. Create the message string: api/2/perp/lighter/cancel-order-{timestamp}
  3. Sign this message with your wallet’s private key
  4. Include both the timestamp and signature in the request body
  5. 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
  })
});