Introducing the Better Auth Chargebee plugin: Use it to handle subscriptions, billing, and auth seamlessly.
Chargebeechargebee API

Metered features

A metered feature object represents two things:

  • the feature whose entitlement is consumed based on measured usage.
  • the configuration that measures that usage.

Sample Metered featureJSON

API Index URL

https://[site].chargebee.com/api/v2/metered_features

Metered features attributes

id
required, string, max chars=50

A unique identifier for the metered feature. This is the same as feature.id.

name
optional, string, max chars=50

A case-sensitive name for the metered feature. For example: API Calls, Input Tokens.

description
optional, string, max chars=250

A brief description of the metered feature.

type
optional, enumerated string

The type of meter. Determines how usage is measured for the metered feature.

Enum Values
simple

Usage is computed from a SQL query over usage_event properties.

compound

Usage is computed from a mathematical formula combining other meters.

status
optional, enumerated string

The current status of the metered feature.

Enum Values
active

The metered feature is active and new entitlements and subscription entitlements can be created for it.

archived

No new entitlements and subscription entitlements can be created for the metered feature. However, any pre-existing entitlements and subscription entitlements remain effective.

deleted

The metered feature has been permanently deleted.

query
optional, string, max chars=500

The SQL query used to measure usage from usage_event properties. For example: SELECT SUM(api_calls) FROM events.

Constraint:

  • The properties referenced in the query are always one of column_definitions.column_name.
column_definitions

Definitions of the columns or properties referenced by the metered feature's query.

features

The feature associated with this metered feature. This array has only one element since any given metered feature is associated with only one feature.

Column definition attributes

column_name
required, string, max chars=100

Name of the column or property used in the query. For example, request_count or input_tokens.

data_type
required, enumerated string

Data type of the column or property.

Enum Values
number

The column or property holds a numeric value.

string

The column or property holds a string value.

Feature attributes

id
required, string, max chars=50

A unique and immutable identifier for the feature. This is the same as id.

name
required, string, max chars=50

A case-sensitive unique name for the feature.

description
optional, string, max chars=500

A brief description of the feature.

status
optional, enumerated string

The current status of the feature.

Enum Values
active

The feature is active. Any entitlements or subscription entitlements defined for the feature take effect immediately.

archived

No new entitlements or subscription entitlements can be created for the feature. However, any pre-existing entitlements and subscription entitlements remain effective.

draft

This value is not applicable for metered features.

type
optional, enumerated string

The type of feature. The value is always range.

Enum Values
switch

This value is not applicable for metered features.

custom

This value is not applicable for metered features.

quantity

This value is not applicable for metered features.

range

The feature is quantity based, with entitlement levels between 1 and unlimited.

unit
optional, string, max chars=50

Specifies the unit of measure. The value is expected in the singular form. It is pluralized automatically as needed. For example, for a feature such as API Calls, the unit can be request.

resource_version
optional, long

The version number of this resource. For every change made to the resource, resource_version is updated with a new timestamp in milliseconds.

updated_at
optional, timestamp(UTC) in seconds

When the feature was last updated.

created_at
required, timestamp(UTC) in seconds

When the feature was created.

metered
required, boolean

Indicates whether the feature is metered. The value is always true.

levels

An ordered list of entitlement levels available for the feature.