Sandboxes
Available environments
Coinbase sandbox support is product-specific. useSandbox is not a universal switch for every Coinbase client. Production is the default.
Advanced Trade static sandbox
Set useSandbox: true on CBAdvancedTradeClient to select the static REST sandbox. It returns predefined mock responses for the endpoints listed by Coinbase. The service does not require authentication, but the SDK's flag changes routing rather than disabling its normal request signing.
Omit credentials when inspecting unauthenticated mock responses. Use this service to inspect supported response shapes. It cannot validate live credentials, account balances, matching or fills. There is no Advanced Trade WebSocket sandbox; do not enable useSandbox on Advanced Trade streaming clients. Keep public production streams clearly separated from mock REST results.
Exchange sandbox
CBExchangeClient and Exchange WebSocket feeds support useSandbox: true. Create a sandbox account and API credentials specifically for that environment; production login sessions and API keys do not carry over. The REST client uses apiKey, apiSecret and apiPassphrase.
import { CBExchangeClient, WebsocketClient } from 'coinbase-api';
function requiredEnv(name: string): string {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} in your server environment.`);
return value;
}
// Configure clients only. No requests, subscriptions or orders are sent.
const options = {
apiKey: requiredEnv('COINBASE_EXCHANGE_SANDBOX_API_KEY'),
apiSecret: requiredEnv('COINBASE_EXCHANGE_SANDBOX_API_SECRET'),
apiPassphrase: requiredEnv('COINBASE_EXCHANGE_SANDBOX_API_PASSPHRASE'),
useSandbox: true,
};
export const rest = new CBExchangeClient(options);
export const ws = new WebsocketClient(options);This example only constructs clients. Use Exchange connection keys when subscribing; the option does not make Advanced Trade or other product streams into Exchange sandbox streams.
The sandbox uses fake funds and a subset of production order books. Transfers are unavailable. The SDK selects its standard Exchange sandbox hosts; it does not automatically select the additional MiCA sandbox hosts listed in Coinbase's documentation. Check current account and regional requirements in the Exchange sandbox guide.
Coverage and limitations
Other products
The SDK does not configure sandboxes for App, Prime, legacy Commerce or Advanced Trade Global. A sandbox documented for a different Coinbase API does not imply support in these clients.
CBInternationalClient retains legacy sandbox routing, but that is not evidence of an available testing service. Coinbase's institutional migration FAQ says INTX migrated to Deribit and old INTX endpoints no longer support trading. Do not start a new sandbox integration against those retained routes; follow Coinbase's current migration and access guidance.
What these environments can prove
Use test environments to check request formats, credentials, order handling and reconnect recovery within the features they support. Testnet liquidity, prices, fills, fees and availability can differ substantially from production. Accounts, balances and order history may also be reset.
Testnet is not a reliable place to evaluate strategy performance. Demo trading may use production market data, but simulated fills do not establish live profitability, slippage, execution quality or capacity. Treat both as integration tests, not evidence that a strategy will succeed with real funds. See the CEX testnet overview for the distinction between testnet and demo trading.
Before switching environments
- Keep credentials and configuration separate for each account, product and environment. Never fall back to live credentials when a test key is missing.
- Configure every REST, subscription and WebSocket API client separately. Changing one client does not reconfigure another.
- Check the selected environment's supported endpoints and instruments before sending a request. Similar method signatures do not imply identical availability.
- Keep authenticated requests on your server. Confirm the destination and account before enabling any write operation.
Production remains the default. Selecting a test environment is an explicit choice for each client; it is not a global SDK setting.