Skip to main content
POST
/
meters
JavaScript
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});

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

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

Authorizations

Authorization
string
header
required

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

Body

application/json
aggregation
Meter 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
Meter Filter · object

Optional filter to apply to the meter

Example:
{
"clauses": [
{
"key": "user_id",
"operator": "equals",
"value": "user123"
},
{
"key": "amount",
"operator": "greater_than",
"value": 100
}
],
"conjunction": "and"
}

Response

Meter created successfully

aggregation
Meter 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
Meter Filter · object

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.

Example:
{
"clauses": [
{
"key": "user_id",
"operator": "equals",
"value": "user123"
},
{
"key": "amount",
"operator": "greater_than",
"value": 100
}
],
"conjunction": "and"
}