Skip to navigation

Add funds to your balance

1

Create your first top up in the dashboard

Before using the API, you need to create a top up from the Dashboard. This saves a payment method that you can reuse programmatically.

2

Get payment methods

List saved payment methods for your company:

const paymentMethods = await client.paymentMethods.list({
company_id: "biz_xxxxxxxxxxxxx",
});
const paymentMethod = paymentMethods.data[0];
3

Create a top up

const topup = await client.topups.create({
company_id: "biz_xxxxxxxxxxxxx",
amount: 1000.0,
currency: "usd",
payment_method_id: paymentMethod.id,
});
console.log(topup.id);

In this example:

  • company_id is your platform’s company ID
  • amount is the amount to add to your balance
  • currency is the currency of the top up
  • payment_method_id is the saved payment method to charge
4

Handle payment events

Listen for payment webhooks to confirm the top up was successful:

if (webhookData.type === "payment.succeeded") {
const payment = webhookData.data;
console.log("Top up successful:", payment.id);
}
if (webhookData.type === "payment.failed") {
const payment = webhookData.data;
console.log("Top up failed:", payment.failure_message);
}