Introduction
APIs
- Authentication
- Customers
- Accounts
- Aliases
- Event Schemas
- Usage Meters
- AddOns
- Licenses
- Feature
- (Deprecated) Price Plans
- Price Plan V2
- Settings
- Price Experimentation
- Jobs
- Event Ingestion
- Entitlements
- Event Management
- Metrics
- Credits
- Invoices
- Payments
- Wallet
- InvoiceGroups
- Alerts
- Reports
List usage meters for event schema
Get a list of usage meters associated with an event schema
curl --request GET \
--url https://api.togai.com/usage_meters \
--header 'Authorization: Bearer <token>'
{
"data": [
{
"id": "01BX5ZZKBKACTAV9WEVG",
"name": "Rides",
"displayName": "Rides Usage",
"description": "Cab rides",
"type": "COUNTER",
"aggregation": "COUNT",
"status": "DRAFT",
"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",
"order": 1,
"computation": "1"
}
]
}
],
"nextToken": "eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==",
"context": {
"pageSize": 10
}
}
_sort
query paramupdated_at DESC
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Filter by status
ACTIVE
, INACTIVE
Filter by aggregations
COUNT
, SUM
"eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ=="
10
Response
Structure of usage meter
Identifier of the usage meter
20
Name of the usage meter
50
"rides-usage"
Display name of usage meter. This is an auto-generated field which contains billableName of usage meter. If billableName is not provided, name will be used as display name.
255
Type of usage meter
COUNTER
"COUNTER"
Aggregation to be applied on usage meter result
- COUNT - Counts number of events matching the usage meter
- SUM - Sums up results of computation of all events matching usage meter
COUNT
, SUM
Billable name of addon. Billable name takes precedence over name to display in invoice.
255
"Rides Usage"
255
"Meter to track cab rides"
Status of usage meter
DRAFT
, ACTIVE
, INACTIVE
, ARCHIVED
"DRAFT"
Computation to be applied on an event if it matches the matcher. In case of a COUNT aggregation type, computation should be passed as '1'
500
{
"*": [{ "var": "attributes.distance" }, 0.4]
}
The order in which multiple matched computations will get evaluated
Optional identifier describing the matcher and computation pair
50
Condition to be applied on event. Upon matching it the corresponding computation will be considered for usage_meter unit calculation. The result of the matcher needs to be truthy in order to be considered as a match.
1500
"{\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"
Structure of an event schema
Name of the event. Must be unique for an organization.
50
Version of event schema
x >= 1
1
Description of the event
255
Status of event schema
- DRAFT - Schema is in draft state
- ACTIVE - Schema is currently active
- INACTIVE - Schema is currently inactive
- ARCHIVED - Older version of event schema
DRAFT
, ACTIVE
, INACTIVE
, ARCHIVED
"DRAFT"
Structure of dimensions
Name of the event dimension
50
"city"
ATTRIBUTE
, DIMENSION
VALUE
, JSON_LOGIC
, JSON_LOGIC_FROM_DEPENDENCY
Template used to generate event id based on event payload
curl --request GET \
--url https://api.togai.com/usage_meters \
--header 'Authorization: Bearer <token>'
{
"data": [
{
"id": "01BX5ZZKBKACTAV9WEVG",
"name": "Rides",
"displayName": "Rides Usage",
"description": "Cab rides",
"type": "COUNTER",
"aggregation": "COUNT",
"status": "DRAFT",
"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",
"order": 1,
"computation": "1"
}
]
}
],
"nextToken": "eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==",
"context": {
"pageSize": 10
}
}