Customer Meters
Get Customer Meter
Get a customer meter by ID.
Scopes: customer_meters:read
GET
/
v1
/
customer-meters
/
{id}
Go (SDK)
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
"github.com/polarsource/polar-go/models/components"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.CustomerMeters.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerMeter != nil {
switch res.CustomerMeter.Customer.Type {
case components.CustomerUnionTypeIndividual:
// res.CustomerMeter.Customer.CustomerIndividual is populated
case components.CustomerUnionTypeTeam:
// res.CustomerMeter.Customer.CustomerTeam is populated
}
}
}from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.customer_meters.get(id="<value>")
# Handle response
print(res)import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.customerMeters.get({
id: "<value>",
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customerMeters->get(
id: '<value>'
);
if ($response->customerMeter !== null) {
// handle response
}curl --request GET \
--url https://api.polar.sh/v1/customer-meters/{id} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.polar.sh/v1/customer-meters/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.get("https://api.polar.sh/v1/customer-meters/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/customer-meters/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"meter_id": "<string>",
"consumed_units": 123,
"credited_units": 123,
"balance": 123,
"customer": {
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"metadata": {},
"email": "<string>",
"email_verified": true,
"type": "<string>",
"name": "John Doe",
"billing_name": "John Doe",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>"
},
"tax_id": {
"[0]": "<string>"
},
"organization_id": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"avatar_url": "<string>",
"external_id": "usr_1337",
"locale": "<string>",
"default_payment_method_id": "<string>"
},
"meter": {
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"filter": {
"clauses": [
{
"property": "<string>",
"value": "<string>"
}
]
},
"aggregation": {
"func": "count"
},
"organization_id": "<string>",
"custom_label": "<string>",
"custom_multiplier": 123,
"archived_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
You can generate an Organization Access Token from your organization's settings.
Path Parameters
The customer meter ID.
Response
Successful Response
An active customer meter, with current consumed and credited units.
The ID of the object.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the customer.
Example:
"992fae2a-2a17-4b7a-8d9e-e287cf90131b"
The ID of the meter.
Example:
"d498a884-e2cd-4d3e-8002-f536468a8b22"
The number of consumed units.
Example:
25
The number of credited units.
Example:
100
The balance of the meter, i.e. the difference between credited and consumed units.
Example:
75
The customer associated with this meter.
- CustomerIndividual
- CustomerTeam
Show child attributes
Show child attributes
The meter associated with this customer.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Go (SDK)
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
"github.com/polarsource/polar-go/models/components"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.CustomerMeters.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerMeter != nil {
switch res.CustomerMeter.Customer.Type {
case components.CustomerUnionTypeIndividual:
// res.CustomerMeter.Customer.CustomerIndividual is populated
case components.CustomerUnionTypeTeam:
// res.CustomerMeter.Customer.CustomerTeam is populated
}
}
}from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.customer_meters.get(id="<value>")
# Handle response
print(res)import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.customerMeters.get({
id: "<value>",
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->customerMeters->get(
id: '<value>'
);
if ($response->customerMeter !== null) {
// handle response
}curl --request GET \
--url https://api.polar.sh/v1/customer-meters/{id} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.polar.sh/v1/customer-meters/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.get("https://api.polar.sh/v1/customer-meters/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polar.sh/v1/customer-meters/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"meter_id": "<string>",
"consumed_units": 123,
"credited_units": 123,
"balance": 123,
"customer": {
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"metadata": {},
"email": "<string>",
"email_verified": true,
"type": "<string>",
"name": "John Doe",
"billing_name": "John Doe",
"billing_address": {
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"city": "<string>",
"state": "<string>"
},
"tax_id": {
"[0]": "<string>"
},
"organization_id": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"avatar_url": "<string>",
"external_id": "usr_1337",
"locale": "<string>",
"default_payment_method_id": "<string>"
},
"meter": {
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"filter": {
"clauses": [
{
"property": "<string>",
"value": "<string>"
}
]
},
"aggregation": {
"func": "count"
},
"organization_id": "<string>",
"custom_label": "<string>",
"custom_multiplier": 123,
"archived_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}
