How to process metered usage in Bubble.io

Dennis H. Lewis shows how to set up usage-based billing in Bubble.io with Stripe. Create a meter in Stripe, configure your Bubble app to send usage events (customer ID, timestamp, value), then create a subscription product that charges per unit. Works for AI services, image generation, and other variable-cost features.
Chapters
Are you watching your SaaS dreams die because you can't figure out how to charge your users for what they actually use? Look, I've been building applications since before the Internet was a thing. I was working for IBM when aix, their version of Unix was literally classified. And I can tell you metered billing isn't just a nice to have anymore, and it's how you survive in 2025 and 2026. And today I'm going to show you exactly how to set up metered usage billing in your bubble application using Stripe. No fluff, no theory, just the exact system we use@ratio.dev to help our clients turn variable costs into predictable revenue. And stick around because at the end I'm giving you free access to our complete no code resource center where we've documented the entire process for plus vetted how to videos and tools. We actually use links in the description below. Here's the thing that most founders don't understand about subscription models, and that's that they're dying. Let's think about it. Who wants another $49 a month charge hitting their credit card for a tool they might not even use? I sure don't. My wife literally audits our subscriptions every quarter like she's the irs. But what if you only charged people for what they actually consumed? Suddenly the risk shifts from your customer to you. And if your product doesn't deliver value, they pay almost nothing. But if it does deliver value, if it really solves their problem, then this becomes the goose that never stops laying golden eggs. Look, nobody wants to be another Netflix or Disney or Apple TV showing up on a credit card every month for not getting watched. Look at the AI tools dominating the market. Anthropic Midjourney Gemini. They're all doing usage based pricing. Why? Because their costs are variable. When you use ChatGPT in your application, you're going to pay OpenAI for all of the tokens that you consume. And when you generate an image in midjourney or in some other platform, you're going to pay for that as well. So having a fixed monthly fee can actually turn out to be kind of dangerous for you as well. You have to really keep track of your costs, but by using usage based billing in your application as well. Now you're only charging the customer for what they use, but you're also for sure charging them for what they consume. And that is a is a real boon for you as well. And what's really cool is you can mix and match. You can have prepaid credits you could have a subscription that gives them a certain amount of credits every month. You could roll them over or not. You can have, you know, you can make them pay up front, you can make them pay for topping up their balance, however you want to build your business. And fortunately Stripe has all of the tools to be able to implement this. But as far as I can tell, very few people are talking about this in the Bubble community and, and Bubble hasn't added in this into their native plugin, although you might could hack parts of it together. But in this video, I'm going to explain to you all the pieces that you need and I'm going to show you how to do it so that this will work really well in your business. So the first thing you're going to need to do is you're going to need to jump into your Stripe account and you're going to go to usage based billing and what you're going to do is you're going to create.
A meter, just like a parking meter where you would pay for 30 minutes downtown in front of the courthouse. The idea here is it's a variable that you're going to track. And Stripe gives you a lot of flexibility.
They could be tokens that are consumed. You could take the, once a month, take the sum of all those tokens and build them. When you create one of these test meters, you can aggregate them as a sum. You could do the count how many times an event has happened in a, over the, over the timeframe. So maybe you don't really want to do tokens, but you want to do chat sessions. Well, you could do that. It could be a count or you could take the last value that you sent in and based on that you could charge. So there's a lot of flexibility here about how you're going to do it and you're just going to create the name and then you're going to create that meter so that in this case we've created one called Connected Clients and I'm going to bill them by the number of clients they have connected through the, through the API and the max number they've had this month, they're going to pay for that. You can, you can make, mix this up with, try, you know, free trials with coupons with subscriptions. You can make it as simple or complicated as you want. You could use tiers, so you could have a, you know, three level tiers and based on that, give them more, more tokens. It's all up to you. Now then once you've done that we need to go in to the bubble builder. I'm going to open up here. I've created an API for Stripe using private key in the header to use the authorization. And for metered usage, I've created now a call here, which means that I'm going to use this API call to tell Stripe to this customer has taken this event.
And I've sent it a value. So it's used seven tokens, it's used 700 tokens.
Four connected clients. It's whatever you want to control and bill by in Stripe. So you're going to pass it the event name. The URL here is Meter Events. You're going to pass it a timestamp and oh, and you're going to pass it the customer ID obviously so that it knows which customer you're going to want to set up your parameters this way. This is just how the Stripe API likes it. So you're going to want to use application and this is your content type. It is an action, it's based on JSON. I'm going to run this in a backend workflow and you can see here how I've set up four parameters. Not doing them in the JSON object down here below. It won't work. So they need to be set up this way. They need to have query string checked off here. And once you've done that, you can just initialize the call and now you can every time in your application when something changes, you just call this event and it gets registered in Stripe. And then based on that, you and how you set up your workflow in, you know, your products in Stripe and the pricing that you've given it, it will. Every billing period, we'll charge them the amount that they need to pay for. Really not that much more there that we need to talk about. We're going to want to also create a subscription for them. So when you do that, this is going to be the other Stripe call here that you're going to want to do. You can pass whatever parameters here that you want your product here in Stripe, the product that you create will use this meter. So here in Stripe, when we go to product catalog and we have a product here for this that I have set it up, it's set as per unit for every four weeks. And this is the meter. I've set it with the connected clients and that's how Stripe knows that this subscription uses this meter. And you could have a, you could have a fixed fee plus a meter for overage. You can, you can mix and match as you like. But this is how Stripe will automatically make that calculation for that invoice every month and send it to the customer's credit card. So that is basically all of the pieces of the puzzle that you're going to need. And we've seen how you can create your metered product. We've seen how to set up the API connector, we've seen how to create a subscription. And then yes, you can combine that with free trials if you want. During the free trial, the usage won't be counted, and it will only start to count once the trial's over. So just know that. And remember to go to ratio.dev, put in your name and your email. You can get free access to our no Code Resource Center. That's where we put all of our videos, where we put all of our the tools we recommend, all of the books we recommend, our podcast episodes. Uh, it's updated weekly. It's totally free. Really convinced it's going to help you on your bubble journey, so be sure to sign up for that. And if you have any questions at all about actually setting up metered usage in your bubble application, if hopefully this video has shown you the path. But if you'd like some help, reach out to us. We'll be glad to jump into your application and set it up for you if that would be of use to you. And if you've liked this video, well, give it a thumbs up. Subscribe to our channel. That means the world to us. We really appreciate it. Thanks for watching. See you on the next video.
More from Dennis

Is Google Killing Websites? The Future of Search, SEO & Web Design After Google I/O

Something we're still looking forward to in Bubble: richer design experiences! #bubble #nocode #ai

Big mistake companies are making right now: firing employees instead of empowering them. #ai







