POST
/
usage_meters
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"
    }
  ]
}

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required

Name 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>
required

Type of usage meter

Available options:
COUNTER
aggregation
enum<string>
required

Aggregation to be applied on usage meter result

Available options:
COUNT,
SUM
computations
object[]
eventSchemaName
string

Event Schema Identifier

Response

201 - application/json
id
string
required

Identifier of the usage meter

name
string
required

Name of the usage meter

billableName
string

Billable name of addon. Billable name takes precedence over name to display in invoice.

displayName
string
required

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.

description
string
type
enum<string>
required

Type of usage meter

Available options:
COUNTER
status
enum<string>

Status of usage meter

Available options:
DRAFT,
ACTIVE,
INACTIVE,
ARCHIVED
aggregation
enum<string>
required

Aggregation to be applied on usage meter result

Available options:
COUNT,
SUM
computations
object[]
createdAt
string
lastActivatedAt
string
updatedAt
string