Treasury API
The org's wallets, its live portfolio, historical value, and the audit trail — everything else on the platform builds on what's in here.
Treasury is the org's home base — a wallet imported here is immediately available to Pay, Trade, Earn, and Borrow, and every product's activity reconciles back into the same portfolio and ledger this API reads. Requires a key or token scoped to Treasury; see Getting started.
Reads are instant, writes go through approvals
Everything on this page except wallet imports is read-only. Anything that moves funds — a payment, a trade, a deposit — is an order that flows through your org's approval policy first: see Approvals & signing.
Watch-only and org-wide — import once here and every product reads from the same list.
Import a wallet
import { TreasuryClient } from '@mooneum/sdk';
const client = new TreasuryClient({
baseUrl: 'https://api.mooneum.com',
token: 'sk_…',
});
// A plain address wallet…
const wallet = await client.importWallet({
app: 'treasury',
type: 'WATCH_ONLY',
chain: 'ethereum',
address: '0x…',
name: 'Operating wallet',
});
// …or a Bitcoin HD wallet from an xpub (fresh address per invoice — see the Pay API guide):
const btc = await client.importWalletXpub({
app: 'treasury',
chain: 'bitcoin',
xpub: 'zpub6…',
name: 'BTC treasury',
});type accepts WATCH_ONLY (the default — Mooneum never holds a key), HOT, or a paired
hardware wallet (HARDWARE_LEDGER / HARDWARE_TREZOR). app records which product the import
happened from; the wallet itself is still org-wide the moment it exists.
List, sync, and manage
const wallets = await client.listWallets();
const wallet = await client.getWallet(id); // with live balances
await client.syncWallet(id); // request an immediate re-sync
await client.updateWallet(id, { name: 'Renamed wallet' });
await client.setWalletActive(id, false); // deactivate without removing itExchange accounts (Binance, Coinbase, Kraken) and Stripe accounts live beside wallets, same shape:
const exchanges = await client.listExchangeAccounts();
await client.createExchangeAccount({
exchange: 'coinbase',
label: 'Main',
apiKey: '…',
apiSecret: '…',
});
const stripeAccounts = await client.listStripeAccounts();Live holdings, historical value, and cashflow — the numbers behind the Treasury dashboard.
const portfolio = await client.getPortfolio(); // live holdings, per wallet and asset
const overview = await client.getTreasuryOverview(); // org-wide dashboard totals
const history = await client.getTreasuryHistory(90); // daily portfolio value, last 90 days
const cashflow = await client.getTreasuryCashflow(30); // in/out flows, last 30 daysgetTreasuryHistory/getTreasuryCashflow take a single days argument (default 30) — the
number of trailing days to return.
Named portfolios
Group wallets into views — one per subsidiary, desk, or fund — without changing who owns what:
const portfolios = await client.listNamedPortfolios(); // rolled-up value per group
const group = await client.createNamedPortfolio({
name: 'Payroll',
kind: 'PAYROLL',
});
await client.assignPortfolioWallet(group.id, walletId);
await client.deleteNamedPortfolio(group.id); // unassigns its wallets, doesn't remove themkind is one of OPERATING, PAYROLL, INVESTMENT, COLD_STORAGE, or CUSTOMER —
informational, doesn't change behavior.
The org's verified counterparties, and the compliance trail every mutating action writes.
Address book
const entries = await client.listAddressBook();
await client.createAddressBookEntry({
chain: 'ethereum',
address: '0x…',
name: 'Landlord',
});POST /api/v1/treasury/address-book/{id}/verify marks an entry verified. Pay's send flows and
the first-time-recipient warning both read from this list, and it's what a policy whitelist
rule checks against — see
Policies & compliance.
Audit log
Every mutating action across the platform, in one feed — the endpoint your compliance export job wants:
const recent = await client.getAuditLogs({ limit: 100 });
const older = await client.getAuditLogs({
limit: 100,
cursor: recent.at(-1)?.id,
});