# Reconcile mobile usage

> Import measured mobile sessions, resolve held rating groups, check the customer’s data allowance and reconcile TMF635 product usage with a sealed invoice.


One final 26 GB session on the example Smart 25 tariff contains 19.75 GB in rating group 101 and 6.25 GB in group 102. Map the first group and the customer meter shows 19.75 GB. Map and release the second and it shows 26 GB against a 25 GB allowance. The next bill rates 1 GB beyond the allowance. The two partner usage records point back to that bill.

## Connect the mediation feed

Use a named switch credential for a **trusted estate-wide mediation source**. The source identifies the subscription and supplies final, normalized records. Give each feed its own principal and retain that name on key rotation. Provision tariff mappings with an operator credential. Send UTC-independent service dates using the operator's local billing calendar. Send integer bytes, seconds or messages. A parent quantity must equal the sum of its distinct rating groups. Preserve source record and batch UUIDs across retries.

The example below uses the repository's worked batch. Set `BILLD` to the billing service URL, `SUBSCRIPTION` to an active Smart 25 subscription, and use the appropriate tokens for the two roles. The example business date is 5 November 2026. For another period, change the mapping date and service date together.

```sh
curl -fsS -X PUT "$BILLD/mobile-mappings/ae9ef6a7-f1e8-4944-9f94-90ca5718f3fa" \
  -H "Authorization: Bearer $OPERATOR_TOKEN" --json \
  '{"source":"switch-east","rating_group":101,"unit":"bytes","kind":"data","from":"2026-11-01"}'

jq --arg sub "$SUBSCRIPTION" '.records[0].subscription = $sub' \
  samples/mobile/batch.json > mobile-batch.json
curl -fsS -X PUT "$BILLD/mobile-batches/67eda7c7-be60-45ef-834b-b270474828ac" \
  -H "Authorization: Bearer $SWITCH_TOKEN" --json @mobile-batch.json
```

## Resolve a held group

Open **Mobilfunk** in the Desk. The initial view includes outstanding records across receipt dates. Filter by source or Eingangstag to inspect one receipt cohort. A record with one outstanding container counts once in the held-record numerator. The volume totals only include its outstanding containers and keep each unit separate.

Choose **Tarifzuordnung anlegen** on group 102. Enter the tariff kind `data` and an effective date on or before the service date, then save. This mapping applies to the source, group and unit for subsequent imports as well. Choose **Erneut prüfen** for the held container. The service checks its tariff and policy again and bills it once. Replaying the original batch returns its original receipt. Use the work queue for the current disposition. An unresolved container holds the affected billing period. If the source confirms an invalid record or independently verifies a duplicate, an operator can record that disposition with its evidence UUID. For a known out-of-profile network or destination, or for a closed period, **Extern abgerechnet und belegt** records an actual external settlement. Supply its evidence UUID and reconcile any customer or finance obligations there. The original measurement and receipt remain available. A late record for an already sealed period requires financial review. For one measurement, staff can read `GET /mobile-measurements/{id}` to check the original tariff hash, mapping, jurisdiction decision, policy revision and invoice linkage.

## Show the customer their meter

Expose `/subscriptions/{id}/mobile-meter/html` through your authenticated customer portal. The portal maps the signed-in customer to a `customer:<billing-account-uuid>` credential server-side. Forward only the meter, its month query and the preference endpoint. For your own app, the JSON sibling is `/subscriptions/{id}/mobile-meter?period=YYYY-MM`. Keep the dedicated credential outside the browser. The customer can disable or re-enable the volume notice free of charge. Period-end figures are available on the sealed invoice and in the historical meter. [German volume disclosure requirements](https://www.gesetze-im-internet.de/tktransparenzv/__9.html)

Connect the provider’s notification gateway to the billd warning queue. Poll `GET /mobile-warnings`, deliver the message to the subscription’s verified contact, then acknowledge the outcome at `PUT /mobile-warnings/{id}/delivery`. Use the warning UUID as the gateway’s idempotency key. Preserve a delivery reference for retries and monitor outstanding failures. Acknowledge with JSON such as `{"outcome":"delivered","reference":"gateway-293"}`. Record an unsuccessful attempt as `failed` with its own reference. Dispatch promptly after record processing. An excessive-consumption warning has its own dated operator threshold and remains independent of the volume preference. The reference thresholds are 100 GB, 72,000 seconds and 2,000 messages per month. Provision threshold revisions from the first day of a month. Review the thresholds against the operator’s products before deployment. [German cost-control requirements](https://www.gesetze-im-internet.de/tktransparenzv/__10.html)

To distinguish an idle day from a missing feed, the operator reconciles all expected feeds for the subscription, including zero-use days. Attest each complete service day with `PUT /subscriptions/{id}/mobile-meter/coverage` and a body such as `{"day":"2026-11-05","reference":"feed-control-20261105"}`. A missing day, held record or change to already confirmed usage limits coverage. Reconcile a changed day again and submit a fresh receipt. Observe the coverage date alongside the last recorded activity.

## Reconcile partner usage

Issue an account-scoped `usage-reader:<billing-account-uuid>` credential for measurements. Partners that also retrieve the invoice use a separate `bill-reader:<billing-account-uuid>` credential for TMF678. The TMF635 v5 collection is `/tmf-api/productUsageManagement/v5/productUsage`. Filter by `product.id` (the subscription UUID) and page by `offset` and `limit`. A 206 response has another page; advance by `X-Result-Count`. Read one measurement by appending its public UUID.

Each accepted container exposes its product, usage type and three string characteristics: exact integer quantity, unit and local service date (`usageDate`). Parsing the quantity as an integer preserves large byte counts. For invoiced usage, sealing sets the status to `rated` and adds the TMF678 `customerBillId`. Prepaid usage becomes `rated` as soon as billd records its wallet rating. The opaque mobile usage reference in billing is `mobile:<ProductUsage UUID>`. Held containers remain in the operator work queue. [Partner bills](../docs/tmf-bills/) · [Roaming controls](../docs/mobile-roaming/)

## Reconcile online charging

Once chargingd acquires a prepaid subscription’s clean service month, it owns the allowance and charges for that subscription throughout the month. Enable online charging for subscriptions whose chargeable traffic uses the CHF. A subscription that already has offline-rated usage or held mobile records continues on the offline path until a clean period.

A secondary mobile container can carry `online_report` next to its rating group and quantity. Direct API usage supports the same field per record. Use the CHF invocation’s report UUID for the exact reported increment. A `reconciliation` receipt means billd retained the observation. The CHF’s own reported usage supplies the meter and is excluded from billd’s prepaid posting and invoice usage charges.

Read `GET /online-charging/reconciliation?month=2026-11`. Counts cover the whole service month. Use `next` as `after` to page through the observations. A copy and report must agree on subscription, service day, tariff kind and quantity. An absent reference is `unmatched`, a referenced report still in transit is `pending_reports`, and different figures or multiple records citing the same report are `conflicting`. The number of reports awaiting any copy is `missing_copies`. API providers without a secondary feed can expect this count to stay positive. A discrepancy requires operator review and cannot produce an additional debit.
