Skip to main content
An exchange API key that can place orders, cancel orders, or move funds is a direct line to your balance sheet. It usually sits in an environment variable, a config file, or a vault that decrypts inside the infrastructure you are trying to protect. An attacker who compromises that infrastructure gets the key too. Turnkey keeps plaintext credentials out of your persistent storage and infrastructure intermediaries. The credential lives encrypted inside a secure enclave, and every retrieval is evaluated by the policy engine before the enclave releases anything to an authorized recipient. You decide which service identities can retrieve which keys, under what conditions, and with how many approvals. This solution builds on Secret storage. Typical credentials this pattern protects:
  • 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

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. 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:
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 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.
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.

Variant: trading on behalf of your users

Some firms run trading strategies on behalf of other people rather than on their own exchange accounts. The same pattern supports a non-custodial setup: each end user gets their own sub-organization and imports their exchange API key into it directly, so the plaintext never passes through your infrastructure on the way in. A delegated access user you control, scoped by policy to retrieving that key and nothing else, lets your trading strategy pull the credential at runtime while the end user retains control of their sub-organization. For a trust-minimized deployment, run the trading strategy itself inside Turnkey Verifiable Cloud. The strategy executes in a verifiable secure enclave, so end users can verify exactly what code receives their API key, and the plaintext exists only inside that enclave while the strategy runs, keeping the arrangement non-custodial end to end.

Next steps