Skip to main content
This guide walks you through creating an entity-owned custodial account in Sandbox, adding test balances in the CDP Portal, and checking balances. You can also create a customer-owned account with the CLI or SDK by setting the optional owner parameter. You can follow along with the CDP CLI, TypeScript SDK, or Java SDK. Use the tabs in each step to switch between them.
Custodial account operations are available in the TypeScript and Java SDKs. For other languages, use the CDP CLI or call the Accounts REST API directly.
For Sandbox API keys and environment basics, see the Sandbox quickstart. Base API URL (Sandbox): https://sandbox.cdp.coinbase.com

Prerequisites

  • A CDP login with access to the CDP Portal
  • For the CLI or TypeScript SDK: Node.js 22 or later
  • For the Java SDK: JDK 21, Gradle, and a GitHub personal access token (classic) with read:packages access
  • A Sandbox API key JSON from the Portal (Sandbox environment, Accounts permission enabled)
Never commit API keys to source control. Store them in environment variables or a secrets manager. Do not use real personal data in the Sandbox environment.

1. Install and configure

CDP CLI handles JWT authentication for you — configure your API key once and it signs requests.
Node.js 22 or later is required.
Configure your Sandbox API key:
Use -e sandbox on commands below if your default environment is not sandbox, or run cdp env sandbox to switch context. More detail: CDP CLI quickstart.

2. Create an account

Create a named entity account. Omitting owner makes the account entity-owned. Supplying an idempotency key is optional but recommended — it makes the request safely retryable, so retries return the same result instead of creating duplicate accounts. See Idempotency.
Create the account with POST /v2/accounts:
With an idempotency key:
cdp api paths are relative to the Sandbox platform base https://sandbox.cdp.coinbase.com/platform/v2. If cdp api fails with a host or path error, configure the URL explicitly: cdp env sandbox --key-file ~/Downloads/cdp_api_key.json --url https://sandbox.cdp.coinbase.com/platform/v2. See How it works.
Copy the accountId from the response (for example account_af2937b0-9846-4fe7-bfe9-ccc22d935114). You use it in the Portal and in later steps below.

Create a customer-owned account

To create a customer-owned account instead, pass the customer’s ID as owner. Before you run an example:
  • Follow the Customers quickstart to create a customer in Sandbox.
  • Confirm that all three custody capabilities — custodyCrypto, custodyFiat, and custodyStablecoin — are active. If any are missing, account creation returns 403 with errorType: customer_not_authorized.
  • Replace the example customer ID with your customer’s ID.
  • Set REQUESTER_IP_ADDRESS to the end user’s public IPv4 or IPv6 address. Pass it as compliance.requesterIpAddress, not your application’s server IP. Customer-owned account creation requires this field under the custody capability policy; omitting it returns 400 with errorType: invalid_request when enforcement is active.
Replace the placeholder before running an example. In your application, obtain the IP from the end user’s request using your trusted proxy configuration. Replace the entity-owned account creation call with the CLI or SDK example:
Reuse the Sandbox environment configured in step 1. Pass the customer ID as owner:
The response’s owner is the customer ID you supplied. Use the returned account ID for the remaining funding and balance steps. See Create account for the full request and response schema.

3. Create and fund the account through the Portal

Sandbox does not move real funds. You add simulated balances in the Portal:
1

Go to Sandbox Accounts

In Sandbox mode in the CDP Portal, open the Accounts tab.
2

Select the test account

Open the account you created with the API (for example My Test Account).
3

Add test assets

Add balances in supported test assets (for example USD and USDC). Values are for testing only.
Sandbox account showing test balances for USD, USDT, and USDC
All balances are simulated in Sandbox — no blockchain or testnet connectivity. You cannot fund accounts by sending real or testnet crypto.

4. List and inspect accounts

After funding the account, list your Sandbox accounts and inspect one account’s balances.
List all accounts:
Inspect an account:

5. Verify balance(s)

List all custodial account IDs:
cdp accounts list and cdp accounts balances ship in recent @coinbase/cdp-cli releases. If your CLI reports an unknown command, run npm install -g @coinbase/cdp-cli@latest, then try again. You can always use cdp api "/accounts/$ACCOUNT_ID/balances" -e sandbox as a fallback; see List balances for account.

Custodial wallets overview

Concepts: custody model, ownership, and how accounts connect to payments

CDP CLI how it works

Environments and cdp api field syntax

Deposit Destinations Quickstart

Generate inbound addresses tied to an account

Accounts API reference

REST reference for account and balance endpoints