- Exchange and EMS API keys for trading operations (REST and WebSocket)
- Long-lived JWTs and bearer tokens with broad authority
- OAuth refresh tokens for backend services
- Service account credentials for third party platforms
Why not a traditional secrets vault?
Key implementation decisions
Example: exchange trading key for a trading firm
A trading firm holds a long-lived JWT for an execution management system that authorizes placing and canceling orders on crypto exchanges. The plaintext should not be stored at rest in the firm’s infrastructure or exposed to intermediaries; after export, it exists transiently in the authorized trading service’s memory while in use.Policy: scope retrieval to the trading service
Implementation steps
For a working end-to-end implementation, see the api-key-storage example — it imports the credential with static properties, creates the retrieval policy, lists the organization’s secrets, and exports the plaintext as the trading service user.
1
Import the API key
Import the credential once, with static properties the policies above target. The client encrypts the plaintext to the enclave. Turnkey’s API and database only ever see ciphertext:You can now delete any persisted plaintext copy from wherever it existed before.
2
Retrieve at runtime
The trading service authenticates with its own credentials and retrieves the key when it boots or opens a session. To find the secret ID at runtime rather than hard-coding it, list the organization’s secrets with
exportSecret generates the ephemeral keypair, submits the export activity, and decrypts the result into the authorized service’s memory. Symmetric, bearer, HMAC, and OAuth credentials necessarily exist there transiently while in use:getSecrets(). That path returns metadata only.3
Require approval for high-risk keys
For withdrawal-capable keys, add a consensus policy so no service can retrieve them alone:The export stays in
exportSecret cannot be used for these keys: it fails fast with EXPORT_SECRET_CONSENSUS_NEEDED rather than waiting on approvals, because the ephemeral private key it generates internally would be lost by the time they arrive. Use the proposal helpers instead, which keep the decryption key in the trading service’s hands across the approval window:ACTIVITY_STATUS_CONSENSUS_NEEDED until a risk admin approves it from the dashboard or via approve_activity, and the released payload is still readable only by the trading service. See Programmable credential access for the full multi-party flow.4
Rotate and revoke
Rotate by importing the replacement key and deleting the old secret. Revoke a service by invalidating its session keys or removing its user. Policy changes take effect immediately, with no re-encryption or re-import of the stored keys.