PATCH
/
usage_meters
/
{usage_meter_id}
curl --request PATCH \
  --url https://api.togai.com/usage_meters/{usage_meter_id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "billableName": "<string>",
  "description": "<string>",
  "eventSchemaName": "<string>",
  "type": "COUNTER",
  "aggregation": "COUNT",
  "computations": [
    {
      "id": "<string>",
      "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
        ]
      },
      "order": 123
    }
  ],
  "filters": [
    {
      "field": "<string>",
      "value": "<string>"
    }
  ]
}'
{
  "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
header
required

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

Path Parameters

usage_meter_id
string
required
Maximum length: 50
Example:

"um.1zYnCiM9Bpg.1zYn"

Body

application/json
Payload to create usage meter

Request to update usage meter

name
string

Name of usage meter.

Maximum length: 255
billableName
string

Billable name of usage meter. Billable name takes precedence over name to display in invoice.

Maximum length: 255
description
string

Description of the usage meter

Maximum length: 255
eventSchemaName
string

Event Schema Identifier

type
enum<string>

Type of usage meter

  • COUNTER - Count usage
Available options:
COUNTER
Example:

"COUNTER"

aggregation
enum<string>

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
Available options:
COUNT,
SUM
computations
object[]
filters
object[]

Filter entry with field and value

Response

200
application/json
Response for Create and Get usage event requests

Structure of usage meter

id
string
required

Identifier of the usage meter

Maximum length: 20
name
string
required

Name of the usage meter

Maximum length: 50
Example:

"rides-usage"

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.

Maximum length: 255
type
enum<string>
required

Type of usage meter

Available options:
COUNTER
Example:

"COUNTER"

aggregation
enum<string>
required

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
Available options:
COUNT,
SUM
billableName
string

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

Maximum length: 255
Example:

"Rides Usage"

description
string
Maximum length: 255
Example:

"Meter to track cab rides"

filters
object[]

Filter entry with field and value

status
enum<string>

Status of usage meter

Available options:
DRAFT,
ACTIVE,
INACTIVE,
ARCHIVED
Example:

"DRAFT"

computations
object[]
eventSchema
object

Structure of an event schema

createdAt
string
lastActivatedAt
string
updatedAt
string