Skip to navigation

Error Codes

A categorized reference of OKX v5 REST and WebSocket error codes.

Overview

Every OKX v5 REST response — success or failure — uses the same JSON envelope:

{
"code": "0",
"msg": "",
"data": []
}
  • code — a string status code. "0" means the request succeeded; any other value is an error.
  • msg — a human-readable explanation. Empty on success, populated on failure.
  • data — an array of result objects.

Compare code as a string ("0"), not the integer 0. The msg / sMsg text is the authoritative, up-to-date explanation for any code — the tables below summarize the documented meaning, but always surface the returned message to callers.

Code "0" is the only success value. On batch endpoints the top-level code can be "0" while individual items still fail, so treat a top-level "0" as “the request was accepted”, not “every item succeeded”. Always inspect per-item sCode as well.

Per-item codes on batch endpoints

Batch endpoints — POST /api/v5/trade/batch-orders, POST /api/v5/trade/cancel-batch-orders, POST /api/v5/trade/amend-batch-orders, and others — can partially succeed. Each element of data carries its own status:

  • sCode — the status code for that individual item ("0" = that item succeeded).
  • sMsg — the message for that individual item.
{
"code": "1",
"msg": "Operation failed.",
"data": [
{ "clOrdId": "order-a", "ordId": "312269865356374016", "sCode": "0", "sMsg": "" },
{ "clOrdId": "order-b", "ordId": "", "sCode": "51008", "sMsg": "Order failed. Insufficient balance." }
]
}

The top-level code is "1" (“Operation failed”) when any item fails, and "2" (“Bulk operation partially succeeded”) when some succeed and some fail. Read both levels.

CodeHTTPMessage / Meaning
0200Success. The request (and, for batches, every item) succeeded.
1200Operation failed. Used at the top level of a batch when all items failed; inspect each sCode.
2200Bulk operation partially succeeded. Some items succeeded, some failed; inspect each sCode.

Public / General (50000–50999)

General request, routing, and system-level errors that apply across all endpoints.

CodeHTTPMessage / Meaning
50000400Body for POST request cannot be empty.
50001503Service temporarily unavailable. Try again later.
50002400JSON syntax error in the request body.
50004400API endpoint request timeout (does not mean the request succeeded or failed; check state).
50005410API endpoint is offline or unavailable.
50006400Invalid Content-Type. Use application/json.
50007403Account blocked.
50008401User does not exist.
50009403Account is suspended (frozen).
50010400User ID is empty.
50011429Rate limit reached. Throttle and retry.
50012400Account status invalid.
50013429Systems are busy. Please try again later.
50014400Required parameter cannot be empty.
50015400Either parameter x or y is required.
50016400Parameter mismatch (paired parameters are inconsistent).
50017400Position frozen due to ADL (auto-deleveraging). Operable after ADL finishes.
50018400Currency is frozen due to ADL.
50019400Account is frozen due to ADL.
50020400Position frozen due to liquidation. Operable once liquidation completes.
50021400Currency is frozen due to liquidation.
50022400Account is frozen due to liquidation.
50023400Funding fee frozen. Operable once settlement completes.
50024400Parameters x and y cannot be provided at the same time.
50025400Parameter x count exceeds the limit.
50026500System error. Try again later.
50027403This account is restricted from trading. Contact customer support.
50028400Unable to take the order; account is restricted from opening positions.
50029400This instrument is unavailable for this account (risk control).
50030403You do not have permission to use this API endpoint.
50032403Account has been set to prohibit transactions for this currency.
50033403Account has been set to prohibit transactions for this business line.
50035400This endpoint requires that the API key be bound to an IP address.
50036400expTime cannot be earlier than the current system time.
50037400Order has expired.
50038400This feature is unavailable in demo trading.
50039400The parameter before cannot be used with begin/end.
50040400Too frequent operations. Please try again later.
50041400User ID is not eligible for this feature (whitelist only).
50044400Must select one broker type.
50060400For the security of your funds, a preset action is required. Please try again later.
50061429Order requests have been rate-limited. Reduce request frequency.
50062400This feature is currently unavailable.

Rate limiting (50011, 50013, 50061)

Rate-limit responses arrive with HTTP 429. Back off using exponential delay, batch where possible, and prefer WebSocket streams over REST polling.

CodeHTTPMessage / Meaning
50011429Rate limit reached. Please refer to the API documentation and throttle requests accordingly.
50013429Systems are busy. Please try again later. Server-side throttling under load.
50061429Order placement/amend/cancel requests exceeded the sub-account order rate limit. Reduce frequency.

See Rate limits for per-endpoint budgets and the sub-account order-count limits.


API authentication & keys (50100–50119)

Authentication failures almost always trace back to the signature or the request headers. See REST authentication for how OK-ACCESS-SIGN is computed.

CodeHTTPMessage / Meaning
50100400API frozen. Contact customer support.
50101401APIKey does not match the current environment (e.g. live key used against demo).
50102401Timestamp request expired. Clock skew exceeded 30 seconds; sync your clock.
50103401Request header OK-ACCESS-KEY cannot be empty.
50104401Request header OK-ACCESS-PASSPHRASE cannot be empty.
50105401Request header OK-ACCESS-PASSPHRASE is incorrect.
50106401Request header OK-ACCESS-SIGN cannot be empty.
50107401Request header OK-ACCESS-TIMESTAMP cannot be empty.
50108401Broker ID does not exist.
50109401Matching broker ID does not exist.
50110401Your IP address is not in the allowlist bound to this API key.
50111401Invalid OK-ACCESS-KEY.
50112401Invalid OK-ACCESS-TIMESTAMP (format not ISO-8601 / not parseable).
50113401Invalid signature. Recompute OK-ACCESS-SIGN from the pre-hash string and secret.
50114401Invalid authorization / authentication failed.
50115405Invalid request method for this endpoint.
50116401Fastapi cannot be used for this endpoint.
50118400You must complete broker withdrawal-verification setup before using this feature.
50119401API key does not exist.

50113 (invalid signature) and 50102 (expired timestamp) are the two most common auth failures. 50113 means the pre-hash string, HTTP method, path, query string, or body you signed does not match what was sent — re-serialize the body exactly once and sign the raw string. 50102 means clock drift; run NTP so your timestamp is within 30 seconds of OKX server time.


Account (50000-range trade / 51000–51999 subset)

Errors returned when placing, amending, or cancelling orders — covering parameter validation, balance, leverage, and position-mode conflicts. These appear at the top level for single orders and as sCode on batch items.

CodeHTTPMessage / Meaning
51000400Parameter error. The parameter named in msg is missing or malformed.
51001400Instrument ID (instId) does not exist.
51002400Instrument ID does not match the underlying.
51003400Either clOrdId or ordId is required.
51004400Order amount exceeds the current tier’s maximum position limit.
51005400Order amount exceeds the maximum order size.
51006400Order price is outside the allowable price-limit range.
51007400Order placement failed: order value is below the minimum (1 USDT).
51008400Order failed. Insufficient account balance.
51009400Order placement blocked: account is in trading-suspended state.
51010400Account level too low. Current account mode does not support this instrument type.
51011400Duplicate order ID (clOrdId already used).
51012400Token does not exist.
51014400Index does not exist.
51015400Instrument ID does not match the instrument type.
51016400Duplicate clOrdId.
51020400Order amount must be greater than the minimum lot size.
51023400Position does not exist.
51024400Trading account is suspended.
51025400Order count exceeds the limit.
51046400Take-profit trigger price must be higher than the last price.
51047400Stop-loss trigger price must be lower than the last price.
51119400Order placement failed due to insufficient balance.
51120400Order quantity is less than the minimum available amount for closing.
51121400Order count must be a multiple of the lot size.
51122400Order price must be higher than or equal to the minimum price increment.

Trade / order (51100–51999 subset)

Order-state and order-management errors — amend, cancel, close, and margin/leverage conflicts.

CodeHTTPMessage / Meaning
51100400Trading amount does not meet the minimum, or exceeds the maximum.
51103400Number of pending orders for the instrument exceeds the limit.
51108400Positions exceed the limit for the market-maker/close-out operation.
51109400No available offer to match the order (no counterparty).
51115400Cancellation failed: the order has already been filled or cancelled.
51116400Order price or trigger price exceeds the allowable limit.
51117400Pending close-orders count exceeds the limit.
51121400Order count must be a multiple of the lot size.
51124400You can only place limit orders during the pre-market call-auction period.
51127400Available balance is zero.
51131400Insufficient balance.
51132400Your position amount is negative and cannot be closed with this order.
51133400Reduce-only cannot increase the position size.
51136400Close-position amount exceeds available position amount.
51201400Value of per market order cannot exceed 1,000,000 USDT.
51202400Market order amount exceeds the maximum amount.
51203400Order amount exceeds the limit for the instrument.
51277400TP trigger price cannot be higher than the last price.
51278400SL trigger price cannot be lower than the last price.
51279400TP trigger price cannot be lower than the last price.
51280400SL trigger price cannot be higher than the last price.
51400400Cancellation failed: the order does not exist.
51401400Cancellation failed: the order is already cancelled.
51402400Cancellation failed: the order is already completed (filled).
51403400Cancellation failed: this order type does not support cancellation.
51404400Order amendment unavailable: the order is in the pre-market call-auction period.
51405400Cancellation failed: you have no pending orders.
51406400Cancellation failed: the number of orders exceeds the batch limit (max 20).
51408400Pair and order do not match; cannot cancel across different instruments.
51410400Cancellation already in progress; do not resubmit.
51503400Order amendment failed: the order does not exist or is already completed.
51506400Order amendment unavailable for this order type.
51509400Amendment failed: the requested change was not accepted.
51603400Order does not exist. Verify ordId / clOrdId before amend or cancel.

Funding & withdrawal (58000–58999 subset)

Errors from the asset/funding endpoints: transfers, deposits, and withdrawals.

CodeHTTPMessage / Meaning
58002400Please activate Options trading before transferring related assets.
58004400Account is blocked from transfers (e.g. deferred settlement).
58005400Transfer amount exceeds the maximum limit for the currency.
58006400Service unavailable for this token in your region.
58007400Abnormal state of your account; transfer is not allowed.
58100400The trading account withdrawal function is disabled.
58101400Transfer suspended for the account.
58102429Too frequent withdrawal requests. Try again later.
58103400Sub-account does not have transfer permissions.
58104400Withdrawal request rejected due to a risk-control review.
58105400The internal transfer amount exceeds the daily limit.
58110400Withdrawals are suspended for this currency due to instability.
58111400Withdrawal is unsupported for the selected chain of this currency.
58112400Withdrawal failed. Please check your account state and try again.
58115400Sub-account transfers are not allowed for this currency.
58116400Transfer amount exceeds the maximum.
58120400Withdrawal services are unavailable. Please try again later.
58121400The withdrawal amount is below the minimum withdrawal threshold.
58124400Withdrawal request has expired.
58125400Non-tradable assets can only be withdrawn in full.
58126400Non-tradable assets can only be withdrawn to an OKX account.
58127400The withdrawal address is not whitelisted.
58128400Withdrawal address is invalid or not on the selected chain.
58129400Insufficient balance to cover the withdrawal fee.
58131400Insufficient available balance for the withdrawal.
58200400Withdrawal from this account is not allowed.
58207400Withdrawal address is not on the address allowlist.
58208400Withdrawal failed: please add a withdrawal address in the security center.
58350400Insufficient balance.

WebSocket (60000–60999)

Returned on the WebSocket channel as event: "error" frames. Login, subscription, and channel errors dominate this range. See WebSocket for connection and subscription details.

CodeHTTPMessage / Meaning
60001—OK-ACCESS-KEY cannot be empty in the login request.
60002—OK-ACCESS-SIGN cannot be empty.
60003—OK-ACCESS-PASSPHRASE cannot be empty.
60004—Invalid OK-ACCESS-TIMESTAMP.
60005—Invalid OK-ACCESS-KEY.
60006—Timestamp request expired (clock skew). Resync and re-login.
60007—Invalid sign (signature mismatch on login).
60008—This channel does not support subscription over this connection type.
60009—Login failed.
60010—Already logged in.
60011—Please log in before subscribing to private channels.
60012—Illegal request. The message format or JSON is invalid.
60013—Invalid args. The subscription arguments are malformed.
60014—Requests too frequent. Slow down subscription/login attempts.
60015—Connections too frequent. Reduce reconnection rate.
60016—Buffer is full. The connection is being closed; reconnect.
60017—Invalid url path.
60018—Wrong channel: the requested channel does not exist, or arg fields are incorrect.
60019—Invalid op. The op field must be one of subscribe, unsubscribe, or login.
60020—APIKey subscription limit has been reached.
60021—The connection has reached its subscription limit.
60022—Bulk login partially succeeded.
60023—Bulk login requests too frequent.
60024—Wrong passphrase in the login request.
60026—Batch login by APIKey and token cannot be used at the same time.
60027—Parameter is empty in the request.
60028—This operation is not supported by this URL.
60029—The op (operation) is not supported.
60030—The channel does not support this instrument type.
63999—Login failed due to an internal system error; reconnect and retry.

The WebSocket also returns transport-level close events. 4004 (no data received in 30s — send a ping), 4005 (buffer full), and 4008 (too many requests) are connection-level codes, distinct from the application-level 600xx error frames above. Send a ping at least every 30 seconds to keep the socket alive.


Handling pattern

Handle top-level and per-item codes uniformly:

resp = request("POST", "/api/v5/trade/batch-orders", orders)
if resp["code"] != "0":
# Overall failure (auth, rate limit, validation) or a partial batch failure.
for item in resp.get("data", []):
scode = item.get("sCode")
if scode not in (None, "0"):
print(f"item failed: {scode} {item['sMsg']}")
print(f"request-level: {resp['code']} {resp['msg']}")
else:
for item in resp["data"]:
# Even when top-level code == "0", per-item sCode is authoritative for batches.
if item.get("sCode", "0") != "0":
print(f"item failed: {item['sCode']} {item['sMsg']}")

For a conceptual walkthrough of the envelope and a troubleshooting checklist, see Error handling.