client.wallet.debit
Debit (spend) from a workspace wallet
Signature
class Client {
wallet: {
debit(workspaceId: string, input: DebitInput): Promise<{
transactionId: string
balanceCents: number
}>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| workspaceId | | Yes | Workspace ID |
| input | | Yes | Debit details (amountCents, description?, metadata?) |
Throws
— workspace not foundNotFoundError
— balance too lowInsufficientFundsError
— wallet is frozenWalletFrozenError
Examples
import { Client } from '@blueforge/client'
const bf = new Client({ apiKey: process.env.BF_API_KEY!, url: 'https://your-project.blueforge.dev' })
const { transactionId, balanceCents } = await bf.wallet.debit('ws_abc', { amountCents: 500 })
Pitfalls
- Frozen wallets — debiting a frozen wallet throws
; thaw withWalletFrozenError
firstclient.wallet.unfreeze - Insufficient balance — throws
if the wallet balance is too lowInsufficientFundsError
See also
client.wallet.creditclient.wallet.getBalance
Tested against
- Unit:
packages/client/src/__tests__/wallet.test.ts