BlueForge Docs

client.wallet.debit

Debit (spend) from a workspace wallet

Signature

class Client {
  wallet: {
    debit(workspaceId: string, input: DebitInput): Promise<{
      transactionId: string
      balanceCents: number
    }>
  }
}

Parameters

NameTypeRequiredNotes
workspaceId
string
YesWorkspace ID
input
DebitInput
YesDebit details (amountCents, description?, metadata?)

Throws

  • NotFoundError
    — workspace not found
  • InsufficientFundsError
    — balance too low
  • WalletFrozenError
    — wallet is frozen

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
    WalletFrozenError
    ; thaw with
    client.wallet.unfreeze
    first
  • Insufficient balance — throws
    InsufficientFundsError
    if the wallet balance is too low

See also

  • client.wallet.credit
  • client.wallet.getBalance

Tested against

  • Unit:
    packages/client/src/__tests__/wallet.test.ts