Usage Meters
Create an usage meter
Create an usage meter and associate with an event schema
POST
/
usage_meters
curl --request POST \
--url https://api.togai.com/usage_meters \
--header 'Authorization: <authorization>' \
--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
]
}
}
]
}'
{
"id": "um.1zlQTBWlkeO.lB7fh",
"name": "Rides",
"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",
"computation": "1"
}
]
}
Authorizations
Authorization
string
headerrequiredBearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
name
string
requiredName of the usage meter. Must be unique for an organization.
billableName
string
Billable name of usage meter. Billable name takes precedence over name to display in invoice.
description
string
Description of the usage meter
type
enum<string>
requiredType of usage meter
Available options:
COUNTER
aggregation
enum<string>
requiredAggregation to be applied on usage meter result
Available options:
COUNT
, SUM
computations
object[]
eventSchemaName
string
requiredEvent Schema Identifier
Response
201 - application/json
id
string
requiredIdentifier of the usage meter
name
string
requiredName of the usage meter
billableName
string
Billable name of addon. Billable name takes precedence over name to display in invoice.
description
string
type
enum<string>
requiredType of usage meter
Available options:
COUNTER
status
enum<string>
Status of usage meter
Available options:
DRAFT
, ACTIVE
, INACTIVE
, ARCHIVED
aggregation
enum<string>
requiredAggregation to be applied on usage meter result
Available options:
COUNT
, SUM
computations
object[]
createdAt
string
lastActivatedAt
string
updatedAt
string
curl --request POST \
--url https://api.togai.com/usage_meters \
--header 'Authorization: <authorization>' \
--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
]
}
}
]
}'
{
"id": "um.1zlQTBWlkeO.lB7fh",
"name": "Rides",
"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",
"computation": "1"
}
]
}