Meters
A Meter defines how to aggregate usage events over a billing period to determine how much a customer should be billed.
POST /api/v1/meters/createGET /api/v1/meters/{id}POST /api/v1/meters/{id}/updatePOST /api/v1/meters/{id}/archivePOST /api/v1/meters/{id}/restoreGET /api/v1/metersGET /api/v1/meters/{id}/summaries
Create a meter
POST /api/v1/meters/create
Create a new Meter object.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Unique request ID specified by the merchant.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request POST \> --url 'https://api-demo.airwallex.com/api/v1/meters/create' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json' \> --data '{> "aggregation_method": "SUM",> "aggregation_property": "quantity",> "description": "Tracks API requests made by customers",> "event_name": "api_call",> "metadata": {> "foo": "bar"> },> "name": "API Requests",> "request_id": "ee939540-3203-4a2c-9172-89a566485dd9">}'
1{2 "aggregation_method": "SUM",3 "aggregation_property": "quantity",4 "archived": false,5 "created_at": "2022-01-01T10:15:30+0000",6 "description": "Tracks API requests made by customers",7 "event_name": "api_call",8 "id": "mtr_1234567890abcdef",9 "metadata": {10 "foo": "bar"11 },12 "name": "API Requests",13 "updated_at": "2022-01-01T10:15:30+0000"14}
Retrieve a meter
GET /api/v1/meters/{id}
Retrieves the details of a Meter.
ID of the Meter object.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/meters/meter_id' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "aggregation_method": "SUM",3 "aggregation_property": "quantity",4 "archived": false,5 "created_at": "2022-01-01T10:15:30+0000",6 "description": "Tracks API requests made by customers",7 "event_name": "api_call",8 "id": "mtr_1234567890abcdef",9 "metadata": {10 "foo": "bar"11 },12 "name": "API Requests",13 "updated_at": "2022-01-01T10:15:30+0000"14}
Update a meter
POST /api/v1/meters/{id}/update
Update a meter.
ID of the Meter object.
Meter description. Used for internal classification and identification.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request POST \> --url 'https://api-demo.airwallex.com/api/v1/meters/meter_id/update' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json' \> --data '{> "description": "Updated description for tracking API requests made by customers",> "metadata": {> "foo": "bar"> },> "name": "Updated API Requests">}'
1{2 "aggregation_method": "SUM",3 "aggregation_property": "quantity",4 "archived": false,5 "created_at": "2022-01-01T10:15:30+0000",6 "description": "Tracks API requests made by customers",7 "event_name": "api_call",8 "id": "mtr_1234567890abcdef",9 "metadata": {10 "foo": "bar"11 },12 "name": "API Requests",13 "updated_at": "2022-01-01T10:15:30+0000"14}
Archive a meter
POST /api/v1/meters/{id}/archive
Archive a Meter. The meter will no longer be available to be linked to new Prices. It can be archived only when there is no linked active price.
ID of the Meter object.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request POST \> --url 'https://api-demo.airwallex.com/api/v1/meters/meter_id/archive' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "aggregation_method": "SUM",3 "aggregation_property": "quantity",4 "archived": false,5 "created_at": "2022-01-01T10:15:30+0000",6 "description": "Tracks API requests made by customers",7 "event_name": "api_call",8 "id": "mtr_1234567890abcdef",9 "metadata": {10 "foo": "bar"11 },12 "name": "API Requests",13 "updated_at": "2022-01-01T10:15:30+0000"14}
Restore a meter
POST /api/v1/meters/{id}/restore
Restore a Meter. The meter will be available to be linked to new Prices.
ID of the Meter object.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request POST \> --url 'https://api-demo.airwallex.com/api/v1/meters/meter_id/restore' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "aggregation_method": "SUM",3 "aggregation_property": "quantity",4 "archived": false,5 "created_at": "2022-01-01T10:15:30+0000",6 "description": "Tracks API requests made by customers",7 "event_name": "api_call",8 "id": "mtr_1234567890abcdef",9 "metadata": {10 "foo": "bar"11 },12 "name": "API Requests",13 "updated_at": "2022-01-01T10:15:30+0000"14}
Get list of meters
GET /api/v1/meters
Retrieves a list of Meters based on the query parameters.
The meter's archived status, either true or false.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
Type of aggregation to perform.
Property within the event to aggregate.
The start time of created_at in ISO8601 format (inclusive).
The end time of created_at in ISO8601 format (exclusive).
A bookmark for use in pagination to retrieve either the next page or the previous page of results. You can fetch the value for this identifier from the response of the previous API call. To retrieve the next page of results, pass the value of page_after (if not null) from the response to a subsequent call. To retrieve the previous page of results, pass the value of page_before (if not null) from the response to a subsequent call.
Number of results per page. Defaults to 20.
Paged results.
Type of aggregation to perform, based on each event's properties value. One of
COUNT: count the number of events.LAST: the value of the last event.MAX: maximum of all event values.SUM: sum up the value of each event.UNIQUE: count the number of unique events.
The name of the property within the event to aggregate. Events will be ignored during aggregation if they are missing this property or if its value is invalid.
false if the Meter is available to be linked to new prices, true otherwise.
Time when this meter was created.
Meter description. Used for internal classification and identification.
The name of the Usage Event to record for. Corresponds with the event_name field on Usage Events.
ID of the Meter object.
A set of key-value pairs that you can attach to this object for storing additional information.
Meter name.
Time when this meter was last updated.
The page cursor used for searching after page.
The page cursor used for search before page.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/meters' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "items": [3 {4 "aggregation_method": "SUM",5 "aggregation_property": "quantity",6 "archived": false,7 "created_at": "2022-01-01T10:15:30+0000",8 "description": "Tracks API requests made by customers",9 "event_name": "api_call",10 "id": "mtr_1234567890abcdef",11 "metadata": {12 "foo": "bar"13 },14 "name": "API Requests",15 "updated_at": "2022-01-01T10:15:30+0000"16 }17 ],18 "page_after": "<string>",19 "page_before": "<string>"20}
Get summaries of a meter
GET /api/v1/meters/{id}/summaries
Calculates the result of a Meter for a customer for a given time period.
ID of the Meter object.
ID of the Billing Customer object.
The start date of Usage Events' happened_at in ISO8601 format (inclusive).
The end date of Usage Events' happened_at in ISO8601 format (exclusive).
The time window to group the usage summary by. If not specified, a single summary for the entire time range is returned. When specified, the response will contain a list of summaries, one for each time window in the range. Possible values are HOUR or DAY. For HOUR grouping, from_happened_at and to_happened_at must align with hour boundaries (e.g., 2025-03-15T14:00:00+0000). For DAY grouping, from_happened_at and to_happened_at must align with UTC day boundaries (e.g., 2025-03-15T00:00:00+0000). If not specified, from_happened_at and to_happened_at must align with minute boundaries e.g., 2025-03-15T14:01:00+0000). The duration must not exceed one year.
A bookmark for use in pagination to retrieve either the next page or the previous page of results. You can fetch the value for this identifier from the response of the previous API call. To retrieve the next page of results, pass the value of page_after (if not null) from the response to a subsequent call. To retrieve the previous page of results, pass the value of page_before (if not null) from the response to a subsequent call.
Number of summaries per page. Defaults to 20.
Paged results.
ID of the Billing Customer object.
The number of usage events that contributed to the value.
Start time of the summary period (inclusive).
ID of the Meter object.
End time of the summary period (exclusive).
The aggregated value based on the meter's aggregation type.
The page cursor used for searching after page.
The page cursor used for search before page.
| Error status | Description |
|---|---|
| 400 | Bad Request. Possible error codes: |
| 401 | Unauthorized. Possible error codes: |
| 404 | Not Found. Possible error codes: |
| 500 | Server Error. Possible error codes: |
$curl --request GET \> --url 'https://api-demo.airwallex.com/api/v1/meters/meter_id/summaries' \> --header 'Authorization: Bearer {{ACCESS_TOKEN}}' \> --header 'Content-Type: application/json'
1{2 "items": [3 {4 "billing_customer_id": "bcus_1234567890abcdef",5 "event_count": 100,6 "from_happened_at": "2022-01-01T00:00:00+0000",7 "meter_id": "mtr_1234567890abcdef",8 "to_happened_at": "2022-01-02T00:00:00+0000",9 "value": 150.7510 }11 ],12 "page_after": "<string>",13 "page_before": "<string>"14}