autoRebalance: false when creating the wallet so your application controls
exact dollar allocations and deposits remain in cash until you allocate them.
Store your API key in GROUND_API_TOKEN. The examples below use the sandbox API:
1. Create a wallet for each customer
Create a wallet without auto-rebalancing by settingautoRebalance: false. Save the Ground wallet
ID on your customer record.
portfolio_wallet.status_changed before creating the wallet. When
the matching walletId reaches idle, read GET /v2/wallets/{id} and show the
customer the appropriate deposit address. Handle failed as a provisioning
failure, and use the wallet read to reconcile a delayed or missed webhook.
2. Receive the completed deposit
Subscribe toportfolio_wallet.deposit.status_changed or poll the wallet’s
deposits. Allocate funds only after the deposit becomes completed. Verify the
webhook signature before parsing it, and deduplicate deliveries with the
Ground-Event-Id header.
cashPositionId as the source when allocating this deposit. IDs are unique
to each environment, so do not reuse sandbox IDs in production.
See Webhook signature verification
for the complete verification flow. Use the wallet read as a fallback when a
webhook is delayed or missed.
3. Allocate the cash
FetchGET /v2/wallets/yield-sources and use a returned source id as the
destination. Send the same allocations array to preview and create.
rebalanceId, requestId, createdAt, current
status, and accepted allocations. Returned dollar amounts use six decimal
places. Track portfolio_wallet.rebalance.status_changed or rebalance activity
until it finishes.
If Ground returns workflow_conflict, wait for the active withdrawal or
rebalance to finish, then retry.
4. Read or change an allocation
Read the wallet to get the customer’s current cash and investments:wallet.positions:
5. View yield
Read the customer’s lifetime earnings, estimated annualized yield, and current breakdown by yield source:6. Withdraw funds
Omitsources to let Ground choose the positions. To withdraw from specific
positions, include the amount from each source. Source amounts must add up to
amountUsd, and each source must contribute at least $0.01.
portfolio_wallet.withdrawal.status_changed until the withdrawal finishes.
Test the integration
In sandbox:- Create a wallet without automatic rebalancing and save its ID on a test customer.
- Deposit test USDC and confirm the completed deposit includes
cashPositionId. - Allocate part of the cash to two yield sources.
- Confirm the rebalance finishes and the wallet returns the new positions.
- Confirm
GET /v2/wallets/{id}/yieldreturns the customer’s yield summary. - Move funds between two existing positions.
- Complete one automatic withdrawal and one selected-source withdrawal.
requestId before sending a request. If the request times out, retry
with the same ID and body.