Skip to main content
PUT
/
organizations
/
{orgId}
/
aggregations
/
{id}
Update Aggregation
curl --request PUT \
  --url https://api.m3ter.com/organizations/{orgId}/aggregations/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "rounding": "UP",
  "quantityPerUnit": 1,
  "unit": "<string>",
  "meterId": "<string>",
  "targetField": "<string>",
  "aggregation": "SUM",
  "version": 123,
  "customFields": "<unknown>",
  "code": "example_code",
  "accountingProductId": "<string>",
  "segmentedFields": [
    "<string>"
  ],
  "segments": [
    {}
  ],
  "defaultValue": 1,
  "customSql": "<string>"
}
'
{
  "id": "<string>",
  "version": 123,
  "customFields": {},
  "name": "<string>",
  "rounding": "UP",
  "quantityPerUnit": 123,
  "unit": "<string>",
  "code": "<string>",
  "segments": [
    {}
  ],
  "accountingProductId": "<string>",
  "meterId": "<string>",
  "targetField": "<string>",
  "aggregation": "SUM",
  "segmentedFields": [
    "<string>"
  ],
  "defaultValue": 123,
  "customSql": "<string>",
  "dtCreated": "2023-11-07T05:31:56Z",
  "dtLastModified": "2023-11-07T05:31:56Z",
  "createdBy": "<string>",
  "lastModifiedBy": "<string>"
}

Authorizations

Authorization
string
header
required

m3ter supports machine to machine authentication using the clientCredentials OAuth2 flow.

The authorizationCode flow controls access for human users via the m3ter Console application.

Path Parameters

orgId
string
required

UUID of the Organization. The Organization represents your company as a direct customer of the m3ter service.

id
string
required

The UUID of the Aggregation to update.

Body

application/json
name
string
required

Descriptive name for the Aggregation.

Required string length: 1 - 200
rounding
enum<string>
required

Specifies how you want to deal with non-integer, fractional number Aggregation values.

NOTES:

  • NEAREST rounds to the nearest half: 5.1 is rounded to 5, and 3.5 is rounded to 4.
  • Also used in combination with quantityPerUnit. Rounds the number of units after quantityPerUnit is applied. If you set quantityPerUnit to a value other than one, you would typically set Rounding to UP. For example, suppose you charge by kilobytes per second (KiBy/s), set quantityPerUnit = 500, and set charge rate at $0.25 per unit used. If your customer used 48,900 KiBy/s in a billing period, the charge would be 48,900 / 500 = 97.8 rounded up to 98 * 0.25 = $2.45.

Enum: ???UP??? ???DOWN??? ???NEAREST??? ???NONE???

Available options:
UP,
DOWN,
NEAREST,
NONE
quantityPerUnit
number
required

Defines how much of a quantity equates to 1 unit. Used when setting the price per unit for billing purposes - if charging for kilobytes per second (KiBy/s) at rate of $0.25 per 500 KiBy/s, then set quantityPerUnit to 500 and price Plan at $0.25 per unit.

Note: If quantityPerUnit is set to a value other than one, rounding is typically set to "UP".

Required range: x > 0
unit
string
required

User defined label for units shown for Bill line items, indicating to your customers what they are being charged for.

Required string length: 1 - 50
meterId
string
required

The UUID of the Meter used as the source of usage data for the Aggregation.

Each Aggregation is a child of a Meter, so the Meter must be selected.

Required string length: 36
targetField
string
required

Code of the target dataField or derivedField on the Meter used as the basis for the Aggregation.

Required string length: 1 - 80
aggregation
enum<string>
required

Specifies the computation method applied to usage data collected in targetField. Aggregation unit value depends on the Category configured for the selected targetField.

Enum:

  • SUM. Adds the values. Can be applied to a Measure, Income, or Cost targetField.

  • MIN. Uses the minimum value. Can be applied to a Measure, Income, or Cost targetField.

  • MAX. Uses the maximum value. Can be applied to a Measure, Income, or Cost targetField.

  • COUNT. Counts the number of values. Can be applied to a Measure, Income, or Cost targetField.

  • LATEST. Uses the most recent value. Can be applied to a Measure, Income, or Cost targetField. Note: Based on the timestamp (ts) value of usage data measurement submissions. If using this method, please ensure distinct ts values are used for usage data measurment submissions.

  • MEAN. Uses the arithmetic mean of the values. Can be applied to a Measure, Income, or Cost targetField.

  • UNIQUE. Uses unique values and returns a count of the number of unique values. Can be applied to a Metadata targetField.

  • CUSTOM_SQL. Uses an SQL query expression. If you select this Aggregation type, use the customSQL request parameter to enter an SQL query.

Available options:
SUM,
MIN,
MAX,
COUNT,
LATEST,
MEAN,
UNIQUE,
CUSTOM_SQL
version
integer<int64>
customFields
any
code
string

Code of the new Aggregation. A unique short code to identify the Aggregation.

Maximum string length: 80
Example:

"example_code"

accountingProductId
string

Optional Product ID this Aggregation should be attributed to for accounting purposes.

Required string length: 36
segmentedFields
string[]

(Optional). Used when creating a segmented Aggregation, which segments the usage data collected by a single Meter. Works together with segments.

Enter the Codes of the fields in the target Meter to use for segmentation purposes.

String dataFields on the target Meter can be segmented. Any string derivedFields on the target Meter, such as one that concatenates two string dataFields, can also be segmented.

Maximum array length: 5
segments
object[]

(Optional). Used when creating a segmented Aggregation, which segments the usage data collected by a single Meter. Works together with segmentedFields.

Enter the values that are to be used as the segments, read from the fields in the meter pointed at by segmentedFields.

Note that you can use wildcards or defaults when setting up segment values. For more details on how to do this with an example, see Using Wildcards - API Calls in our main User Docs.

Maximum array length: 1000
defaultValue
number

Aggregation value used when no usage data is available to be aggregated. (Optional).

Note: Set to 0, if you expect to reference the Aggregation in a Compound Aggregation. This ensures that any null values are passed in correctly to the Compound Aggregation calculation with a value = 0.

Required range: x >= 0
customSql
string

Enter the SQL query expression to be used for a Custom SQL Aggregation. Custom SQL queries should be run against the Measurements table - for more details see Custom SQL Aggregations in your main User documentation.

NOTE: The customSql Aggregation type is currently available in Preview release. If you are interested in using this feature, please get in touch with m3ter Support or your m3ter contact.

Maximum string length: 2048

Response

Return the updated Aggregation

id
string
required

The UUID of the entity.

version
integer<int64>

The version number:

  • Create: On initial Create to insert a new entity, the version is set at 1 in the response.
  • Update: On successful Update, the version is incremented by 1 in the response.
customFields
object

User defined fields enabling you to attach custom data. The value for a custom field can be either a string or a number.

If customFields can also be defined for this entity at the Organizational level,customField values defined at individual level override values of customFields with the same name defined at Organization level.

See Working with Custom Fields in the m3ter documentation for more information.

name
string

Descriptive name for the Aggregation.

rounding
enum<string>

Specifies how you want to deal with non-integer, fractional number Aggregation values.

NOTES:

  • NEAREST rounds to the nearest half: 5.1 is rounded to 5, and 3.5 is rounded to 4.
  • Also used in combination with quantityPerUnit. Rounds the number of units after quantityPerUnit is applied. If you set quantityPerUnit to a value other than one, you would typically set Rounding to UP. For example, suppose you charge by kilobytes per second (KiBy/s), set quantityPerUnit = 500, and set charge rate at $0.25 per unit used. If your customer used 48,900 KiBy/s in a billing period, the charge would be 48,900 / 500 = 97.8 rounded up to 98 * 0.25 = $2.45.

Enum: ???UP??? ???DOWN??? ???NEAREST??? ???NONE???

Available options:
UP,
DOWN,
NEAREST,
NONE
quantityPerUnit
number

Defines how much of a quantity equates to 1 unit. Used when setting the price per unit for billing purposes - if charging for kilobytes per second (KiBy/s) at rate of $0.25 per 500 KiBy/s, then set quantityPerUnit to 500 and price Plan at $0.25 per unit.

If quantityPerUnit is set to a value other than one, rounding is typically set to UP.

unit
string

User defined or following the Unified Code for Units of Measure (UCUM).

Used as the label for billing, indicating to your customers what they are being charged for.

code
string

Code of the Aggregation. A unique short code to identify the Aggregation.

segments
object[]

(Optional). Used when creating a segmented Aggregation, which segments the usage data collected by a single Meter. Works together with segmentedFields.

Contains the values that are to be used as the segments, read from the fields in the meter pointed at by segmentedFields.

accountingProductId
string

Optional Product ID this Aggregation should be attributed to for accounting purposes.

meterId
string

The UUID of the Meter used as the source of usage data for the Aggregation.

Each Aggregation is a child of a Meter, so the Meter must be selected.

targetField
string

Code of the target dataField or derivedField on the Meter used as the basis for the Aggregation.

aggregation
enum<string>

Specifies the computation method applied to usage data collected in targetField. Aggregation unit value depends on the Category configured for the selected targetField.

Enum:

  • SUM. Adds the values. Can be applied to a Measure, Income, or Cost targetField.

  • MIN. Uses the minimum value. Can be applied to a Measure, Income, or Cost targetField.

  • MAX. Uses the maximum value. Can be applied to a Measure, Income, or Cost targetField.

  • COUNT. Counts the number of values. Can be applied to a Measure, Income, or Cost targetField.

  • LATEST. Uses the most recent value. Can be applied to a Measure, Income, or Cost targetField. Note: Based on the timestamp (ts) value of usage data measurement submissions. If using this method, please ensure distinct ts values are used for usage data measurment submissions.

  • MEAN. Uses the arithmetic mean of the values. Can be applied to a Measure, Income, or Cost targetField.

  • UNIQUE. Uses unique values and returns a count of the number of unique values. Can be applied to a Metadata targetField.

  • CUSTOM_SQL. Uses an SQL query expression. The customSQL parameter is used for the SQL query.

Available options:
SUM,
MIN,
MAX,
COUNT,
LATEST,
MEAN,
UNIQUE,
CUSTOM_SQL
segmentedFields
string[]

(Optional). Used when creating a segmented Aggregation, which segments the usage data collected by a single Meter. Works together with segments.

The Codes of the fields in the target Meter to use for segmentation purposes.

String dataFields on the target Meter can be segmented. Any string derivedFields on the target Meter, such as one that concatenates two string dataFields, can also be segmented.

defaultValue
number

Aggregation value used when no usage data is available to be aggregated. (Optional).

Note: Set to 0, if you expect to reference the Aggregation in a Compound Aggregation. This ensures that any null values are passed in correctly to the Compound Aggregation calculation with a value = 0.

customSql
string

The SQL query expression to be used for a Custom SQL Aggregation.

dtCreated
string<date-time>

The DateTime when the aggregation was created (in ISO 8601 format).

dtLastModified
string<date-time>

The DateTime when the aggregation was last modified (in ISO 8601 format).

createdBy
string

The id of the user who created this aggregation.

lastModifiedBy
string

The id of the user who last modified this aggregation.