Skip to main content
PATCH
/
v1
/
meters
/
{id}
Go (SDK)
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Meters.Update(ctx, "<value>", components.MeterUpdate{})
    if err != nil {
        log.Fatal(err)
    }
    if res.Meter != nil {
        switch res.Meter.Aggregation.Type {
            case components.MeterAggregationTypeAvg:
                // res.Meter.Aggregation.PropertyAggregation is populated
            case components.MeterAggregationTypeCount:
                // res.Meter.Aggregation.CountAggregation is populated
            case components.MeterAggregationTypeMax:
                // res.Meter.Aggregation.PropertyAggregation is populated
            case components.MeterAggregationTypeMin:
                // res.Meter.Aggregation.PropertyAggregation is populated
            case components.MeterAggregationTypeSum:
                // res.Meter.Aggregation.PropertyAggregation is populated
            case components.MeterAggregationTypeUnique:
                // res.Meter.Aggregation.UniqueAggregation is populated
        }

    }
}
{
  "metadata": {},
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "id": "<string>",
  "name": "<string>",
  "unit": "scalar",
  "filter": {
    "conjunction": "and",
    "clauses": [
      {
        "property": "<string>",
        "operator": "eq",
        "value": "<string>"
      }
    ]
  },
  "aggregation": {
    "func": "count"
  },
  "organization_id": "<string>",
  "custom_label": "<string>",
  "custom_multiplier": 123,
  "archived_at": "2023-11-07T05:31:56Z"
}

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Path Parameters

id
string<uuid4>
required

The meter ID.

Body

application/json
metadata
Metadata · object

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

name
string | null

The name of the meter. Will be shown on customer's invoices and usage.

Minimum string length: 3
unit
enum<string> | null

The unit of the meter.

Available options:
scalar,
token,
custom
custom_label
string | null

The label for the custom unit. Required when unit is 'custom'.

custom_multiplier
integer | null

The multiplier to convert from base unit to display scale. Required when unit is 'custom'.

Required range: x > 0
filter
Filter · object

The filter to apply on events that'll be used to calculate the meter.

aggregation
CountAggregation · object

The aggregation to apply on the filtered events to calculate the meter.

is_archived
boolean | null

Whether the meter is archived. Archived meters are no longer used for billing.

Response

Meter updated.

metadata
object
required
created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

id
string<uuid4>
required

The ID of the object.

name
string
required

The name of the meter. Will be shown on customer's invoices and usage.

unit
enum<string>
required

The unit of the meter.

Available options:
scalar,
token,
custom
filter
Filter · object
required

The filter to apply on events that'll be used to calculate the meter.

aggregation
CountAggregation · object
required

The aggregation to apply on the filtered events to calculate the meter.

organization_id
string<uuid4>
required

The ID of the organization owning the meter.

custom_label
string | null

The label for the custom unit.

custom_multiplier
integer | null

The multiplier to convert from base unit to display scale.

archived_at
string<date-time> | null

Whether the meter is archived and the time it was archived.