The D
The D

Reputation: 11

How to charge users based on api call with pay as you go model

We are building an api based business and currently logging all api calls to the cassandra db with corresponding timestamp. We have one endpoint with POST method. You can specify which parameters you want to use in the body and api returns the result.

However these parameters are affecting our costs a lot and some parameters are requiring a lot of calculation so we are charging based on user's request body.

Also we are using Stripe. How can we reliably charge users based on api calls? If you have any examples or blog post please post.

Upvotes: 1

Views: 361

Answers (1)

taintedzodiac
taintedzodiac

Reputation: 2906

You want to use Metered Billing. You'll create a subscription that is billed at the end of the billing cycle (normal subscription bill at the start). During the billing cycle, you'll use the API to report usage as it occurs.

If you want to charge different rates for different endpoints or types of calls, you can create subscriptions with multiple plans and report each plan's usage separately. The customer will then be billed for all plans under the same subscription.

Upvotes: 1

Related Questions