Builds the payload that provisions a perp account for the signer — for Lighter this creates an on-chain sub-account and/or API key entry; for Gains it is a no-op for most flows (accounts are implicit).
Run this once per (dex, chainId) before the user’s first deposit/create-order.
Request Body
Chain of the perp account (e.g., lighter:301).
Lighter sub-account index (≥ 0). Omit to use the default index.
Lighter API key slot to provision (≥ 0). Omit to use the default slot.
Endpoint-specific errors
| Status | message |
|---|
| 400 | create-account payload generation failed — DEX rejected provisioning (e.g., slot already in use) |
| 501 | payload action "create-account" not implemented yet — DEX does not support account provisioning |
Example
Provision a Lighter API key for the caller:
const endpoint = 'api/2/perp/payloads/create-account';
const timestamp = Date.now();
const signature = await wallet.signMessage(`${endpoint}-${timestamp}`);
const res = await fetch(`https://api.mobula.io/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
timestamp,
signature,
dex: 'lighter',
chainId: 'lighter:301',
}),
}).then(r => r.json());