Skip to main content

Usage: end-to-end walkthrough

Your company sells access to a messaging API. It charges each customer for the API calls that the customer makes. Your API reports the calls of each customer in batches. Each usage event holds the number of calls of one customer in one minute. This walkthrough follows your billing team as it meters the usage of one customer, Acme Corp, from the first usage event to the number of a billable metric. It puts usage-event collections, data schemas, data fields, the API slug endpoint, billable metrics, the visual builder, and calculation types into practice. It uses these settings: The company, the customer, and the numbers are fictional.

Prerequisites

Create the usage-event collection

The usage events of API calls need a usage-event collection. Its data schema needs one data field for the number of calls. The root fields customer_id and timestamp say whose calls they are and when they happened.
  1. Go to Usage > Usage Events.
  2. Click ADD USAGE EVENT. The Add Usage Event screen opens.
  3. In Usage Event Name, enter API calls. API Slug Endpoint shows api_calls, because Follow the usage event name is selected.
  4. If the screen shows Enable S3 ingestion for this usage event, leave it off.
  5. Under Your Data Schema, click + ADD NEW DATA FIELD.
  6. In Data field, enter calls.
  7. In Data type, select Int64.
  8. Click ADD USAGE EVENT. The Usage Events list opens and shows API calls.

Send a test usage event from the dashboard

Before your engineers connect the API, the billing team checks the usage-event collection with a single usage event. It reports 500 calls. Customer ID holds the root field customer_id. The billable metric of this walkthrough matches it to the external ID of a customer, or to the ID that Zenskar assigns to the customer. The billing team enters acme-corp, the external ID of Acme Corp.
  1. In Usage Events, click API calls. The screen of the usage-event collection opens.
  2. Next to UPLOAD CSV, click the arrow, and then click Add a single event. The Add New Event panel opens.
  3. In Customer ID, enter acme-corp.
  4. Under Timestamp, in Date, select October 5, 2026.
  5. In Time, enter 09:00:00.
  6. In calls, enter 500.
  7. Click ADD EVENT. The panel closes.

Send a usage event through the API

In production, your API sends each batch to the API slug endpoint of the usage-event collection. Your engineers start from the sample request on the screen of the usage-event collection. This usage event reports 700 calls.
  1. Next to Sample Request, click View. The Sample Request window shows a curl request to https://api.zenskar.com/usage/api_calls.
  2. Click the copy icon. Paste the request in a terminal.
  3. Replace <your-api-key> with your API key.
  4. Replace the text after --data-raw with the following usage event:
  5. Run the request. Zenskar stores the usage event.
  6. On the screen of the usage-event collection, click REFRESH TABLE. The Events Table shows both usage events.

Build the billable metric

The usage events hold the calls of each minute. A price needs one number for each customer and month. The billing team therefore builds a billable metric in the visual builder. Its calculation type is sum: it adds up the calls values of the usage events.
  1. Go to Usage > Billable Metrics.
  2. Click ADD NEW BILLABLE METRIC. The Add New Billable Metric screen opens with VISUAL BUILDER selected.
  3. Under Select tables & filters, in Table Name, select api_calls under Usage Event. Click NEXT.
  4. Under Map customer, keep customer_id in Your customer column and external_id in Zenskar customer column. Click NEXT.
  5. Under Set date field, keep timestamp in Column. Click NEXT.
  6. Under Set Billable Metric over, in Select calculation type, select SUM. In Select column to calculate over, select calls.

Preview the billable metric

Before saving, the billing team checks the number for Acme Corp in October.
  1. Under Query preview, in Search By Customer Name, External ID, select Acme Corp.
  2. In Billing Period, select October 1, 2026, as the first day and October 31, 2026, as the last day.
  3. Click RUN QUERY.
The table shows 1200 under quantity. The test usage event reports 500 calls. The usage event from the API reports 700 calls.

Save the billable metric

  1. Click CREATE BILLABLE METRIC. The Choose Billable Metric Name window opens.
  2. Enter API calls.
  3. Click CREATE BILLABLE METRIC.
The Billable Metrics list opens and shows API calls.

What comes next

At real volume, the usage events of Acme Corp report 12,000 calls in October. The billable metric gives 12,000.

Point-in-time products: end-to-end walkthrough

This walkthrough creates the product and the pricing preset that price these calls.