Documentation Index
Fetch the complete documentation index at: https://mintlify.com/polarsource/polar/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Meters define how to aggregate events into billable usage. They specify which events to count and how to calculate the quantity.
The Meter Object
Aggregation function: count, sum, avg, max, or unique_count
Property to aggregate (required for sum/avg/max)
Whether meter is archived
List Meters
curl -X GET "https://api.polar.sh/v1/meters" \
-H "Authorization: Bearer polar_pat_..."
Query Parameters
Get Meter
curl -X GET "https://api.polar.sh/v1/meters/{id}" \
-H "Authorization: Bearer polar_pat_..."
Path Parameters
Create Meter
curl -X POST "https://api.polar.sh/v1/meters" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "API Requests",
"slug": "api_requests",
"filter": {
"type": "and",
"clauses": [
{
"type": "property",
"property": "name",
"operator": "eq",
"value": "api_request"
}
]
},
"aggregation": "count",
"organization_id": "org_123"
}'
Request Body
URL-friendly slug (auto-generated if not provided)
Filter clause to match events
Filters use a clause-based structure:Property Filter:{
"type": "property",
"property": "name",
"operator": "eq",
"value": "api_request"
}
Operators: eq, ne, gt, gte, lt, lte, contains, inLogical Filters:{
"type": "and",
"clauses": [...]
}
Types: and, or, not
How to aggregate: count, sum, avg, max, unique_count
Event property to aggregate (required for sum/avg/max)
Organization ID (required unless using org token)
Update Meter
curl -X PATCH "https://api.polar.sh/v1/meters/{id}" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "API Requests (Updated)",
"is_archived": false
}'
Path Parameters
Request Body
Get Meter Quantities
curl -X GET "https://api.polar.sh/v1/meters/{id}/quantities" \
-H "Authorization: Bearer polar_pat_..."
Get aggregated quantities for a meter over time.
Path Parameters
Query Parameters
Time interval: hour, day, week, or month
Timezone for aggregation (e.g., America/New_York)
Delete Meter
curl -X DELETE "https://api.polar.sh/v1/meters/{id}" \
-H "Authorization: Bearer polar_pat_..."
Deleting a meter will affect any products using metered pricing based on this meter.
Examples
Count Events
curl -X POST "https://api.polar.sh/v1/meters" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "API Calls",
"slug": "api_calls",
"filter": {
"type": "property",
"property": "name",
"operator": "eq",
"value": "api_request"
},
"aggregation": "count",
"organization_id": "org_123"
}'
Sum Property Values
curl -X POST "https://api.polar.sh/v1/meters" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Data Transfer (GB)",
"slug": "data_transfer_gb",
"filter": {
"type": "property",
"property": "name",
"operator": "eq",
"value": "data_transfer"
},
"aggregation": "sum",
"aggregate_field": "bytes",
"organization_id": "org_123"
}'
Complex Filter
curl -X POST "https://api.polar.sh/v1/meters" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Premium API Calls",
"filter": {
"type": "and",
"clauses": [
{
"type": "property",
"property": "name",
"operator": "eq",
"value": "api_request"
},
{
"type": "property",
"property": "tier",
"operator": "eq",
"value": "premium"
}
]
},
"aggregation": "count",
"organization_id": "org_123"
}'