Authentication
The Legend API uses bearer token authentication. Every request must include a query key or JWT in theAuthorization header.
Three auth methods
Query keys
Get a query key from dashboard.legend.xyz under Settings > API Keys:OAuth login (CLI)
Thelegend-cli can authenticate via Google SSO:
Making requests
Include your query key or JWT as a bearer token:Two layers of auth
The Legend API separates API access from fund authorization:
Your query key lets you do everything except move funds. To execute a plan, the sub-account’s signer must produce an EIP-712 signature. The signer key — whether an EOA private key or a Turnkey-managed P256 key — is controlled by you or your end-user at your discretion. Legend never holds it.
See Signer types for more on EOA vs Turnkey P256.
Key rotation
You can have multiple active query keys for the same Prime Account. To rotate:- Create a new query key
- Update your application to use the new key
- Revoke the old key
Security best practices
- Store query keys in environment variables or a secrets manager
- Use separate keys for production and development
- Rotate keys periodically and immediately if compromised
- Query keys grant access to all sub-accounts under your Prime Account — scope access at the application level if needed