General
Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Events
- Meters
- Benefits
- Customer Meters
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Customer Events
- Billing Events
- Organization Events
OAuth 2.0 API
- Connect
- Clients
Meters
Create Meter
Create a meter.
Scopes: meters:write
POST
/
v1
/
meters
/
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.create({
name: "<value>",
filter: {
conjunction: "or",
clauses: [
{
property: "<value>",
operator: "ne",
value: "<value>",
},
],
},
aggregation: {
func: "sum",
property: "<value>",
},
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
// Handle the result
console.log(result);
}
run();
{
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"filter": {
"conjunction": "and",
"clauses": [
{
"property": "<string>",
"operator": "eq",
"value": "<string>"
}
]
},
"aggregation": {
"func": "count"
},
"organization_id": "<string>"
}
Authorizations
You can generate an Organization Access Token from your organization's settings.
Body
application/json
Response
201
application/json
Meter created.
The response is of type object
.
Was this page helpful?
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.create({
name: "<value>",
filter: {
conjunction: "or",
clauses: [
{
property: "<value>",
operator: "ne",
value: "<value>",
},
],
},
aggregation: {
func: "sum",
property: "<value>",
},
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
// Handle the result
console.log(result);
}
run();
{
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"filter": {
"conjunction": "and",
"clauses": [
{
"property": "<string>",
"operator": "eq",
"value": "<string>"
}
]
},
"aggregation": {
"func": "count"
},
"organization_id": "<string>"
}
Assistant
Responses are generated using AI and may contain mistakes.