Introduction
Baremetrics offers simple integration with popular payment providers such as Stripe, Recurly and Braintree. If you are using one of those providers, go ahead and sign up and connect them right now!
If you're using a non-supported payment provider, or you're managing your own subscriptions, the Baremetrics API might be a great fit for you. With just a little dev work on your part, you can create customers and manage their subscriptions to unlock the full Baremetrics feature set.
You'll need a Baremetrics account to use the API. Your API keys are available in the Settings area.
Authentication
Authentication to the Baremetrics API is performed using a bearer token. To use this, send the following with your request:
-H "Authorization: Bearer APIKEY"
You can view your API key here
All requests must be sent over HTTPS
{
"error": "Unauthorized. Token not found"
}
RestClient.get 'https://api.baremetrics.com/v1/account'
Sandbox
To help you build your integration, we have setup a full sandbox environment for you.
The sandbox is underpowered relative to our production servers. Please only use the sandbox for testing that your code works... don't submit a significant amount of data else it could take a very very long time to process!
You can view your sandbox API key here
You can use the Sandbox API by using: https://api-sandbox.baremetrics.com
You can access the Sandbox Dashboard in your API Settings
You must access the sandbox from this link. Trying to access it directly will ask for a username/password, and your existing ones won't work for the sandbox.
Pagination
All endpoints return 30 objects by default. You can override this by passing the query param of per_page. The maximum objects per page is 200 at this time. You can specify the page by supplying the query param of page.
The following objects will be returned in all paginated responses:
{
"meta": {
"pagination": {
"has_more": false,
"page": 0,
"per_page": 30
}
}
}
Rate Limit
Our rate limit set to 1000 requests per hour. If you need to temporarily increase this, please contact us.
We will return the following headers to help you manage this:
X-RateLimit-Limit
X-RateLimit-Remaining
Quick Start Guide
Learn how to create your first plan, customer and subscription in Baremetrics. Still need help? Join us in the #api channel in our Slack!
Getting your first customer into Baremetrics requires only three steps! The steps must be completed in order, however. For example, you can't create a subscription without first creating a customer and a plan.
You only need to create a plan once! It can be used over and over again for multiple customers and subscriptions.
Before you begin, snag the Source ID for the provider Baremetrics. You will need this anytime you create, modify or interact with plans, customers, subscriptions or charges through the API.
Let's create a $10/mo. plan called *Basic Plan. Here's what that looks like.
The amount is in cents. So for our $10/mo. plan we will use an amount of 1000.
RestClient.post "https://api.baremetrics.com/v1/:source_id/plans", {
oid: 'basic_plan',
name: 'Basic',
currency: 'usd',
amount: 1000,
interval: 'month',
interval_count: 1
}
If you did everything right, you'll get a 200 response with your new plan details!
{
"plan": {
"oid": "basic_plan",
"source_id": "123",
"source": "baremetrics",
"name": "Basic",
"interval": "month",
"interval_count": 1,
"trial_duration": null,
"trial_duration_unit": null,
"created": null,
"active": true,
"setup_fees": 0,
"amounts": [
{
"currency": "USD",
"symbol": "$",
"symbol_right": false,
"amount": 1000
}
]
}
}
Once you have at least one plan you can start creating customers.
You only need to provide us a unique ID to create a customer. However to get the best experience, we recommend sending Baremetrics as much data as possible!
RestClient.post "https://api.baremetrics.com/v1/:source_id/customers", {
oid: '123123123', # Provide a unique ID for the customer
name: 'Josh Pigford',
notes: 'Salesperson: Kaegan Donnelly', # This will populate the notes field in the customer profile
email: 'josh@baremetrics.com', # We use the email address to retrieve social data about your customer such as a picture and location
created: 1471343207 # The unix date "created" date for a customer. We add this to the customer profile as well.
}
If everything goes as planned, we'll return a 200 response with more details about the customer that you've created!
{
"customer": {
"oid": "123123123",
"source_id": "source_1",
"source": "stripe",
"created": 1471343207,
"email": "josh@baremetrics.com",
"name": "Josh Pigford",
"display_image": "https://logo.clearbit.com/baremetrics.com",
"display_name": "Customer 1",
"notes": 'Salesperson: Kaegan Donnelly',
"ltv": 0,
"is_active": false,
"is_canceled": false,
"current_mrr": 0,
"current_plans": []
}
}
Alright, you're most of the way there! If you look at your Baremetrics dashboard though you won't see a whole lot. Since Baremetrics is all about tracking your subscriptions, this final step is crucial to getting your key metrics and insights!
You can get really fancy with subscriptions with things like addons and quantities, but we're going to keep this first one really simple.
RestClient.post "https://api.baremetrics.com/v1/:source_id/subscriptions", {
oid: 'abcdabcd', # A unique ID for the subscription
started_at: 1471887288, # The date the subscription begins
canceled_at: nil, # The date the subscription ends, if applicable
plan_oid: 'basic_plan', # The ID of the plan you created earlier
customer_oid: '123123123', # The ID of the customer you created earlier
}
Metrics generally update about once every 30 minutes, but it can take a couple of hours at times. Check the "Last Updated" date at the top right of your dashboard to see when we last calculated your metrics.
Here's what your finished subscription customer will look like in Baremetrics!
List Sources
Each Plan, Customer, Subscription and Charge belongs to a source. A source can be Stripe, Braintree, Recurly or the Baremetrics API.
When you want to interact with any of these objects, you must supply the Source in the URL. For example: GET /v1/:source_id/subscriptions
You can get your source_id from the Sources endpoint
Please note that while you can read data from your Stripe, Braintree and Recurly sources, you can only modify data that has been added via the API.
Update Customer
This endpoint allows you to update the basic information stored on a Customer, such as first name, last name and notes
Create Customer
This endpoint allows you to create a customer record. After you create the record, you will be able to create a Subscription
It may take a little while for us to fetch all of the profile information for the customer.
Delete Customer
You must delete all subscriptions for this customer before you can remove them.
Update Subscription
This allows you to update a Subscription, such as changing plans and addons.
Passing an empty "addons" array will remove all addons from this subscription.
It may take a while for your updates to appear in your metrics. There may also be a delay in the data being fully displayed in the GET /subscriptions endpoint.
Cancel Subscription
This endpoint allows you to cancel a subscription.
It may take a while for your cancellations to appear in your metrics.
To update the canceled_at time on a subscription, you may send subsequent canceled events. However, you cannot set the date further forward than it currently is set.
Create Subscription
This endpoint allows you to create a Subscription.
It may take a while for your subscriptions to appear in your metrics. There may also be a delay in the data being fully displayed in the GET /subscriptions endpoint.
How and why do I use addons?
Addons are used to add additional charges to a base plan. They allow you to create a variety of different combinations of features without creating a separate plan for each possible combination.
Let's look at a hypothetical way of charging for Baremetrics.
We could have a base subscription of $25/mo. Additional features like dunning, customer profiles, etc. could be treated as an addon.
$25/mo. base charge + $25 addon for Dunning = $50/mo.
Delete Subscription
It may take a while for your subscriptions to disappear from your metrics.
Create Charge
Create "One-Off" charges that are not linked to a subscription.
These charges do not affect MRR. They only impact Net Revenue and Other Revenue.
Available Metrics
The following metrics are available through our Read API.
- active_customers
- active_subscriptions
- add_on_mrr
- arpu
- arr
- cancellations
- coupons
- downgrades
- failed_charges
- fees
- ltv
- mrr
- net_revenue
- new_customers
- other_revenue
- reactivated_customers
- refunds
- revenue_churn
- trial_conversions
- upgrades
- user_churn
Show Customers
Returns a list of customers that make up this metric. For example, the upgrades metric will return all customers who have upgraded within the selected range. You can also see their MRR contribution.
