Creating Billing Meters
Creating a New Billing Meter
Creating a new billing plan can be done in a few different ways. You can do it through the New Billing Meter menu item in the left navigation menu.
It can also be done through the Metered Billing screen by clicking Add Billing Meter on the Billing Meter list screen.
Additionally, by clicking the Create New button in the left navigation menu and selecting Billing Meter under Alerts and Workflows, a new meter can be created.
A new billing plan will require a few details, including:
- Name
- This will be the name that your billing meter will display as in Moesif
- Billing provider info
- This includes the linked billing provider, plan/product, and add-on/price that this meter will report to.
- Filters
- This is the criteria for which API transactions or actions should be included in the metric.
- Metric to charge on
- This is the metric that you charge customers on. Generally, Event Count is common to choose, but other options exist including Unique Users, Unique Companies. You can also formulate your own metric using custom metadata fields such as to track bandwidth consumed or other metrics.
The fields are shown on the screen like so:
Usage is always grouped by Company Id. The usage totals for each company will be tallied and sent to the billing provider to charge the customer based on plan and add-on billing cycle.
Editing an Existing Billing Meter
Updates to existing billing meters is limited to changing the name and status (enabled or disabled) of the billing meter. Editing an existing plan is limited due limitations that need to be enforced for audit purposes.
Once a plan has been created, it can be edited and updated by going to the Metered Billing list screen and clicking on the plan Name of the plan you want to change.
You can also edit the details for the plan by clicking on the kebab menu at the end of the billing entry and selecting View Details.
Linking a Billing Meter to a Billing Provider
If you have not set up a billing provider, you can do so by clicking the Billing Provider dropdown on the Metered Billing details screen, by clicking the Edit Billing Provider button on the Metered Billing list screen, or by going to Settings > Extensions and selecting the billing provider that you want to configure or edit from the extensions list.
When you create a new billing meter, under the Link To section at the top of the Metered Billing input screen, you can select your billing provider, plan/product, and add-on/price that the usage data should be counted towards and linked to. Depending on the billing provider being used, this data will pre-populate (unless you are using a custom billing provider or API). The dropdowns will retrieve the necessary data from the products and plans you’ve created in the billing provider you have configured to work with Moesif.
Setting up a Usage Multiplier/Tiering
If required, you can optionally multiply your usage by a ratio in your selected billing provider. Depending on the billing provider chosen, this can be done in a few ways. For instance, you may want to charge a set rate per 100 API calls. One of the most common ways to do this is to set up tiered pricing or volume pricing.
Depending on the billing provider you’re using, each offer their own mechanisms for implementing such a pricing model. Below are the corresponding links for common billing providers that work with Moesif:
One thing to note is that setting a usage multiplier/tiering may not be advantageous in all scenarios. For instance, when the multiplier is < 1.0 and volumes are small there may be large discrepancies created as time progresses. If tiers/multipliers are create large gaps for usage and volumes are low, customers may consider charges to be unfair. For example, if a usage multiplier of
.001
(every API call is 1/1000 of a chargeable unit) and usage is rounded up, if a customer uses 1001 API calls then they will be charged as if they had made up to 2000 API calls. Having well structured tiers and rules for rounding up/down can mitigate some of the issues that may arise.
Adding Billing Criteria
When a billing plan is created, you must establish what criteria you want to bill upon. This is done by setting the Filter and the Metric criteria.
An example would be to bill on all API Calls which return an “HTTP 200 - OK” response. The Filter and Metric criteria would look like so:
Adding a Custom/Scripted Field
If a field does not exist in your request or response that you’d like to bill upon, you can create the field as a Scripted Field. A Scripted Field has the follow capabilities and limitations:
- Write a script that retroactively creates a custom field using other fields, formulas, arithmetic, and more.
- Only numbers, booleans, and dates (treated as a number, milliseconds since epoch) are supported.
[field.path.field_name]
is a reference to a field- If field value does not exists, for numbers it defaults to 0, and for dates it will default to epoch. You can use
[field.path.field_name|50]
to set default value. - Most mathematical functions are supported and if, else, then, end are supported. (detailed docs coming soon).
- Only expression are supported, no other variables or statements are supported.
- Scripted fields with body fields may take several minutes to query.
To add a Scripted Field, under the Metrics section on the Add/Update Billing Meter screen, select Custom Metric.
Once Custom Metric is selected, in the Field selector, select the Scripted Field option.
In the modal that appears, you can input your Scripted Field expression. To add a field from Moesif into the expression, you can select it from the Add a reference to or freely type into the expression field.
Once your expression is input, click the Set button to add the field as a metric.
Enabling and Disabling a Billing Plan
Enabling and disabling a billing plan can be done in 2 places. It can be done on the Metered Billing list screen by toggling the status.
It can also be done by going to any of your metered billing plans, turning the plan off, and clicking update save that status change.
Archiving a Billing Plan
To archive a billing plan, simply go to the main billing screen where all of your plans are listed. Click the kebab menu at the end of the entry and select Archive.
Once clicked, you’ll be prompted to confirm that you do want to archive the plan. By clicking Archive Billing Meter, the plan will then be archived.
By clicking Archive Billing Meter, the plan will then be archived.
Plans cannot be deleted due to audit reasons. Once a plan is archived you will be unable to re-enable the plan. If you are looking to simply just make the plan inaccessible for a temporary period, simply disable the plan instead of archiving it.
Cloning a Billing Plan
To clone a billing plan, simply go to the main billing screen where all of your plans are listed. Click the kebab menu at the end of the entry and select Clone.
Once clicked, the settings from the original billing plan will pre-populate the new billing meter screen (the same screen used to create a new billing plan).