Skip to main content
POST
/
limits
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 limit = await client.limits.create({
  limitValue: 1,
  meterId: 'x',
  name: 'x',
  period: 'hour',
});

console.log(limit.id);
{
  "id": "lmt_abc123",
  "projectId": "proj_xyz",
  "name": "Daily Token Limit",
  "meterId": "mtr_total_tokens",
  "limitValue": 100000,
  "period": "day",
  "customerId": "cust_123",
  "dimensionFilters": {},
  "alertThresholds": null,
  "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 for the limit

Minimum string length: 1
meterId
string
required

ID of the meter this limit references

Minimum string length: 1
limitValue
integer
required

Limit value

Required range: x > 0
period
enum<string>
required

Time period for the limit. Boundaries are calculated from customer billingCycleStart.

Available options:
hour,
day,
week,
month,
annual,
all_time
customerId
string | null

Customer ID to scope the limit to

dimensionFilters
object

Key-value pairs to filter or scope the rule. Keys must be alphanumeric with underscores (max 64 chars). Values are strings (max 256 chars).

alertThresholds
integer[] | null

Alert thresholds as percentages

Required range: 1 <= x <= 100

Response

Limit created

id
string
required

Unique identifier for the limit

projectId
string
required

ID of the project that owns this limit

name
string
required

Human-readable name for the limit

meterId
string
required

ID of the meter this limit references

limitValue
number
required

Limit value

period
string
required

Time period for the limit (hour, day, week, month, annual, all_time). Period boundaries are calculated from the customer billingCycleStart.

dimensionFilters
object
required

Additional dimension filters for scoping

createdAt
string<date-time>
required

ISO 8601 timestamp when the limit was created

updatedAt
string<date-time>
required

ISO 8601 timestamp when the limit was last updated

customerId
string | null

Optional customer ID to scope the limit to

alertThresholds
integer[] | null

Alert thresholds as percentages (e.g., [80, 100])

Required range: 1 <= x <= 100