Skip to main content
POST
/
meters
JavaScript
import Limitry from '@limitry/sdk';

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

const meter = await client.meters.create({
  aggregation: 'sum',
  field: 'x',
  name: 'x',
});

console.log(meter.id);
{
  "id": "mtr_abc123",
  "projectId": "proj_xyz",
  "name": "GPT-4 Tokens",
  "description": "Total tokens for GPT-4 calls",
  "aggregation": "sum",
  "field": "values.total_tokens",
  "eventFilter": {
    "dimensions": {
      "model": "gpt-4"
    }
  },
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Authorizations

Authorization
string
header
required

API Key or Personal Access Token (PAT). When using PAT, include X-Project header.

Body

application/json
name
string
required

Human-readable name

Minimum string length: 1
aggregation
enum<string>
required

Aggregation type

Available options:
sum,
count,
max,
latest
field
string
required

Field to aggregate

Minimum string length: 1
description
string

Description

eventFilter
object

Filter for matching events

Response

Meter created

id
string
required

Unique identifier for the meter

projectId
string | null
required

Project ID (null for global defaults)

name
string
required

Human-readable name

description
string | null
required

Description of what this meter measures

aggregation
string
required

Aggregation type (sum, count, max, latest)

field
string
required

Field to aggregate (e.g., "values.total_tokens", "*" for count)

eventFilter
object
required

Filter for matching events

createdAt
string<date-time>
required

Created timestamp

updatedAt
string<date-time>
required

Updated timestamp