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
- You need a role with the Can Create Usage Event, Can Read Usage Event, Can Create Billable Metric, and Can Read Billable Metric permissions. See Permissions: usage events and Permissions: billable metrics.
- You need an API key of the organization. See API keys.
- A customer with the external ID
acme-corpmust exist.
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 fieldscustomer_id and timestamp say whose calls they are and when they happened.
- Go to Usage > Usage Events.
- Click ADD USAGE EVENT. The Add Usage Event screen opens.
- In Usage Event Name, enter
API calls. API Slug Endpoint showsapi_calls, because Follow the usage event name is selected. - If the screen shows Enable S3 ingestion for this usage event, leave it off.
- Under Your Data Schema, click + ADD NEW DATA FIELD.
- In Data field, enter
calls. - In Data type, select Int64.
- 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 fieldcustomer_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.
- In Usage Events, click API calls. The screen of the usage-event collection opens.
- Next to UPLOAD CSV, click the arrow, and then click Add a single event. The Add New Event panel opens.
- In Customer ID, enter
acme-corp. - Under Timestamp, in Date, select October 5, 2026.
- In Time, enter
09:00:00. - In calls, enter
500. - 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.-
Next to Sample Request, click View. The Sample Request window shows a
curlrequest tohttps://api.zenskar.com/usage/api_calls. - Click the copy icon. Paste the request in a terminal.
-
Replace
<your-api-key>with your API key. -
Replace the text after
--data-rawwith the following usage event: - Run the request. Zenskar stores the usage event.
- 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 thecalls values of the usage events.
- Go to Usage > Billable Metrics.
- Click ADD NEW BILLABLE METRIC. The Add New Billable Metric screen opens with VISUAL BUILDER selected.
- Under Select tables & filters, in Table Name, select
api_callsunder Usage Event. Click NEXT. - Under Map customer, keep
customer_idin Your customer column and external_id in Zenskar customer column. Click NEXT. - Under Set date field, keep
timestampin Column. Click NEXT. - 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.- Under Query preview, in Search By Customer Name, External ID, select Acme Corp.
- In Billing Period, select October 1, 2026, as the first day and October 31, 2026, as the last day.
- Click RUN QUERY.
1200 under quantity. The test usage event reports 500 calls. The usage event from the API reports 700 calls.
Save the billable metric
- Click CREATE BILLABLE METRIC. The Choose Billable Metric Name window opens.
- Enter
API calls. - Click CREATE BILLABLE METRIC.
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.