Guides and Examples
Everything Billing
Usage
9 min
usage overview in the nue api, usage represents the consumption based metrics that drive variable billing for services and products usage tracking enables businesses to implement pay as you go models, tiered pricing structures, and hybrid subscription approaches that combine fixed and variable components what is usage based billing? usage based billing is a pricing model where customers are charged based on their actual consumption of services or resources rather than a fixed recurring fee this model aligns costs with value customers pay for what they actually use enables flexible pricing supports various consumption based pricing strategies provides transparency gives customers visibility into their consumption patterns scales with customer growth naturally increases revenue as customer usage grows to get started with nue usage accelerator, please refer to this article ingest usage via api ingest raw usage raw usage represents a raw usage record that results from a measurable consumption of a product or service it is characterized by various fields, including created date, customer id, quantity, and timestamp, among others after the raw usage records are uploaded, nue rates them into billable usage records you can automate the usage ingestion using the ingest raw usage api post https //api nue io/usage/raw usage for example, the following api ingest 2 more raw usage records of the vroom webinar to nue note it is important to make sure that the raw usage uploaded is processed only once this objective can be achieved by selecting a deterministic transactionid that ensures that each raw usage has the unique transactionid nue ensures that raw usage records having the same id will be processed once and only once curl location 'https //api nue io/usage/raw usage' \\ \ header 'apiaccesskey {{apiaccesskey}}' \\ \ header 'content type application/json' \\ \ header 'authorization bearer {{token}}' \\ \ data '{ "transactionid" "sub 001336 001", "data" \[ { "transactionid" "sub 001336 001", "customerid" "0015f00001uphpvaaf", "subscriptionnumber" "sub 001336", "timestamp" "2023 04 24t09 00 06 000z", "quantity" 129, "properties" { "region" "eu 1", "clusterid" "1" } }, { "transactionid" "sub 001336 002", "customerid" "0015f00001uphpvaaf", "subscriptionnumber" "sub 001336", "timestamp" "2023 04 20t09 00 06 000z", "quantity" 398, "properties" { "properties" { "region" "eu 2", "clusterid" "2" } } } ] } ' the custom attributes within the properties element can be used to organize usage records into groups a single subscription may contain multiple usage record groups, each of which is rated independently manage custom fields in raw usage developers can create and manage custom text fields on the raw usage object directly through the nue metadata api key capabilities include create custom text fields and delete custom fields we only support creating the ‘text’ type custom field for now, and will support other types in the future newly created fields will be queryable via graphql updating a field is currently not supported; users can delete and recreate a field with the same api name to modify it after creating a custom field on the raw usage object, users can include this field in their csv files when uploading raw usage data, or using ingest raw usage api, populating it with their desired values please refer to the api documentation for more information about the nue metadata api the following is an example post /api/metadata/objects/rawusage/fields\ text content type application/json { "apiname" "externalid", "name" "external id", "minlength" 5, "maxlength" 255 } rated usage optionally, you can ingest pre rated usage using ingest rated usage api unlike raw usage, rated usage can be submitted in multiple currencies at billing time, usage records are grouped by currency and converted into invoice items post https //api nue io/usage/rated usage