Creating Billable Items

This article talks about billable items and how to create them using APIs

Updated over a week ago

Billable items are the building blocks of your pricing model. There are three types of billable items on Togai :

USAGE METERS

Usage meters aggregate the event streams into usage based metrics. You can use aggregation functions such as SUM and COUNT to arrive at the usage based billable item. Here's the API to create a usage meter. Here's what a request payload would look like :

curl --request POST \
--url https://api.togai.com/usage_meters \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"name": "Rides",
"description": "Cab rides",
"type": "COUNTER",
"aggregation": "SUM",
"eventSchemaName": "evfhr123d",
"computations": [
{
"matcher": "{\n \"and\": [\n {\"in\": [{\"var\": \"dimension.city\"}, \"chennai\", \"mumbai\"]},\n \"or\": [\n {\">\": [{\"var\": \"attribute.distance\"}, 100]},\n {\"<\": [{\"var\": \"attribute.distance\"}, 20]}\n ]\n ]\n}\n",
"computation": {
"*": [
{
"var": "attributes.distance"
},
0.4
]
}
}
]
}
'

Points to note :

  1. Only one event schema can be associated to a usage meter.

  2. Computation should be set as 1 for the COUNT usage meter type.

Once the usage meter is created, they have to be activated using the API to activate the usage meter. Here's what a request payload would look like :

curl --request POST \
--url https://api.togai.com/usage_meters/usage_meter_id/activate \
--header 'accept: application/json'

ADD ONS

Add ons are flat components of the pricing. An add-on need not be attached to an event schema because it does not have a usage based component to it.
โ€‹

There are two types of add-ons:

  1. Fixed Fee - Subscription fees, implementation fees, fee for priority support etc

  2. Licenses - Users, seats etc

Here's the API to create an add - on. Here's what the request payload to create a license add on would look like :

curl --request POST \
--url https://api.togai.com/addons \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"type":"LICENSE"}'

FEATURES

Features are components of your pricing that need to be gated or limited based on usage.

Here's the API to create a feature. Here's what a sample request payload would look like :

curl --request POST \
--url https://api.togai.com/features \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"name": "DiscountCredits",
"description": "Discount Credits feature",
"schemaAssocitions": [
"event_schema1",
"event_schema2"
]
}
'

Now that you've created the building blocks of your pricing model, let's go ahead and assemble these blocks to build your pricing model.

Did this answer your question?