Skip to content

Workflow

How to Create an OKX API Key, Secret, and Passphrase for Trading

Updated Ninja Terminal team

Short answer

To create an OKX API key, open API in your OKX account, choose Create API key for API trading, name it, set an IP address allowlist, and create a passphrase. Under Permissions select Read and Trade, leave Withdraw off, and save the API key, secret key, and passphrase. OKX cannot recover the passphrase.

An OKX API connection needs three values, not two: an API key, a secret key, and a passphrase. People often miss the passphrase and then cannot connect. This guide creates a trade-only OKX key with an IP allowlist and connects it to Ninja Terminal. See also OKX on Ninja Terminal.

What is the OKX passphrase?

The passphrase is a password you choose while creating the key. It is not your OKX login password. OKX does not show it after creation. If you lose it, you must delete the key and create a new one. Store it in your password manager together with the key and secret.

How do you create the key?

OKX names the menu differently on web and app. On the web it is under your profile, in API and connections. In the app it is under the menu, in API. The form fields are: API key name, Account, Used for (purpose), IP address allowlist, Permissions, and Passphrase.

  1. Log in to OKX and open the API page.
  2. Select Create API key.
  3. Choose API trading as the purpose.
  4. Enter a name, such as “Ninja Terminal”.
  5. Create a passphrase and keep it. Ninja Terminal asks for it later.
  6. Use your live trading account.

OKX may require more than 100 USD in assets under management to create a key in some regions. This applies to master accounts and sub-accounts.

How do you set the IP allowlist?

  1. In Ninja Terminal, choose OKX in the Add Account dialog. The setup shows an IP list with a copy button.
  2. Paste every address into the OKX IP address allowlist field.

OKX accepts up to 20 addresses per key, separated by a comma or a space. Ninja Terminal copies the list comma-separated.

The setup generates the list for the account you are adding. Copy it from that screen for each OKX key instead of reusing a list from another account.

Which permissions should you enable?

  1. Open Permissions.
  2. Select Read and Trade.
  3. Leave Withdraw off.
  4. Select Submit all, complete verification, and save the API key and secret key.
Permission Needed by Ninja Terminal Notes
Read Yes Balances, positions, orders
Trade Yes Spot and perpetual swap orders
Withdraw No Keep off

How do you connect the key to Ninja Terminal?

  1. In Add Account, choose OKX.
  2. Paste the API key, secret key, and passphrase. Add an optional nickname.
  3. Select Test, then Connect. The test reports each market (Spot and Swap).

Ninja Terminal encrypts all three values with AES-256-GCM and stores them on your device. Orders execute on your own OKX account. See the API key security checklist for the full practice.

Why does binding an IP matter on OKX?

OKX deletes keys with Trade or Withdraw permission and no IP binding after 14 days of inactivity. A key bound to IP addresses avoids that rule and limits where the key can be used. Read-only keys that are bound to IPs or specific permissions do not expire.

What if the connection fails?

  • Credential rejected: check the key, the secret, and the passphrase. The passphrase must match exactly.
  • IP error: an address is missing from the allowlist. Add all listed addresses.
  • Hidden characters: copy-paste can add invisible characters. Paste the value again, or create a new key.

Frequently asked questions

What is the OKX API passphrase?

It is a password you set while creating the API key. It is not your OKX login password, and OKX cannot show it again. If you lose it, delete the key and create a new one.

Which permissions does an OKX API key need for trading?

Read and Trade. Leave Withdraw off. A terminal does not need withdrawal permission.

How many IP addresses can I add to an OKX API key?

OKX lets you link up to 20 addresses per key, separated by a comma or a space.

Do OKX API keys expire?

OKX deletes keys that have Trade or Withdraw permission and no IP binding after 14 days of inactivity. Binding the key to IP addresses avoids this.

Sources

  1. OKX Help Center — API FAQ
  2. OKX — API management

Trade every venue from one tab.

Binance, OKX, Bybit, and Hyperliquid with news, charts, and one-command orders. Included with Ninja Squad Pro membership.