Make One Private Read
An authentication failure does not always mean the signature function is wrong. A key created on a different environment, an expired request timestamp, and a missing permission can all reject a private call for different reasons.
Preserve the returned retCode and message. Bybit's error reference distinguishes cases including 10002 for the request window, 10003 for key validity and environment checks, 10004 for signing, and 10005 for permissions.
This example requires a key created on Bybit testnet. It does not change the account or submit an order:
bybit-private-check.mjs
import { RestClientV5 } from 'bybit-api';
const key = process.env.BYBIT_TESTNET_KEY;
const secret = process.env.BYBIT_TESTNET_SECRET;
if (!key || !secret) throw new Error('Set both Bybit testnet credentials');
const client = new RestClientV5({ key, secret, testnet: true });
const response = await client.getAccountInfo();
if (response.retCode !== 0) {
throw new Error(`Bybit ${response.retCode}: ${response.retMsg}`);
}
console.log({ marginMode: response.result.marginMode });
A public ticker call can establish connectivity but cannot establish private credentials. A successful private read narrows the problem further than a failed order whose account mode, quantity, and permissions all remain unchecked.
Check the Key and Environment
Confirm where the key was created and which domain the client addresses. Testnet and demo are different environments. Regional routing can impose another distinction, so use the current integration guide for the actual account.
Verify that the key is active, its IP restrictions match the application's egress, and its permissions cover the read being attempted. None of those checks requires exposing the key in a support log.
Match the Signing Key Type
Bybit supports HMAC and RSA key workflows. The SDK accepts its signing material through the secret option. For RSA that is the private key content in the supported PEM format, not a path to the file and not the public key uploaded to Bybit. The SDK tutorial and its authentication examples own the full setup.
Preserve real PEM line breaks when loading a file. An environment variable containing literal backslash-n characters is a different string from a multi-line key unless the configuration loader converts it deliberately.
Investigate the Specific Failure
For a signing error, check key type and any custom serializer or signing hook. For a timestamp error, check clock and dispatch delay. For a permission error, reduce the call to an operation the key is actually allowed to perform.
Change one cause at a time and keep the response code with each result. Increasing a receive window or enabling time synchronization is not a general fix for an incompatible key or missing permission.
Related articles
Continue from here