Skip to content

Wallets

Wallets provide a prepaid credit system for customers. Credits can be granted manually or automatically, and are consumed during invoice finalization to reduce the amount due.

FieldTypeDescription
iduuidUnique wallet identifier
customer_iduuidCustomer this wallet belongs to
namestringDisplay name
codestringOptional unique code per customer
statusenumactive, terminated
balance_centsstringCurrent balance in cents
credits_balancestringCurrent balance in credits
consumed_amount_centsstringTotal consumed amount in cents
consumed_creditsstringTotal consumed credits
rate_amountstringConversion rate: balance_cents = credits × rate_amount × 100. Default: 1.0 (1 credit = $1)
currencystringISO 4217 currency code
priorityintegerConsumption order (1–50, lower = consumed first)
expiration_atdatetimeOptional expiration date
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
ACTIVE → TERMINATED

Active wallets accumulate and consume credits. Terminated wallets cannot process further transactions. Wallets can optionally expire at a set date.

Terminal window
curl -X POST /v1/wallets \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "customer-uuid",
"name": "Main Credits",
"code": "main",
"currency": "USD",
"rate_amount": "1.0",
"priority": 1,
"initial_granted_credits": "100.00",
"expiration_at": "2026-12-31T23:59:59Z"
}'
FieldDescription
rate_amountConversion rate: balance_cents = credits × rate_amount × 100. Default: 1.0 (1 credit = $1)
priorityConsumption order (1–50, lower = consumed first)
initial_granted_creditsCredits to grant immediately on creation
expiration_atOptional expiration date
codeOptional unique code per customer
Terminal window
curl -X POST /v1/wallets/{wallet_id}/top_up \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"credits": "50.00",
"source": "manual"
}'
SourceDescription
manualManually granted by admin
intervalAutomatically granted on a recurring schedule
thresholdGranted when usage crosses a threshold

Each top-up creates an inbound wallet transaction and increases the wallet balance.

Transfer credits from one wallet to another:

Terminal window
curl -X POST /v1/wallets/transfer \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source_wallet_id": "source-wallet-uuid",
"target_wallet_id": "target-wallet-uuid",
"credits": "25.00"
}'

The response returns updated source_wallet and target_wallet objects along with credits_transferred.

When an invoice is finalized, wallet credits are consumed automatically:

  1. Active, non-expired wallets are sorted by priority (ascending), then by creation date
  2. For each wallet, the consumable amount is min(wallet.balance, remaining_invoice_amount)
  3. An outbound wallet transaction is created
  4. An InvoiceSettlement record links the consumption to the invoice
  5. The process continues until the invoice is fully covered or no wallets remain

A customer has two wallets:

WalletPriorityBalance
Promo Credits1$25.00
Main Credits2$100.00

For a $40.00 invoice:

  1. Promo Credits consumed: $25.00 (balance → $0.00)
  2. Main Credits consumed: $15.00 (balance → $85.00)
  3. Invoice prepaid_credit_amount: $40.00
Terminal window
DELETE /v1/wallets/{wallet_id}

Sets the wallet status to terminated. Remaining balance is forfeited.

Wallets with an expiration_at date are automatically terminated by a background task when the expiration date passes. The check_expired_wallets task handles this.

List all transactions for a wallet:

Terminal window
curl /v1/wallets/{wallet_id}/transactions \
-H "Authorization: Bearer $API_KEY"
FieldTypeDescription
iduuidTransaction identifier
wallet_iduuidParent wallet
customer_iduuidCustomer identifier
transaction_typestringinbound (credit) or outbound (debit)
transaction_statusstringTransaction status
sourcestringmanual, interval, or threshold
statusstringCurrent status
amountstringAmount in currency
credit_amountstringAmount in credits
invoice_iduuidLinked invoice (if outbound)
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp
TypeDirectionDescription
inboundCreditTop-up or grant
outboundDebitConsumption against invoice
StatusDescription
grantedCredits granted
purchasedCredits purchased
voidedTransaction voided
invoicedLinked to an invoice

Get a daily breakdown of credits in and out over a date range:

Terminal window
curl "/v1/wallets/{wallet_id}/balance_timeline?start_date=2026-01-01&end_date=2026-01-31" \
-H "Authorization: Bearer $API_KEY"

Each point in the response contains:

FieldDescription
dateCalendar date
inboundTotal credits added on this date
outboundTotal credits consumed on this date
balanceEnd-of-day balance

Get a projected depletion date based on recent consumption rate:

Terminal window
curl "/v1/wallets/{wallet_id}/depletion_forecast?days=30" \
-H "Authorization: Bearer $API_KEY"

The days parameter controls how many days of historical consumption to use for the projection.

FieldDescription
wallet_idWallet identifier
current_balance_centsCurrent balance
avg_daily_consumptionAverage daily consumption over the lookback period
projected_depletion_dateEstimated date the wallet will reach zero (null if no consumption)
days_remainingEstimated days until depletion (null if no consumption)

Wallets are also accessible via the customer portal API:

MethodPathDescription
GET/portal/walletGet wallet balance and transactions
GET/portal/wallet/{wallet_id}/balance_timelineGet wallet balance timeline
POST/portal/wallet/{wallet_id}/top_upRequest a wallet top-up
GET/portal/wallet/{wallet_id}/transactionsList wallet transactions
MethodPathDescription
POST/v1/walletsCreate a wallet
GET/v1/walletsList wallets
GET/v1/wallets/{id}Get wallet details
PUT/v1/wallets/{id}Update wallet (name, expiration, priority)
DELETE/v1/wallets/{id}Terminate a wallet
POST/v1/wallets/{id}/top_upAdd credits
POST/v1/wallets/transferTransfer credits between wallets
GET/v1/wallets/{id}/transactionsList transactions
GET/v1/wallets/{id}/balance_timelineGet daily balance timeline
GET/v1/wallets/{id}/depletion_forecastGet projected depletion date