curl --request POST \
--url https://api.togai.com/usage_meters \
--header 'Authorization: Bearer <token>' \
--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",
"displayName": "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",
"order": 1,
"computation": "1"
}
]
}
Create an usage meter and associate with an event schema
curl --request POST \
--url https://api.togai.com/usage_meters \
--header 'Authorization: Bearer <token>' \
--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",
"displayName": "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",
"order": 1,
"computation": "1"
}
]
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Payload to create usage meter
Request to create usage meter
Response for Create and Get usage event requests
Structure of usage meter