Quickstart
Implement pricing & billing in under 5 minutes
In this tutorial, we’ll set up pricing for an AI chatbot product. Here are the products we want to offer:
Feature | Free Plan | Pro Plan |
---|---|---|
Chat messages | 10 per month | 50 per month |
Pro Analytics | ✖️ | ✔︎ |
Price | Free | $99 per month |
Step 1: Define product features
We can define the chatbot’s features in the Autumn dashboard, under the Features tab. We’ll create two features:
- “Chat messages”: a
metered
feature, as it has a quantity that can be used up. - “Pro Analytics”: a
boolean
feature, as it’s a simple on-off toggle depending on the tier
We’ll use the feature_id
and event_name
defined here when calling the Autumn APIs from our application (see Step 4).
Step 2: Create a product
Next, let’s head over to the Products tab and create our 2 products.
- “Free”: and give it the entitlement “Chat messages” with a limit of 10 messages per month. Make sure you set it as a default product, so that it’s automatically attached to any new customers.
- “Pro”: and set the entitlement “Chat messages” to 50 per month, add the entitlement “Pro Analytics” and set the price to $99 per month.
Step 3: Attach a product on purchase
Now we can integrate this pricing model into our application. When our user clicks on our ‘Upgrade to Pro’ button from our frontend, we’ll call the /attach
endpoint.
This will return a Stripe Checkout URL, which we can redirect the customer to, in order to complete their payment.
Make sure you’ve pasted in your Stripe test secret
key sk_test_...
in the Autumn
dashboard. For testing, you
can also paste your test key in the live key field.
You can do this directly from your frontend. Use your AUTUMN_PUBLISHABLE_KEY
from the Developer page.
Autumn will automatically create a customer if the customer ID is new.
Step 4: Check access and send usage events
Finally, whenever a customer tries to use a chat message, you can check if they are allowed by calling the /entitled endpoint. When they successfully use a chat message, send a usage event by calling the /events endpoint, and Autumn will update the customer’s usage.
Sending usage events requires using your AUTUMN_SECRET_KEY
. Create one from
the Developer page.