/v1 call except the OpenAPI document needs an API key:
Create a key
Each key belongs to one trading account and has its own limits. A key is either a test key (lean_sk_test_…) or a live key (lean_sk_live_…). Both use the same trading account. Test keys
simulate orders and fills with no money; live keys trade real money, and trading can be paused
platform wide. A key’s mode is set when you create it and can’t be changed. See
Test mode and live mode.
- Sign in to Lean.
- Open Settings (the gear) and choose API.
- Under API keys, choose Create API key. Give the key a name, then choose its mode, access, per order limit, daily limit and expiry. The mode is Test and the access is Read and trade unless you change them. Choose Create key.
- Under Copy your key now, choose Copy, then Done. You won’t see the key again.
The API keys list shows each key’s name with a Test or Live badge, its prefix (such as
lean_sk_test_xxxxxxxx…), when it was created, last used and expires, and whether it is Active,
Revoked or Expired. A user can hold up to 10 active keys; revoke one to create another.
Manage keys with the API (advanced)
If you manage keys from your own tooling, call/api-keys instead. These requests take the access
token of your Lean session while you are signed in, sent as Authorization: Bearer <token>, never an API key. The
token expires after a short time.
Content-Type: application/json, or the request is refused with
400 VALIDATION_ERROR. The secret is in data.secret. mode is test or live and defaults to test. scopes takes
read, trade and route. route lets the key pay for a buy with cash on the other venue (see
Paying from the other venue) and needs trade. Leave it out for a key that should only trade with the cash already on each venue. A key can
also take withdraw, with optional withdrawal limits; see
Withdrawals through the API. Limits are in millionths of a dollar, so 5000000 is $5.
expiresInDays is required and must be from 1 to 90, or null for a key that never expires; the
API has no default.
A key’s limits can’t be above its trading account’s limits, or the request is refused with 422.
An account limit is at most 100,000,000 USD. The API reference documents
Create an API key,
List API keys,
Revoke an API key,
Update API key limits,
Get account limits,
Update account limits,
Pause an API key,
Resume an API key,
List trading pauses,
Pause account API trading and
Resume account API trading, with every field
and error.