Skip to main content

Charging rules reference

A charging rule applies commercial pricing to a labeled Charge target. It is a base pricing schedule or an ordered adjustment.

For pricing behavior and worked calculations, see Charging rules. For target, measure, and allocation keys, see Charger instructions.

Authoring shape​

KeyRequiredMeaning
ruleYesIdentity, targeting, commercial range, and role.
scheduleBase rules onlyOne volume or graduated tier schedule.
actionsYesEmpty for a base rule. One or more ordered actions for an adjustment rule.

The rule object:

KeyRequiredMeaning
nameYesReadable rule name.
descriptionNoExplanation for operators.
enabledYesWhether a workflow can use this version.
targetIdYesStable ruleTargets[].id from the Charger instructions.
roleYesbase or adjustment.
priorityAdjustment onlyNonnegative integer. Higher priorities run first.
commercialRangeYesBilled-period range: validFrom and optional validTo.
labelsYesNonempty map, equal to the complete label map of the target measure.
groupDimensionIdsYesStable dimension IDs that define the pricing group. Empty list for no grouping.
criteriaYesOrdered dimension filters. Empty list when none apply.
arithmeticPolicyIdYesdecimal-38-12-half-even-v1.

Reference targets, dimensions, and measures by stable ID, not by display name.

Exact decimals are strings in plain notation, with at most 26 integral and 12 fractional digits. Do not use a JSON number or an exponent.

Base pricing schedule​

A base rule requires schedule, forbids priority, and has an empty actions list.

rule:
name: Usage base price
enabled: true
targetId: usage-charge
role: base
commercialRange:
validFrom: "2026-01-01T00:00:00Z"
labels:
charge: usage
currency: USD
groupDimensionIds:
- customer-id
- billing-month
- provider-id
criteria: []
arithmeticPolicyId: decimal-38-12-half-even-v1
schedule:
mode: volume
quantityMeasureId: chargeable-usage
tiers:
- lowerBound: "0"
upperBound: "100"
unitRate: "2.00"
- lowerBound: "100"
unitRate: "1.50"
actions: []
KeyRequiredMeaning
modeYesvolume or graduated.
quantityMeasureIdYesStable ID of the exact nonnegative quantity measure.
tiersYesOne or more contiguous half-open ranges.

Each tier has lowerBound, optional upperBound, and unitRate. The first lower bound is zero, and every upper bound equals the next lower bound. Only the final tier can omit upperBound. Quantities and rates cannot be negative.

  • volume applies the rate of one tier to the complete quantity. In the example, quantity 120 gives 120 x 1.50 = 180.00 before adjustments.
  • graduated applies each rate to the quantity inside its tier: 100 x 2.00 + 20 x 1.50 = 230.00. Tiers are not rounded separately.

Adjustment rule​

An adjustment rule requires priority and one or more actions. It must not contain schedule.

rule:
name: Azure usage adjustment
description: Apply the contracted uplift or fallback credit
enabled: true
targetId: usage-charge
role: adjustment
priority: 200
commercialRange:
validFrom: "2026-06-01T00:00:00Z"
labels:
charge: usage
currency: USD
groupDimensionIds:
- customer-id
- billing-month
- provider-id
criteria:
- order: 0
reference:
id: provider-id
kind: dimension
condition: equal
values:
- azure
arithmeticPolicyId: decimal-38-12-half-even-v1
actions:
- order: 0
kind: percent
value: "10"
fallback: false
filter:
reference:
id: chargeable-usage
kind: measure
condition: greater_than_or_equal
values:
- "1000"
- order: 1
kind: offset
value: "-1.25"
fallback: true

The criterion filters on provider-id, so the rule also groups by it: see Criteria and action filters. Every rule for a target uses the groupDimensionIds of the target in the same order.

Actions run by ascending order. The first matching filtered action applies. One final unfiltered action can be the fallback.

Action kindEffect on the current exact value
fixedReplace the value.
offsetAdd a signed value.
percentMultiply by 1 + value / 100. Below -100 is invalid.

Hypermeter rounds once, on the final amount of the target group.

Criteria and action filters​

KeyMeaning
orderUnique nonnegative evaluation order. Criteria only.
reference.idStable dimension or measure ID.
reference.kinddimension for a criterion, measure for an action filter.
conditionequal, not_equal, greater_than, greater_than_or_equal, less_than, less_than_or_equal, in, or not_in.
valuesString list: exactly one value for a scalar comparison, one or more for in and not_in. Action filter values are exact decimals.
  • A criterion can filter only on a dimension in the groupDimensionIds of the rule. The rule then applies to a whole group or skips it.
  • A group whose filtered dimension is NULL never matches, also with not_equal and not_in.
  • Any other criterion, including one on a rule without grouping dimensions, is rejected when you save the rule, also from hyper. An older rule with this shape fails the workflow check until you fix it.
  • Tiers, fixed adjustments, and allocation add up per group. With provider-id in the grouping, tiers count Azure usage and other usage separately, and a fixed action sets one amount per customer, month, and provider.

Commercial range​

commercialRange.validFrom is inclusive. Optional commercialRange.validTo is exclusive and must be after validFrom. Both are RFC 3339 timestamps with a timezone.

The range applies to complete billed periods, not to the run time. Boundaries must align with the Charge grain and pricing calendar. A period that crosses a boundary is not prorated.

Grouping, precedence, and allocation​

  • One target, group, and billed period has at most one applicable base schedule. Its result replaces the unadjusted target value. Without a base, adjustments start from the unadjusted value.
  • Applicable adjustments have distinct priorities. Each reads the exact result of the previous one.
  • Allocation is part of ruleTargets, and a rule cannot replace it. A target can declare at most one proportional_by_measure policy. Hypermeter rounds the group amount before allocation and uses the largest-remainder method at 12 decimals. See Rule targets and allocation.

Immutable versions​

  • Creating a rule writes its first version. An edit, enable, disable, or delete creates a successor version and keeps the history.
  • These changes require expectedVersion. A stale value fails and does not overwrite a newer version.
  • A workflow release freezes the rule versions that match. Later rule changes do not alter an active release. To use a successor version, publish the workflow again.

Native operation contract​

These native operations replace the removed Charging Rule resource routes. For discovery, authentication, and receipts, see Native API and JSON:API migration.

OperationInputResult
charging_rule.list{} for the complete lean list, or a rich-page inputrules, with projection and page for a rich page
charging_rule.getrule_idThe canonical definition, current version, digest, and live_change_hand_off
charging_rule.validatedefinitionvalid, findings, and the definition digest when available
charging_rule.createdefinitionThe committed rule ID, version, digest, enabled state, and owner hand-off
charging_rule.updaterule_id, expected_version, and the complete definitionThe committed successor version and owner hand-off
charging_rule.deleterule_id and expected_versionrule_id and deleted_version
  • Inputs go under input. Do not use data.attributes, the old resource type, relationship fields, or the expectedVersion query parameter. The version precondition is expected_version.
  • Definition fields keep their names and exact decimal strings.
  • Read the definition and version before each edit, and send the whole definition.
  • deleted_version identifies the consumed version. The history stays.
  • A delegate can create, change, or delete disabled rules only. To enable, disable, or change a live rule, an owner uses the web app: live_change_hand_off points to that flow.

Search and page through rules​

{} returns the complete lean list. Use projection: "rich" for search, filters, and pagination:

{
"projection": "rich",
"enabled": false,
"query": "Storage",
"page_number": 1,
"page_size": 25
}
  • Paging defaults to page 1 and size 25. The maximum page size is 100.
  • name matches exactly. enabled accepts either boolean. label_sets matches any complete label map. Filters combine with AND.
  • query is a literal substring search with Unicode simple lowercase, without normalization or accent folding.
  • The result has page.total_count, total_pages, page_number, page_size, and has_more.
  • Rules sort by creation time descending, then ID ascending. Pages can shift when someone edits rules.
  • A read that is too large fails with RESULT_TOO_LARGE, without a truncated page.

Call through hyper​

hyper op describe charging_rule.get
hyper op call charging_rule.get \
--tenant <tenant-id> --task <task-id> \
--input '{"rule_id":"11111111-1111-4111-8111-111111111111"}' --json

Use a rule_id from your list result. For an update, put rule_id, expected_version, and the complete definition in a file:

hyper op call charging_rule.update \
--tenant <tenant-id> --task <task-id> --input-file updated-rule.json --json

If delivery of a write is uncertain, do not send a replacement: see Recover an uncertain command. A compact acknowledgement confirms the change without the definition. Use its charging_rule.get target when present.

Retired fields and kinds​

effectiveRange, weight, aggregation, filters, aggregationColumns, and aggregationColumnsKind are not accepted. Use commercialRange, priority, criteria, groupDimensionIds, and Charger target allocation.

The kinds inclusive and exclusive are not tier modes. Use volume or graduated. Inclusive and Exclusive remain valid for the moment boundaries of a Charger.