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
| Key | Required | Meaning |
|---|---|---|
rule | Yes | Identity, targeting, commercial range, and role. |
schedule | Base rules only | One volume or graduated tier schedule. |
actions | Yes | Empty for a base rule. One or more ordered actions for an adjustment rule. |
The rule object:
| Key | Required | Meaning |
|---|---|---|
name | Yes | Readable rule name. |
description | No | Explanation for operators. |
enabled | Yes | Whether a workflow can use this version. |
targetId | Yes | Stable ruleTargets[].id from the Charger instructions. |
role | Yes | base or adjustment. |
priority | Adjustment only | Nonnegative integer. Higher priorities run first. |
commercialRange | Yes | Billed-period range: validFrom and optional validTo. |
labels | Yes | Nonempty map, equal to the complete label map of the target measure. |
groupDimensionIds | Yes | Stable dimension IDs that define the pricing group. Empty list for no grouping. |
criteria | Yes | Ordered dimension filters. Empty list when none apply. |
arithmeticPolicyId | Yes | decimal-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: []
| Key | Required | Meaning |
|---|---|---|
mode | Yes | volume or graduated. |
quantityMeasureId | Yes | Stable ID of the exact nonnegative quantity measure. |
tiers | Yes | One 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.
volumeapplies the rate of one tier to the complete quantity. In the example, quantity120gives120 x 1.50 = 180.00before adjustments.graduatedapplies 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 kind | Effect on the current exact value |
|---|---|
fixed | Replace the value. |
offset | Add a signed value. |
percent | Multiply by 1 + value / 100. Below -100 is invalid. |
Hypermeter rounds once, on the final amount of the target group.
Criteria and action filters
| Key | Meaning |
|---|---|
order | Unique nonnegative evaluation order. Criteria only. |
reference.id | Stable dimension or measure ID. |
reference.kind | dimension for a criterion, measure for an action filter. |
condition | equal, not_equal, greater_than, greater_than_or_equal, less_than, less_than_or_equal, in, or not_in. |
values | String 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
groupDimensionIdsof 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_equalandnot_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-idin the grouping, tiers count Azure usage and other usage separately, and afixedaction 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 oneproportional_by_measurepolicy. 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.
| Operation | Input | Result |
|---|---|---|
charging_rule.list | {} for the complete lean list, or a rich-page input | rules, with projection and page for a rich page |
charging_rule.get | rule_id | The canonical definition, current version, digest, and live_change_hand_off |
charging_rule.validate | definition | valid, findings, and the definition digest when available |
charging_rule.create | definition | The committed rule ID, version, digest, enabled state, and owner hand-off |
charging_rule.update | rule_id, expected_version, and the complete definition | The committed successor version and owner hand-off |
charging_rule.delete | rule_id and expected_version | rule_id and deleted_version |
- Inputs go under
input. Do not usedata.attributes, the old resource type, relationship fields, or theexpectedVersionquery parameter. The version precondition isexpected_version. - Definition fields keep their names and exact decimal strings.
- Read the definition and version before each edit, and send the whole definition.
deleted_versionidentifies 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_offpoints 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.
namematches exactly.enabledaccepts either boolean.label_setsmatches any complete label map. Filters combine with AND.queryis 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, andhas_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.