telco

Billing, contract and usage events

Subscribe to signed CloudEvents and decode each payload with the event schemas or Rust types.

On this page

Use contract events to update a CRM, bill events to start reconciliation, and usage events to retrieve completed switch receipts.

What an event looks like

A CloudEvents 1.0 envelope, the same on the pull feed and on a contractd or billd webhook:

{
  "specversion": "1.0",
  "id": "01a1e9c2-2e01-7423-a0a3-722983ab028c",
  "source": "urn:telco:billd",
  "type": "de.telco.bill.sealed",
  "subject": "bill/01a1e9c2-2e01-7423-a0a3-722983ab028c",
  "time": "2026-10-05T06:00:01Z",
  "datacontenttype": "application/json",
  "dataschema": "https://hupe1980.github.io/telco/schemas/events/de.telco.bill.sealed.json",
  "sequence": "42",
  "businessdate": "2026-10-05",
  "data": { "id": "…", "number": "RE-2026-000001", "kind": "invoice", "billing_account": "…" }
}

De-duplicate on id, order by sequence within one source. businessdate is the day the fact belongs to; on a test clock it is not the day of time. orderref, when present, is the seller's order reference: every event of a contract that came through POST /signups carries it, so a shop matches events to its orders without a lookup (Selling).

Every type's data has a schema

Each event's payload is a Rust struct in the telco-events crate, with a generated JSON Schema (draft 2020-12). Find it

  • at the event's dataschema URL,
  • in GET /event-types on contractd and billd, with the meaning and the source (a shared profile a service consumes under any type, such as contractd's appointment@1, is listed there by profile, dataschema and route),
  • as a downloadable schema, such as bill held,
  • in the terminal: telco events schema bill.held,
  • all at once as an AsyncAPI 3.0 document at /schemas/asyncapi.json (telco events asyncapi): one message per type, the envelope, the signature headers — for code generators and event catalogues.

Every schema is strict (additionalProperties: false). Every event the services' test suites emit is read back strictly into its type when the test ends, so a producer cannot send a field the schema does not declare. data carries ids, states, dates and rule ids — never a name, an address, a contact or an amount: those stay behind the API, read under the reader's own rights, and a test refuses a payload field named like one.

The promise. A type is never renamed or removed; data only gains optional fields; a fact that changes meaning gets a new type, emitted beside the old one until a release note retires it.

The types

TypeEmitted byData
de.telco.usage.batch-reconciledusagedid, the completed voice batch. Operators and read-only integrations poll GET /usage/events and fetch the redacted receipt by UUID.
de.telco.customer.createdcontractdid
de.telco.customer.movedcontractdid, from — read the new address from contractd
de.telco.billing-account.createdcontractdid, customer
de.telco.billing-account.changedcontractdid, field (payment_method, invoice_email), from
de.telco.contract.createdcontractdid, state
de.telco.contract.approvedcontractdid, state — § 54 Abs. 3 TKG
de.telco.contract.voidedcontractdid, state
de.telco.contract.termination-receivedcontractdid, effective_on, basis, rule
de.telco.contract.renewal-notice-duecontractdid, last_day_to_cancel, initial_term_end — § 56 Abs. 3 TKG, once
de.telco.contract.renewedcontractdid, renewed_on, rule
de.telco.contract.term-extendedcontractdid, initial_months, rule — § 66 Abs. 3 TKG
de.telco.contract.endedcontractdid, ended_on
de.telco.subscription.outage-credit-approvedcontractdid (subscription), case_id identify the frozen outage award for billing
de.telco.subscription.appointment-credit-approvedcontractdid (subscription), case_id — billd reads the immutable award
de.telco.subscription.createdcontractdid, contract, state
de.telco.subscription.activatedcontractdid, state — billing starts
de.telco.subscription.restrictedcontractdid, state
de.telco.subscription.restriction-liftedcontractdid, state
de.telco.subscription.plan-changedcontractdid, plan, book_version
de.telco.subscription.identifier-assignedcontractdid, kind — the value stays in contractd
de.telco.subscription.termination-scheduledcontractdid, state
de.telco.subscription.endedcontractdid, state
de.telco.subscription.voidedcontractdid, state
de.telco.bill.sealedbilldid, number, kind, billing_account
de.telco.bill.heldbilldbilling_account, period, code, rules, fix (field, operation)
de.telco.bill.creditedbilldid, number, cites
de.telco.test.pingeitherwebhook — sent only by POST /webhooks/{name}/test, never on the feed

In Rust

Add the events crate and a JSON decoder to your Rust project:

cargo add telco-events --features webhook
cargo add serde_json
use telco_events::{CloudEvent, bill, contract, webhook};

// Standard Webhooks: HMAC-SHA256 over id.timestamp.body, the code telco signs with.
let secrets = [webhook::Secret::parse(&std::env::var("TELCO_WEBHOOK_SECRET")?)?];
webhook::verify(&secrets, |h| headers.get(h).map(str::to_owned), &body, now_unix)?;

let event: CloudEvent = serde_json::from_slice(&body)?;
match event.kind.as_str() {
    bill::SEALED => {
        let sealed: bill::Sealed = event.data()?; // refused if the type or the data differ
        println!("{} sealed for {}", sealed.number, sealed.billing_account);
    }
    contract::TERMINATION_RECEIVED => {
        let t: contract::TerminationReceived = event.data()?;
        println!("ends on {}", t.effective_on);
    }
    _ => {}
}

The crate does no I/O and reads no clock: verify takes your now. With the schema feature, telco_events::schema(kind) returns any type's schema.

Receiving them

Pull. Read GET /events on contractd and billd or GET /usage/events on usaged. Store the returned next cursor per service and send it as after on the next request. To filter the billing feed, add types=de.telco.bill.*.

Push. Register a webhook on contractd or billd (POST /webhooks, the webhooks guide): it gets its signing secret once, a test ping, a delivery log and replay, and sees only the types its key may see. An operator can also configure subscribers on the emitting service (TELCO_SUBSCRIBERS=crm=https://crm.example/telco). Deliveries are signed, in order per subscriber, retried with back-off, and a 410 Gone pauses the subscriber (the services).

Watching them

telco listen follows the contract, billing and usage feeds as things happen — one line per event, each aggregate in its colour:

$ just listen bill contract
● following contractd, billd and usaged (de.telco.bill.*, de.telco.contract.*) — Ctrl-C ends it
17:04:10 02.11.2027  contract.renewed                   contract/…3fe46a0c            renewed_on=2027-11-01 rule=DE-TKG-56-3-renewed
17:04:10 02.11.2027  bill.sealed                        bill/…e5fefc50                billing_account=…1bb2981b kind=invoice number=RE-2027-000021
17:04:10 02.11.2027  bill.held                          billing-account/…4670fc2a     code=bill.einvoice-invalid fix=invoice_email period=2027-11 rules=PEPPOL-EN16931-R010
  • --types bill,contract.ended filters (a bare aggregate means all its types); --json prints the envelopes, one per line, for jq; --all starts from the beginning.
  • --webhook 127.0.0.1:9199 --secret whsec_… receives deliveries instead, so you can point a subscriber at it and rehearse your endpoint: each signature is checked, a forged delivery is answered 401 and shown as refused, and control characters in event text are shown escaped.
  • telco events list prints every type with its source and meaning.

Download Markdown