On this page
No Headings
Use the /v1/oauth2/token endpoint to obtain an access token and pass it as a Bearer token in the Authorization header.
Client CredentialsToken URLhttps://api-m.sandbox.paypal.com/v1/oauth2/tokenInheaderScopes
readwriteThe code of the metric
application/json
TypeScript Definitions
Use the request body type in TypeScript.
application/json
application/json
application/json
application/json
application/json
application/json
curl -X PUT "https://api-m.sandbox.paypal.com/v1/commerce/billing/metrics/Metric-Code-123" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Metric", "description": "This metric has been updated", "code": "updated_metric_code", "type": "METERED", "aggregation_type": "SUM", "field_filters": [ { "key": "region", "values": [ "us-east-1", "us-west-1" ] } ] }'{
"id": "bm_01H2XT1G7N8E2JHJKBVPDS0TQD",
"name": "API Requests",
"code": "api_requests",
"type": "METERED",
"description": "Measures the total number of API requests made",
"aggregation_type": "COUNT",
"field_filters": [
{
"key": "region",
"values": [
"us-east-1",
"us-west-1",
"eu-west-1"
]
}
],
"created_at": "2023-05-10T14:32:18Z"
}{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "dc99e3955cdd8",
"details": [
{
"field": "/email",
"value": "abc",
"location": "body",
"issue": "INVALID_PARAMETER_VALUE",
"description": "The value of a field does not conform to the expected format."
}
]
}{
"name": "NOT_AUTHORIZED",
"message": "Authorization failed due to insufficient permissions.",
"debug_id": "565f78f101498",
"details": [
{
"issue": "PERMISSION_DENIED",
"description": "You do not have permission to access or perform operations on this resource."
}
]
}{
"name": "string",
"debug_id": "string",
"message": "string",
"details": [
{
"field": "string",
"value": "string",
"location": "string",
"issue": "string",
"description": "string"
}
]
}{
"name": "UNPROCESSABLE_ENTITY",
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "90957fca61718",
"details": [
{
"field": "/email",
"value": "sdfwdj@sdfs.com",
"location": "body",
"issue": "UNSUPPORTED_EMAIL",
"description": "The email provided is not supported."
}
]
}{
"name": "INTERNAL_SERVER_ERROR",
"message": "An internal server error has occurred.",
"debug_id": "90957fca61718"
}Descriptive name of the metric that represents a pricing component of your application. This is primarily used for display purposes in the user interface.
Unique code used to identify the metric within your system. This code is used in API requests to associate events with the correct metric and must be unique across all metrics. Once created, this code cannot be changed.
Type of metric, either 'metered' for usage-based or 'recurring' for fixed periodic charges.
"RECURRING""METERED" | "RECURRING"Optional detailed description of the metric that provides additional context about what the metric measures and how it's used. This information is for internal use and helps document the purpose of the metric.
Aggregation type for the metric
"COUNT" | "SUM" | "MAX" | "COUNT_DISTINCT" | "LATEST"Property name within the event payload that will be used for aggregating usage data. This field specifies which value from the event should be used for calculations. It is required for aggregation types like 'SUM', 'MAX', and other types that operate on values, but not required for 'COUNT' aggregation.