Skip to content
Coinland

OKX guidesAPI

Create an OKX API Key: Setup Steps, Safe Permissions, IP Allowlist and Expiry

Create an OKX API key without surprises: where the form lives, a passphrase only you know, read vs trade vs withdraw, IP binding and the 14-day expiry.

Published: Last checked: How we check our guides

You create an OKX API key from the API page of the OKX website: name the key, pick its permissions, set a passphrase and approve it with your two-factor codes. A bot, tax tool or portfolio tracker then works through that key and never sees your login password. Most later headaches trace back to three choices made in this form, so the steps below slow down at the passphrase, the permission boxes and the IP field.

Before you open the form

Decide what the key is for before you start. Write down which tool will use it, whether that tool only reads data or also places orders, and whether it runs from a server with a fixed IP address. Those three answers fill in most of the form for you.

Use the website rather than the app. The app has an API entry lower down its main menu, but OKX's developer documentation tells you to create keys on the website before signing any request, and the web form is easier to read. If you trade from a sub-account, switch to that sub-account first, because each sub-account holds its own keys.

In some regions OKX's API FAQ says an account must hold a minimum asset balance before it can create a key. When that applies, the create button stays unavailable and the page names the requirement you have not met yet.

OKX create API key steps on the website

Log in, open the profile menu, go to the API page and choose the option to create a key. The form asks for a key name, the account it belongs to and its purpose, an IP allowlist, the permissions and a passphrase.

Give the key a name that tells you which tool uses it, such as the bot's or tracker's name. Months later, when you have several keys, that label is how you will know which one to edit or delete.

After you submit, OKX asks for your two-factor codes and then shows the new key. Copy everything straight into a password manager or secrets store before you leave the page.

The three values and where to keep them

A working key is really a set of three: the API key, the secret key and the passphrase. OKX generates the first two. You type the passphrase yourself while filling in the form. A signed request fails unless all three are present.

Treat the secret and the passphrase like a password. Together with the key, they let anyone do whatever the permissions allow. Keep them out of shared documents, chat messages, screenshots and public code repositories.

Picking a passphrase you can find again

This passphrase belongs to one key only. Make it different from your OKX login password. Once the key exists, OKX will neither display the passphrase again nor recover it for you.

Losing it has one remedy. You delete the key, create a replacement and then paste the new values into every tool that relied on the old one. Saving the passphrase in the same vault entry as the secret, at the moment you create the key, spares you that chore.

Read, trade or withdraw permission

Read lets a tool see balances, bills and order history. Trade adds placing and cancelling orders, moving funds between your own accounts and changing settings. Withdraw lets the key send funds out of OKX altogether.

Match the box to the job. Portfolio and tax trackers need read and nothing more. Most trading bots need read plus trade.

Withdraw is rarely worth enabling. If a key with that permission leaks, the account can be drained. OKX's FAQ also lists separate transfer, loan and earn permissions, and only eligible accounts see the loan and earn options.

You can return to the API page later to change a key's name, permissions and bound IP addresses. Starting with the smallest set and adding more only when a tool asks for it costs you nothing.

IP allowlist: when it helps and when it breaks things

With an allowlist, OKX accepts requests for that key only from the addresses you entered. One key can hold up to 20 addresses in IPv4, IPv6 or network segment format. Separate them with a comma or a space in the form.

Bind an address only if the tool runs somewhere with a stable IP, such as a rented server. Home internet connections often change address, and the key will stop working the moment yours does. Hosted bot services usually publish the addresses you should enter. Take them from that service's own documentation and from no other source.

Why an unbound key expires after 14 days

OKX's documentation says a key with trade or withdraw permission and no bound IP address expires after 14 days without activity. Its API FAQ adds that expired keys are deleted automatically, and that calls to private account endpoints, such as checking a balance or placing an order, count as activity.

You can avoid this by binding an IP address or by making sure the tool calls the API regularly. Suppose a bot sat idle and now fails, and the key is missing from your API page. The expiry rule is the likely reason, and the fix is a new key. Demo trading keys are the exception: OKX states they do not expire.

Fixing errors on a fresh key

Error 50101 points to an environment mismatch. Either a live key was sent with the demo trading header or a demo key was sent to live trading. Error 50119 reports that the key does not exist, and OKX's FAQ links it to calling the wrong domain for your region. If a regional OKX entity serves your account, your tool has to use that entity's API domain.

Error 50102 means the timestamp in the request is too old. OKX refuses requests more than 30 seconds away from its server time, so sync the clock on the machine running the tool.

When a third-party app will not connect at all, check two things first: the passphrase was pasted with no stray spaces, and the request leaves from an allowlisted address. Keep main account and sub-account credentials apart, since a key, secret or passphrase from one will not work for the other. API access and features also vary by country and OKX entity, so read OKX's regional information if an endpoint refuses you.

Questions and answers

I lost my OKX API passphrase, can I get it back?

No. OKX cannot show or recover a passphrase once the key exists. Delete that key, create a new one and update your tools with the new values.

Why is my OKX API key gone from the API page?

Most likely it expired. A key with trade or withdraw permission and no bound IP address is deleted after 14 days without activity. Binding an IP or using the key regularly prevents it.

How many IPs can one OKX API key have?

Up to 20, according to OKX's documentation. You can enter IPv4 addresses, IPv6 addresses or network segments.

What permissions does an OKX trading bot need?

Read and trade cover most bots. Keep withdraw switched off unless the tool is fully under your control and truly needs it, because a leaked key with withdraw permission can move money out.

Do I need a new key to change permissions?

No. On the API page you can edit an existing key's name, permissions and bound IP addresses.

Crypto trading carries a high risk of loss, and leveraged products can lose your whole deposit. Nothing here is investment advice. Check that the exchange is available in your country before you sign up.

Related guides

Save up to 50% on fees + get up to $100 in rewards

Eligibility and terms may apply. The link fills in our referral code at sign-up. Check the code field before you submit: a registered code usually cannot be changed.

Get OKX Offer

Coinland earns a commission from the exchange when you sign up through the links on this page, based on the trading fees you later pay. The link does not raise your fee rate.