Metrics

Create a new metric

post/metrics

Request

Request body

namestring

Descriptive name of the metric that represents a pricing component of your application. This is primarily used for display purposes in the user interface.

codestring

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'METERED' | 'RECURRING'

Type of metric, either 'metered' for usage-based or 'recurring' for fixed periodic charges.

descriptionstring

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'COUNT' | 'SUM' | 'MAX' | 'COUNT_DISTINCT' | 'LATEST' nullable

Aggregation type for the metric

aggregation_fieldstring

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.

Example request

{
  "type": "METERED",
  "aggregation_type": "SUM"
}

Response

Metric created successfully

namestring required

Descriptive name of the metric that represents a pricing component of your application. This is primarily used for display purposes in the user interface.

codestring required

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'METERED' | 'RECURRING'

Type of metric, either 'metered' for usage-based or 'recurring' for fixed periodic charges.

descriptionstring

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'COUNT' | 'SUM' | 'MAX' | 'COUNT_DISTINCT' | 'LATEST' nullable required

Aggregation type for the metric

aggregation_fieldstring

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.

idstring required

Unique identifier of the metric, automatically generated by the system upon creation. This ID is used internally to track the metric and cannot be modified.

created_atstring date-time required

Date and time in ISO 8601 format.

updated_atstring date-time

Date and time in ISO 8601 format.

Example response

{
  "type": "METERED",
  "aggregation_type": "SUM",
  "created_at": "2023-10-01T12:00:00Z",
  "updated_at": "2023-10-01T12:00:00Z"
}

Changes

No recorded changes to this operation across all 1 revision of this API.