Meters
Represents billing meters used to track and aggregate customer usage, including aggregation settings, event mapping, and status details.
Table-Specific Information
SELECT
The component uses the Stripe API to filter the results by the following columns and operators while the rest of the filter is executed client-side within the component.
| Column | Supported Operators |
| Id | = |
| Status | = |
You can select:
- A meter by specifying its Id:
SELECT * FROM Meters WHERE Id = 'mtr_test_61SVnB524GIp5I1qJ41SI44T5qOYG17Q'
- A meter by specifying its status:
SELECT * FROM Meters WHERE Status = 'active'
INSERT
To create a new meter, the DisplayName, EventName, and DefaultAggregationFormula fields are required. To insert using these columns:
INSERT INTO Meters (DefaultAggregationFormula, DisplayName, EventName) VALUES ('last', 'displayName', 'event_name')
A new meter can be created with custom customer mapping and value setting event payload keys.
INSERT INTO Meters (DefaultAggregationFormula, DisplayName, EventName, CustomerMappingEventPayloadKey, CustomerMappingType, ValueSettingsEventPayloadKey) VALUES ('count', 'insert4', 'insert4D', 'star', 'by_id', 'platinum')
The values inserted in the event payload keys must be used to execute the CreateBillingMeterEvent stored procedure.
UPDATE
To update an meter, specify an Id. Only DisplayName can be updated.
UPDATE Meters SET DisplayName = 'UpdatedName' WHERE Id = 'mtr_test_61SW9E6CAVwliacFb41SI44T5qOYGXZ2'
Columns
| Name | Type | ReadOnly | References | Description |
| Id [KEY] | String | True |
The unique identifier for the meter object. | |
| Object | String | True |
String representing the object's type. Objects of the same type share the same value. | |
| Created | Datetime | True |
Time at which the object was created. Measured in seconds since the Unix epoch. | |
| CustomerMappingEventPayloadKey | String | False |
The key in the meter event payload to use for mapping the event to a customer. | |
| CustomerMappingType | String | False |
The method for mapping a meter event to a customer. The allowed values are by_id. | |
| DefaultAggregationFormula | String | False |
Specifies how events are aggregated. The allowed values are count, last, sum. | |
| DisplayName | String | False |
The meter's name. | |
| EventName | String | False |
The name of the meter event to record usage for. Corresponds with the event_name field on meter events. | |
| EventTimeWindow | String | False |
The time window to pre-aggregate meter events for, if any. The allowed values are day, hour. | |
| Livemode | Boolean | True |
Has the value true if the object exists in live mode or the value false if the object exists in test mode. | |
| Status | String | True |
The meter's status. The allowed values are active, inactive. | |
| StatusTransitionsDeactivatedAt | Datetime | True |
The time the meter was deactivated, if any. Measured in seconds since Unix epoch. | |
| Updated | Datetime | True |
Time at which the object was last updated. Measured in seconds since the Unix epoch. | |
| ValueSettingsEventPayloadKey | String | False |
The key in the meter event payload to use as the value for this meter. |