Skip to content
Docs
Open Legend

About

AboutGetting startedWhat is Legend?Why are we building this?Who is this for?

Platform

Web appiOSAndroidTelegram

Trading

TradingOrder typesDeposits and withdrawalsRanks

Capital

Legend CapitalCapital Affiliate Rewards

Autocopy

Copy tradingAutocopyLimits and safeguards

Social

SocialActivityFeedClansChat

Rewards

Referrals and rewards

API reference

Trading APIAuthentication and API keysAPI key actionsOrdersAccount, positions, and fillsLeverage, margin, and TWAPsRate limitsErrors and idempotency

Legend Research

Connect Legend to an AI assistantConnector permissionsMCP tools and order review

Fees

Fees

Support

FAQ
Trade onLEGEND

Trade where legends are made.

Download on theApp StoreGet it onGoogle Play
Product
TradeMobile app
Resources
BlogLearnFAQDocsCareers
© 2026 Legend. All rights reserved.
Privacy policyTerms of service
Ctrl K

Legend documentation

Authentication and API keys

Create and revoke account-scoped trading credentials.

View Markdown ↗
Trading APIPreviousAPI key actionsNext

Bearer authentication

Authorization: Bearer lg_trade_<64 hexadecimal characters>

Treat the key as a secret. The API stores its SHA-256 hash. Read-only keys have trading:read; trading keys created in settings also have trading:write. The server checks current account ownership, key revocation, scopes, network, and feature availability.

Wallet-signed registration

Settings handles registration for most integrations. The low-level endpoints are documented under API key actions.

A wallet signs EIP-712 typed data with domain name Legend Trading API, version 1, and a salt equal to keccak256(UTF8("https://app.legend.trade/api/trading")). Use this exact audience for production registration and revocation, including requests sent to trading-api.legend.trade. The signing audience is stable and does not change with the API hostname.

TradingAccess contains these fields, in order:

FieldTypeValue
accountstringLegend account UUID
networkstringhyperliquid_mainnet
keyHashstringSHA-256 of the entire plaintext API key, lowercase hex without 0x
policystringJSON with the scopes array sorted lexicographically, without whitespace
issuedAtuint256Current Unix time in milliseconds
expiresAtuint2560, meaning valid until revoked

The JSON consent uses snake_case field names and expires_at: null (or omits that field). A signature must be registered within five minutes of issued_at. This freshness requirement applies to registration only; the created key does not expire.

The signed network, account, permissions, and audience cannot be changed. Create a new key to change permissions. Only main-account, mainnet grants are accepted. A key hash cannot be registered again, including after revocation.

Revocation

Settings signs RevokeTradingAccess under the same domain, with account and keyHash as string fields. The owner signature is required; knowledge of a key hash alone cannot revoke a key. Revocation works even if trading is disabled. A revocation submitted before registration prevents later replay of that registration.

Revocation stops unsent slices of Legend TWAPs started with that key. If a slice was already sent, Legend records its result before it stops the job. Disabling API access also stops unsent API TWAP slices.

Native Hyperliquid TWAPs and resting venue orders remain active until you cancel them. Use the Legend app to cancel them when API access is disabled. Key revocation does not reverse a trade that already reached the venue.

You can have up to five active keys per user. Signed registration attempts are limited to ten per hour. Revocation remains available when those limits are reached.

Existing grants that explicitly authorized a finite expiry retain that signed restriction; they are not silently extended. Create a new key for access until revocation.