Authentication
SIWE flow (frontend)
The frontend SDK uses Sign-In with Ethereum. The user’s wallet signs a challenge message. Blend returns a JWT that binds the wallet to a Blend account. The JWT contains the wallet address, account ID, and account type. Every SDK call after sign-in includes it automatically. You never pass an account ID.API key auth (server)
The server SDK authenticates with an API key (sk_live_) in the X-API-Key header. No challenge/verify step. The API key replaces both the publishable key and the SIWE session.
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.
Session security
- Keep JWTs in memory. Use
sessionStoragefor persistence across reloads. AvoidlocalStorage. - Clear the session when the wallet disconnects or address changes.
- Never share an exported session across users or account types.
Auth error codes
Accounts
Resolution
How Blend maps wallet addresses to accounts differs by SDK. Frontend (automatic): The publishable key identifies your organization and account type. SIWE proves wallet ownership. After sign-in, the account is implicit. Server (manual): The API key identifies your organization. TheaccountTypeId in the SDK config selects the product. You call sdk.lookupAccount(address) to resolve the account (creates it if new, but does not deploy a Safe). Then call sdk.forAccount(accountId) to scope operations, and safe.request(chainId) to deploy a Safe.
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.0.1 SafeResolution type. Use the authenticated account context when writing TypeScript against this release.
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:
@blend-money/node.
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.
RequestOptions follows the intent parameters:
Error handling
SdkError
All SDK methods throwSdkError on failure.
SdkError from @blend-money/node. Both wrapper packages re-export the shared SDK types and utilities, so applications do not need to import @blend-money/core directly.
Error codes
Session errors:
Auth errors:
General errors:
Amount utilities
Convert between human-readable amounts and smallest-unit strings.parseAmount rejects fractional digits exceeding the token’s decimal count.
Server integrations import these utilities from @blend-money/node.
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.
DepositQuote
WithdrawQuote
ExecuteResult
ActionPlan
ActionPlan with deployType: "direct". Withdrawals produce an ActionPlan[] with deployType: "multisend".
BalanceResponse
Frontend SDK
Frontend configuration, auth, and execution.
Server SDK
Server configuration, account management, and sessions.