How to sell prepaid credits for an API

Short answer

To sell prepaid credits for an API, create a meter for the activity, create a Usage credits benefit for that meter, and attach the benefit to a product. Buyers pay by card and receive units, your app spends them, and Ruba tracks the balance. Ruba pays you to your own bank.

Why credits are friendly to small sellers

Ruba sells prepaid credits for 4% + $0.50 a sale, and usage draws them down. Imtiaz in Chattogram sells an image-resizing API. Customers pay him once, and he does not want to chase small invoices later. With prepaid credits, customers buy a pack, say 10,000 calls, and spend them as they go. The money comes first.

That also protects your costs. If every call costs you something, a customer cannot use more than they paid for.

Credits first, overage second

Here is the order. Your application sends an event to a meter. Ruba checks the customer’s balance. Credits are used first. Only when the balance is zero does extra usage become billable, and only if the product has a metered price.

Credits onlyNo overage
  1. 1Buyer pays for a packUnits are issued.
  2. 2App spends unitsEach event uses some.
  3. 3Balance reaches zeroRuba does not charge more.
  4. 4Your app decidesBlock, or offer a top-up.
Leave the product without a metered price.
Credits + overageMetered price
  1. 1Buyer pays for a packUnits are issued.
  2. 2App spends unitsCredits go first.
  3. 3Balance reaches zeroExtra use is overage.
  4. 4Ruba bills overageOn the subscription invoice.
Add a metered price to the product.
Figure 1From Ruba’s credits docs.

Set it up, step by step

Five steps
  1. Step 1Create a meterFor the activity you bill.
  2. Step 2Create the benefitUsage credits, with units.
  3. Step 3Choose rolloverCarry unused credits or not.
  4. Step 4Attach itTo a one-time or recurring product.
Figure 2From Ruba’s guide on funding usage after a purchase. Test it in the sandbox first.

A one-time product issues its units once after purchase. A subscription issues them at the start of each billing cycle.

Read the balance in your app

Ruba does not block a customer at zero. Your app reads the balance and decides. Use the Customer Meters API for credited, consumed and remaining units.

TypeScript
import { Ruba } from "@getruba/sdk";

const ruba = new Ruba({
  accessToken: process.env.RUBA_ACCESS_TOKEN ?? "",
  server: "sandbox",
});

const meters = await ruba.customerMeters.list({
  customerId: "<customer_id>",
});

for await (const page of meters) {
  for (const meter of page.result.items) {
    console.log(meter.meterId, meter.creditedUnits);
  }
}
Figure 3Adapted from Ruba’s docs. Add the fields your app needs.
Ruba does
Issue credits on purchase or each cycle
Track credited, consumed and remaining units
Use credits before overage
Your app does
Refuse a call at zero balance
Offer a top-up or upgrade
Show the balance to the user
Figure 4From Ruba’s docs.

What to do next

Ruba charges 4% + $0.50 per sale, with no monthly fee, and pays you in PKR, INR or BDT to your own bank. Money is ready 7 days after a sale, and payouts start at $10 after the fee. Apply for Ruba early access. Next: usage-based billing for an AI app.

Buyers pay first, then spend. You are never chasing an invoice. Nothing monthly to pay, and no company required. Early access gets your API credits a rate of 4% + $0.50 per sale, locked once you are approved and for as long as the account is open and in good standing. Ruba promises that a fee it never told you about is refunded, and that you get $100. Terms apply. See the early-access deal.

Questions people ask

What are credits in Ruba?

Credits are prepaid units attached to a Usage Meter. When an event reaches that meter, Ruba uses the customer’s available units first and bills any metered overage only after the balance reaches zero.

How do customers get credits?

Through a Usage credits benefit attached to a product. For a one-time product, the units are issued once after purchase. For a subscription, they are issued at the start of each billing cycle.

Do unused credits carry over?

Only if you turn on Carry unused credits over. It affects newly issued credits, not credits already granted.

Can I do credits with no overage at all?

Yes. Leave the product without a metered price for that meter, and the customer only spends what they bought.

Why not send negative events to model credits?

Do not do it. Negative events can change a Sum meter, but they are not recorded as first-class credited units. Use the Usage credits benefit.

Sources

We check these when we update this guide. Rules can change, so check them yourself before you decide.

A note from FaizanHi, I’m Faizan, the founder of Ruba. I built it so people anywhere, from Pakistan, India and Bangladesh to the UK, the EU and the US, can sell software to the world and get paid at home.I wrote these guides to be as fair as I can. But I built Ruba, so I’m about as neutral as a parent at a school play. That’s why every fact has a source you can check.
Early access is live.

Sellers approved now keep 4% + $0.50 per sale locked for as long as they sell, plus +$100 if we ever charge a fee we never told you about. No company and no monthly fee. You are paid to a bank in your own name, in PKR, INR, BDT or 51 other currencies, whenever you ask, from $10. A payout costs $2 up to $200.

Applying is not approval. Terms apply.
All guides

Can’t find your country or currency? Email support@getruba.com.

This guide is general information, not legal, tax or financial advice. Other companies named here set their own rules, which can change. Check their websites before you decide.