An exchange API key used by a trading bot is a bearer credential for real money: whoever holds the secret can act on the account within the permissions the key carries. This guide is for traders, quant developers and small funds who run bots, portfolio trackers or tax tools against exchange accounts. It covers how to scope permissions, why withdrawal rights should stay off, how IP allowlists and key types reduce the value of a stolen secret, where to store bot keys, and how to rotate and respond when a key leaks. Examples use three large exchanges' public documentation; platforms are listed alphabetically and the order is not a ranking. For exchange-operator controls such as hot wallets and signing infrastructure, see the Crypto Exchange Identity and Key Security Guide.
This is an independent guide from NHI Mgmt Group, based on the public API documentation of Binance, Coinbase and Kraken as of November 2026. It is not sponsored or reviewed by any of them. Product features change, so confirm settings against each exchange's current documentation.
Key takeaways
- One key per job, least permission. A portfolio tracker needs read access only; a bot needs read and trade; almost nothing automated needs withdraw.
- Withdrawal stays off by default. A key that cannot move funds off the exchange limits a theft to bad trades, which is still harmful but far smaller than an emptied account.
- Bind every trading key to known IP addresses. IP restriction turns a leaked secret into something an attacker cannot use from their own infrastructure, and some exchanges require it for higher permissions.
- Store bot keys like production secrets. A secrets manager or encrypted store, never source code, chat or shared spreadsheets, and never a plain environment file committed to a repository.
- Rehearse the kill switch. Know where to delete a key, cancel open orders and review history in minutes, because exchange keys are abused fast.
Key permissions
Each exchange groups API rights differently, but they map to three levels: read (balances, orders, history), trade (place, modify and cancel orders) and move funds (withdraw or transfer). Name keys after their purpose and host ("tracker-readonly", "bot-eu-vps-01") without including account details, as Kraken's documentation also advises.
| Level | Binance | Coinbase | Kraken | Typical consumer |
|---|---|---|---|---|
| Read | Enable Reading (available on all keys) | View permission (balances, orders, fills, portfolios, key permissions) | Query Funds, Query Open Orders and Trades, Query Closed Orders and Trades, Query Ledger Entries, Export Data | Portfolio trackers, tax and accounting tools, monitoring dashboards |
| Trade | Trading permissions, off by default and enabled in API Management; futures has its own permission | Trade permission (create, edit, cancel orders; convert) | Modify Orders, Cancel/Close Orders | Trading bots, rebalancers |
| Move funds | Withdrawals permission, which requires IP access restriction | Transfer permission (moving funds and balances); the docs warn that a secret with transfer could move funds out of the account | Withdraw Funds (also Deposit Funds under the Funds group) | Treasury automation with strong controls only |
- Split by purpose: Binance's API documentation recommends separate keys for separate purposes, such as one for trading and one for read-only monitoring. Doing the same on every exchange means a leaked tracker key cannot trade.
- Scope by account or portfolio where offered: Coinbase lets you restrict a key to a portfolio as well as to permissions. Running a bot in a dedicated sub-account or portfolio caps what any key can touch.
- Check what the key really has: verify permissions after creation, for example through Coinbase's key permissions endpoint or the exchange's API management page, and record them in your own inventory.
- Third-party bot services: when a hosted service asks for a key, give the minimum it documents. Kraken's guidance for a third-party trading key is order placement and cancellation, perhaps open-order queries, and almost certainly not withdrawals.
Withdrawal permissions
Treat withdraw or transfer rights as a separate, exceptional decision. If a strategy really needs automated movement of funds, for example sweeping profits to cold storage, put controls around it rather than adding the right to an existing trading key.
- Binance: the Withdrawals permission cannot be enabled unless the key has IP access restrictions. Keep it on a dedicated key bound to a single fixed address.
- Coinbase: the Transfer permission covers moving funds and allocating balances. Keep it off trading keys and use a separate key, restricted to the portfolio it needs, with an IP allowlist.
- Kraken: the Withdraw endpoint sends funds to a withdrawal key name set up on the account in advance, and an optional address parameter is checked against that key. Pre-configure only destinations you control, and add two-factor authentication to the API key where the client software supports sending the one-time password.
Decision guidance
| Situation | Recommended approach | Trade-off |
|---|---|---|
| Individual trader with one bot | Read and trade only; withdraw manually through the exchange's web or app with account two-factor authentication | Manual step for profit-taking |
| Hosted bot or signal service | Read and trade only, IP restricted to the provider's published egress addresses if offered, dedicated sub-account | You depend on the provider's own key storage |
| Small fund with automated sweeps | Separate withdraw-only key, fixed IP, destination pre-configured to a cold wallet you control, alerting on every withdrawal | More keys to inventory and rotate |
| Team running many strategies | One key per strategy and host, central secrets manager, documented owner per key | Operational overhead, offset by faster containment |
IP allowlists
An IP allowlist ties a key to the addresses your bot runs from. A secret copied from a log or laptop then fails when used elsewhere.
- Binance: IP access restriction accepts IPv4 addresses. System-generated HMAC keys with unrestricted IP are limited to reading, and the exchange strongly advises against enabling other permissions without IP restriction. Self-generated keys (Ed25519 or RSA) are another route to higher permissions; Binance's API documentation highly recommends Ed25519.
- Coinbase: adding an IP allowlist is recommended when creating a Secret API Key in the Coinbase Developer Platform portal, alongside portfolio and permission restriction.
- Kraken: IP Address Restriction limits key use to specified client addresses, and Key Expiration can make a key valid only for a set period.
Practical points: run bots from a host with a static egress address (a virtual private server or a cloud NAT gateway), not a home connection whose address changes. If you use a hosted service, ask for its fixed egress addresses. Avoid adding broad ranges to keep a bot working: each extra address is somewhere a stolen key works.
Storage
Bot keys leak the same way other API keys do: committed to repositories, pasted in support chats, printed in logs, left in backups. OWASP's Secrets Management Cheat Sheet recommends dedicated secrets managers over general configuration stores and notes that environment variables are generally accessible to processes and may appear in logs or dumps. See the API Key Management Guide.
| Option | Suitable for | Watch for |
|---|---|---|
| Cloud secrets manager or self-hosted vault | Bots on cloud hosts, teams, funds | Scope access to the bot's own identity; enable audit logs |
| Password manager | Individuals storing keys before deployment; Kraken recommends this and warns against saving keys unencrypted | Do not copy keys onward into plain files |
| Encrypted file mounted at runtime | Single virtual private server | Protect the decryption key separately; restrict file permissions |
| Environment variables | Last resort; Coinbase's docs suggest them instead of putting credentials in code | Never commit .env files; keep them out of crash dumps and logs |
| Self-generated asymmetric keys | Where offered (Binance Ed25519 or RSA; Coinbase ECDSA) | The private key never goes to the exchange, but it still needs the same protection |
- Keep secrets out of code: add pre-commit secret scanning and repository scanning. See the Git Secret Scanning Guide.
- Mask in logs: log the key name or last four characters, never the secret or the signed request. Kraken's docs stress that the private key is used only to sign locally and must never be transmitted.
- Harden the bot host: patched operating system, SSH keys rather than passwords, no other workloads, and outbound access limited to the exchange endpoints the bot uses.
- Request hygiene: use a short validity window for signed requests (Binance's recvWindow defaults to 5,000 ms and cannot exceed 60,000 ms; Coinbase JWTs expire after two minutes) and keep the host clock synchronised, which also avoids Kraken nonce errors.
Rotation
Exchange keys rarely expire on their own, so rotation is your job. Rotate on a schedule, when a person or provider with access leaves, when a host is rebuilt, and immediately on suspicion.
- Inventory: list every key with exchange, account or portfolio, permissions, IP allowlist, host, owner and creation date.
- Create the replacement: same permissions and allowlist, new name with a date suffix. On Kraken, set Key Expiration so a forgotten key stops working.
- Deploy: write the new secret to the secrets manager and restart the bot so it reads the new value. Confirm it trades in a small test.
- Revoke the old key: delete it in API management straight away rather than leaving it for later.
- Record: update the inventory and set the next rotation date (for example every 90 days for trading keys, sooner for any key with withdraw or transfer).
Rollback: if the new key fails, fix the configuration and create another key rather than re-enabling the old one; a revoked key should stay revoked.
Compromise response
Signs of a stolen key include orders you did not place, unusual trades in thinly traded pairs, new withdrawal destinations, IP restriction errors from unknown addresses and unexpected permission changes. See the API Key Leak Response Playbook.
- Contain: delete the key (Binance advises revoking all keys on unusual activity; Coinbase advises regenerating or disabling; on Kraken delete it in the account's API key settings). Stop the bot so it does not recreate exposure.
- Cancel open orders and check positions: close anything placed by the attacker where safe.
- Secure the account: change the account password, review two-factor settings, sessions, linked devices and withdrawal destinations.
- Contact the exchange's support through its official site or app, with times, order IDs and the key name.
- Find the leak: scan repositories, logs, backups and the bot host; check any third-party service that held the key.
- Rebuild and reissue: new host if it may be compromised, new keys with tighter permissions and allowlists.
Detection and measurement
- Alert on every withdrawal or transfer, every new API key and every permission change, using the exchange's email or app notifications.
- Reconcile bot order logs against exchange fills daily; orders the bot did not send are a red flag.
- Metrics: share of keys with IP restriction (target 100% for trade keys); share of keys with withdraw or transfer (target near zero); keys older than the rotation target; time from detection to key deletion; secrets found by scanning per quarter.
Common failure patterns
- One "do everything" key: read, trade and withdraw on one key used by a tracker, a bot and a script.
- No IP restriction: left off because the bot's address changes, so the key works from anywhere.
- Keys in repositories or chat: a public or shared repository with a config file, or a key pasted into a support ticket or community channel.
- Forgotten keys: keys for retired bots or cancelled services never deleted.
- Trusting a hosted service blindly: no review of what permissions it needs or how it stores keys.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.AA-01, PR.AA-05, DE.CM-03 | Manage credentials, least privilege, monitor activity |
| NIST SP 800-53 Rev. 5 | IA-5 Authenticator Management, AC-6 Least Privilege, AU-6 Audit Record Review | Key lifecycle, permission scoping, reviewing activity |
| MITRE ATT&CK | T1552.001 Credentials In Files, T1528 Steal Application Access Token | How keys are commonly stolen from files and applications |
| CryptoCurrency Security Standard | Key and account controls | See the CryptoCurrency Security Standard Guide |
Practitioner checklist
- Inventory every exchange API key with owner, permissions, allowlist and host.
- Create one key per purpose; trackers get read only.
- Keep withdraw and transfer off every trading key.
- Restrict every trading key to fixed IP addresses.
- Prefer self-generated asymmetric keys where the exchange offers them.
- Store secrets in a secrets manager or password manager, never in code.
- Turn on exchange notifications for withdrawals, new keys and permission changes.
- Rotate on a schedule and delete old keys immediately.
- Write down and rehearse the kill-switch steps for each exchange.
Standards and references
- Binance: Spot API request security
- Binance: How to create API keys
- Coinbase: API key authentication
- Coinbase: Advanced Trade API permissions
- Kraken: How to create an API key
- Kraken: Spot REST authentication
- OWASP: Secrets Management Cheat Sheet
- NIST: SP 800-53 Rev. 5
Related NHI Mgmt Group resources: Crypto Exchange Identity and Key Security Guide · Crypto Exchange Account Security Guide · API Key Management Guide · Crypto Wallet Security Guide