How to Create and Connect an API Key on OKX
You can only create an API keyvia the OKX website, not via the mobile app.
Follow the steps below carefully:
Step-by-step guide
1. Log in to your OKX account
Go to okx.com and log in to your account.
2. Go to your profile menu and click ‘API’
In the left-hand menu, scroll down and click on ‘API’ under your profile settings.
3. Click on ‘Create API Key’
You’ll see a button labeled ‘Create API key’ on the right. Click it to begin.
4. Fill in the API Key details
API Key name: Choose a name like Tradingbot Sparx
Account: Choose Main account or a sub-account.
Purpose: Select API trading
IP Whitelist: Enter this IP: 178.22.60.189 (This ensures your key can only be used by Sparx)
Set permissions
Enable both:
Read
Trade
Make sure withdrawals are disabled.
Set a passphrase
Choose a secure passphrase.
You will need this later to connect the API.
5. Click ‘Submit all’
Once everything is filled in, click on Submit all.
6. Confirm with your Authenticator app and Email
You’ll be asked to:
Enter your 2FA code
Confirm the request via your email
7. Click ‘View’ to access your API key
After creation, you’ll see your key listed. Click ‘View’ to reveal the keys:
Copy and store these details securely. You’ll need them to connect your bot.
Tips & Reminders
Make sure to use the correct IP address for extra security.
If you lose your API secret or passphrase, you’ll need to generate a new key
API keys without an IP allowlist will automatically expire after 14 days of inactivity
⚠️ Important Note About Wallet Balances and Subaccounts
Unlike Bitvavo, OKX does support subaccounts — and we strongly recommend using them.
This ensures that your trading bot operates on an isolated balance, separate from your long-term holdings.
However, even when using subaccounts, it’s important to avoid using the same coin in multiple places at once.
For example:
If your subaccount already holds ETH as a long-term position, and you run a bot that also trades ETH in that same subaccount, the bot may use that existing ETH balance as part of its strategy.
Best Practice:
Use a dedicated subaccount for each bot, and make sure that only the coins the bot is supposed to trade are held in that account.