POST
/
meters
JavaScript
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: 'My Bearer Token',
});

const meter = await client.meters.create({
  aggregation: { type: 'count' },
  event_name: 'event_name',
  measurement_unit: 'measurement_unit',
  name: 'name',
});

console.log(meter.id);
{
  "aggregation": {
    "key": "<string>",
    "type": "count"
  },
  "business_id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "description": "<string>",
  "event_name": "<string>",
  "filter": null,
  "id": "<string>",
  "measurement_unit": "<string>",
  "name": "<string>",
  "updated_at": "2023-11-07T05:31:56Z"
}

Authorizations

Authorization
string
header
required

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

Body

application/json
aggregation
object
required

Aggregation configuration for the meter

event_name
string
required

Event name to track

measurement_unit
string
required

measurement unit

name
string
required

Name of the meter

description
string | null

Optional description of the meter

filter
object | null

Optional filter to apply to the meter

Examples:
{
"clauses": [
{
"key": "user_id",
"operator": "equals",
"value": "user123"
},
{
"key": "amount",
"operator": "greater_than",
"value": 100
}
],
"conjunction": "and"
}
{
"clauses": [
{
"key": "plan",
"operator": "equals",
"value": "premium"
},
{
"key": "plan",
"operator": "equals",
"value": "enterprise"
}
],
"conjunction": "or"
}
{
"clauses": [
{
"clauses": [
{
"key": "user_type",
"operator": "equals",
"value": "premium"
},
{
"key": "user_type",
"operator": "equals",
"value": "enterprise"
}
],
"conjunction": "or"
},
{
"key": "active",
"operator": "equals",
"value": true
}
],
"conjunction": "and"
}

Response

Meter created successfully

aggregation
object
required
business_id
string
required
created_at
string<date-time>
required
event_name
string
required
id
string
required
measurement_unit
string
required
name
string
required
updated_at
string<date-time>
required
description
string | null
filter
object | null

A filter structure that combines multiple conditions with logical conjunctions (AND/OR).

Supports up to 3 levels of nesting to create complex filter expressions. Each filter has a conjunction (and/or) and clauses that can be either direct conditions or nested filters.

Examples:
{
"clauses": [
{
"key": "user_id",
"operator": "equals",
"value": "user123"
},
{
"key": "amount",
"operator": "greater_than",
"value": 100
}
],
"conjunction": "and"
}
{
"clauses": [
{
"key": "plan",
"operator": "equals",
"value": "premium"
},
{
"key": "plan",
"operator": "equals",
"value": "enterprise"
}
],
"conjunction": "or"
}
{
"clauses": [
{
"clauses": [
{
"key": "user_type",
"operator": "equals",
"value": "premium"
},
{
"key": "user_type",
"operator": "equals",
"value": "enterprise"
}
],
"conjunction": "or"
},
{
"key": "active",
"operator": "equals",
"value": true
}
],
"conjunction": "and"
}