If your pricing model has a variable component based on usage for one or more products, you can express that in Sequence via usage events and usage metrics.

Usage events are basic units of product usage – for example: an API call, a transaction processed, a user session. Each usage event belongs to one of your customers and includes contextual information in the form of the event type and properties.

Usage metrics measure overall usage by aggregating multiple usage events – for example: the total number of API calls, transaction volume, active users. Metrics are scoped to a specific customer and time period, and can include filters and breakdowns based on event properties.

Sequence updates usage metrics in real time as customers use your product. At the end of each billing period, the total usage for each of your customers is combined with a price to calculate the corresponding charge on the invoice. To see how it all works together, see the examples, or jump right in with the quick start.

Quick start

1. Create a few usage events for a customer:

  • Head to the Usage > Events section in the dashboard and click “Submit test event”
  • Select a a customer to assign this event to, and pick the event timestamp to be sometime in the past, e.g. last month
  • Pick an event type, (e.g. “api_call”) and optionally add some event properties as key-value pairs
  • Repeat the last step a few times to generate a few test events. You will see them appear on the events table

2. Create a usage metric to aggregate the events:

  • From Usage > Metrics, click “Add new”
  • Give the metric a name (e.g. “API calls”) and optionally a description
  • Select the event type you defined in step 1 from the drop-down, and select “Count of usage values” as the aggregation type

3. Preview the usage metric calculation:

  • After adding the usage metric, select it from the Metrics table to enter the preview window
  • Select the customer the customer that you generated events for in step 1, and pick a time window to calculate the metric over
  • Click “Calculate”. The preview will show the number of usage events found for the given customer in the selected time window

4. Create a usage-based billing schedule:

  • From Billing > Schedules, click “Add new”
  • Select your customer, and add a new price to the schedule by clicking “Add prices > Create new”
  • Select “Linear pricing” as your pricing model
  • Give this product a name (e.g. “API usage”) and select the metric you created in step 2 as the “Usage metric”
  • Pick a unit price, which is the amount to be charged for each usage event
  • Select a start date in the past for the billing schedule, covering the period you generated events for. Click “Start schedule”

5. Generate usage-based invoices:

  • Navigate to Billing > Invoices to see the backdated invoices for the billing schedule you just created
  • Click on one of the invoices to see usage-based charges
  • 🎉