- get - Get Metrics
- limits - Get Metrics Limits
- listDashboards - List Metric Dashboards
- createDashboard - Create Metric Dashboard
- getDashboard - Get Metric Dashboard
- deleteDashboard - Delete Metric Dashboard
- updateDashboard - Update Metric Dashboard
Get metrics about your orders and subscriptions.
Currency values are output in cents.
Scopes: metrics:read
declare(strict_types=1);
require 'vendor/autoload.php';
use Brick\DateTime\LocalDate;
use Polar;
use Polar\Models\Components;
use Polar\Models\Operations;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Operations\MetricsGetRequest(
startDate: LocalDate::parse('2025-03-14'),
endDate: LocalDate::parse('2025-03-18'),
interval: Components\TimeInterval::Hour,
organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);
$response = $sdk->metrics->get(
request: $request
);
if ($response->metricsResponse !== null) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
$request |
Operations\MetricsGetRequest | ✔️ | The request object to use for the request. |
?Operations\MetricsGetResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
Get the interval limits for the metrics endpoint.
Scopes: metrics:read
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->metrics->limits(
);
if ($response->metricsLimits !== null) {
// handle response
}?Operations\MetricsLimitsResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\APIException | 4XX, 5XX | */* |
List user-defined metric dashboards.
Scopes: metrics:read
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->metrics->listDashboards(
organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737'
);
if ($response->responseMetricsListDashboards !== null) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId |
string|array|null | ➖ | Filter by organization ID. |
?Operations\MetricsListDashboardsResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
Create a user-defined metric dashboard.
Scopes: metrics:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = new Components\MetricDashboardCreate(
name: '<value>',
organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);
$response = $sdk->metrics->createDashboard(
request: $request
);
if ($response->metricDashboardSchema !== null) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
$request |
Components\MetricDashboardCreate | ✔️ | The request object to use for the request. |
?Operations\MetricsCreateDashboardResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
Get a user-defined metric dashboard by ID.
Scopes: metrics:read
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->metrics->getDashboard(
id: '<value>'
);
if ($response->metricDashboardSchema !== null) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | ✔️ | The metric dashboard ID. |
?Operations\MetricsGetDashboardResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
Delete a user-defined metric dashboard.
Scopes: metrics:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->metrics->deleteDashboard(
id: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | ✔️ | The metric dashboard ID. |
?Operations\MetricsDeleteDashboardResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |
Update a user-defined metric dashboard.
Scopes: metrics:write
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$sdk = Polar\Polar::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$metricDashboardUpdate = new Components\MetricDashboardUpdate();
$response = $sdk->metrics->updateDashboard(
id: '<value>',
metricDashboardUpdate: $metricDashboardUpdate
);
if ($response->metricDashboardSchema !== null) {
// handle response
}| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | ✔️ | The metric dashboard ID. |
metricDashboardUpdate |
Components\MetricDashboardUpdate | ✔️ | N/A |
?Operations\MetricsUpdateDashboardResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| Errors\HTTPValidationError | 422 | application/json |
| Errors\APIException | 4XX, 5XX | */* |