Authentication
API key auth
The SDK authenticates with an API key (sk_live_) in the X-API-Key header.
accountId explicitly to every account-scoped call via sdk.forAccount(accountId).
Rate limits
Exceeding limits returns a
429 with error code RATE_LIMITED or RATE_LIMIT.
Accounts
Resolution
The API key identifies your organization. TheaccountTypeId in the SDK config selects the Account Type. You resolve each account yourself.
Call sdk.lookupAccount(address) to resolve the account for a wallet address. It creates the account if it is new, but it does not deploy a Safe. Then call sdk.forAccount(accountId) to scope operations, and safe.request(chainId) to deploy a Safe.
client.
Safe submodule
Check and trigger Safe deployments on specific chains.resolve returns a discriminated union:
The REST response for
"validated" also includes accountId, userAddress, and chainId. Those fields are not declared on the SDK 3.1.2 SafeResolution type. Use the values you already have from lookupAccount(), forAccount(), and resolve() instead.
request is fire-and-forget. Deployment happens in the background.
Balance & positions
balance
Current aggregate balance with per-chain breakdown.
Each
perChain entry includes totalUnderlying in the token’s smallest unit and totalUnderlyingDecimals. Use getTotalUnderlyingBalance to normalize those values and sum them without floating-point arithmetic:
balanceHistory
Time-series balance snapshots. UsestartDate and endDate to filter.
positions
All position events (deposits, withdrawals, rebalances) sorted newest first.positions.events is a discriminated union. Every event includes matching kind and eventType fields.
Narrow on either discriminator:
price is the fiat value of the full event, not a per-token unit price. Rebalance events use usdValueIn and usdValueOut instead of price.
returns
Profit and loss metrics for the account.Yield
Account-type-level yield data. Not per-account.Request cancellation
Every async SDK method that makes an HTTP request acceptsRequestOptions as its final argument. Pass signal to cancel work when a user changes an input or a request is no longer needed.
For session methods, RequestOptions follows the intent parameters:
Error handling
SdkError
All SDK methods throwSdkError on failure.
@blend-money/node re-exports the shared SDK types and utilities. You do not need to import @blend-money/core directly.
Error codes
Session errors:
General errors:
Amount utilities
Convert between human-readable amounts and smallest-unit strings.parseAmount rejects fractional digits exceeding the token’s decimal count.
Key types
SessionStatus
OPEN to LOCKED to SETTLED. The submit endpoint records accepted transaction hashes and settles the session directly. SETTLED does not mean Blend verified transaction receipts. Use balances and positions as the source of truth for indexed on-chain activity.
SUBMITTED and FAILED remain in the type for historical sessions and compatible resume behavior. An executor can poll a legacy SUBMITTED session until it reaches a terminal state. Terminal states are SETTLED, FAILED, and CANCELLED.
SessionResult
Quote methods return aSessionResult. Narrow on type before you read actionPlan or actionPlans. See Deposits & Withdrawals for the full field list.
ActionPlan
ActionPlan with deployType: "direct". Withdrawals produce an ActionPlan[] with deployType: "multisend".
BalanceResponse
Using the SDK
Configuration, account management, and sessions.
Deposits & Withdrawals
Full deposit and withdrawal flows with cross-chain routing.