Integrating a utility data API: what the payload should contain and how to build on it
A developer guide to consuming a utility data API: the fields a bill and interval payload must carry, units, idempotency, webhook versus polling, and mapping to warehouse, BI and ERP.
Most guides to utility data APIs are written from the collection side: how to get bills and meter reads out of a utility. This one is written from the other side. You are a data engineer, a BI developer or an ERP integrator, a provider is going to hand you structured utility data, and you need to know what the payload should contain, how it is delivered, and how to land it in a warehouse, Power BI, an ERP or an ESG tool without rebuilding the provider's validation.
Treat this as the consumer's contract. If a field on this list is missing from the payload, you will end up reconstructing it from PDFs. For how the data is gathered, see automating utility data collection; for the internal stages after it lands, see designing an energy data pipeline.
What a good payload contains
A utility bill is a hierarchy, and the payload should preserve it rather than flatten it into totals. The public reference for the usage half is Green Button, which is based on the Energy Services Provider Interface (ESPI) standard released by NAESB in the fall of 2011 and covers electricity, gas and water. Its data model separates the usage point (service location and meter), the meter reading, the reading type (what is measured, in what unit, at what interval) and the interval blocks of values. A bill payload needs the same discipline plus the financial layer.
- Account and customer: utility account number, customer name as billed, service address, and your own site and organization identifiers
- Meter: meter number, commodity, multiplier, and the meter's active date range so meter swaps are explicit
- Bill period: start date, end date, days, bill date, due date, and whether each read was actual or estimated
- Reads and quantities: start and end reads, consumption, demand (billed and metered), power factor where billed, each with a unit
- Line items: every charge as its own record with description, quantity, unit, rate, amount, tax treatment and the tariff component it belongs to
- Tariff and rate class with effective dates; currency and totals (current charges, prior balance, payments, amount due)
- Source document reference: an identifier for the PDF, portal export or Green Button file the record was built from, with page references where possible
- Validation status and flags: whether the record passed the provider's checks, and which flags were raised (estimated read, period gap, unit change, tariff mismatch, duplicate)
- Lineage: when the source was received, extracted and validated, and the version of the record
Units, scaling and normalization
Units belong on every quantity, not in the documentation. Gas arrives as volume on some bills and energy on others; water as cubic meters, gallons or hundreds of cubic feet. Green Button is instructive here: the format applies power-of-ten multiplier scaling to readings and separate scaling to cost and currency, so a consumer that ignores the multiplier reads every value off by orders of magnitude. Your payload should deliver a normalized value alongside the original with the conversion factor stated: the bill's own figure for reconciliation, the normalized figure for analysis, and never one overwriting the other. The same goes for names: rate class labels, charge descriptions and meter identifiers drift between bills from the same utility, so carry both the canonical value and the source string. Warehouse-side mapping rules are in building a utility data warehouse.
Identifiers, idempotency and versioning
Utility bills get corrected, cancelled and rebilled, and an integration that cannot express that will double count. Three rules keep it honest. Every bill record carries a stable identifier that does not change when the content is corrected, plus a version number that does; Green Button's guidance on UUID generation exists for the same reason. Deliveries are idempotent: receiving the same bill version twice has no effect, so the consumer can safely retry. A correction arrives as a new version that references the one it supersedes, with a reason (rebill, cancel, estimated-to-actual true-up), and the consumer marks the prior version superseded rather than deleting it. Interval data follows the same pattern: a re-read of a day replaces that day's block by identifier.
Delivery patterns: webhook, polling, scheduled export, backfill
Delivery depends on how downstream systems consume: a finance system wants a complete batch to post, a dashboard wants the latest record as soon as it exists, and a warehouse wants both plus the ability to reload history.
| Pattern | Best for | What the consumer has to handle |
|---|---|---|
| Webhook (push on event) | Exception alerts, AP workflows that start when a bill lands | Acknowledge fast, process later; retries and out-of-order events; signature verification |
| Polling (pull on schedule) | Warehouse and BI refreshes on a fixed cadence | Updated-since cursor; pagination; idempotent upserts so overlapping windows are safe |
| Scheduled export (file drop) | ERP and ESG tools that ingest CSV or JSON batches | File naming with period and version; checksum; a manifest of contents |
| Backfill (bulk history) | Initial load, baseline periods, re-processing after a schema change | Rate limits; ordering by bill period; the same versioning rules as incremental loads |
Insist that the backfill and the incremental payload share one record shape; a provider that exports history in one format and streams updates in another has handed you two integrations.
Interval data specifics
Interval data is where integrations quietly break. Green Button providers deliver readings in 5-minute, hourly, daily or monthly intervals, depending on what the energy provider decides to make available, and Canadian smart meters commonly produce hourly or 15-minute data. The payload should state the interval length per reading type rather than leaving you to infer it from timestamp spacing. Every timestamp needs a UTC offset, and the contract should say whether it marks the start or the end of the interval. Daylight saving transitions produce a 23-hour day and a 25-hour day each year; local time without offsets will lose or duplicate an hour, and that day's demand peak will be wrong.
Keep energy and power distinct: a 15-minute value in kilowatt-hours is not a 15-minute average in kilowatts. Carry a quality code per reading (actual, estimated, missing, edited) so a gap is visible rather than filled with zero. And since intervals and bills describe the same meter over the same period, expose the interval-to-bill reconciliation as a field rather than leaving each consumer to compute it.
Error handling and reconciliation
The validation status on each record is the consumer's routing key: passed records load straight through, flagged records go to a review queue or quarantine table with the flags attached, and structural failures are rejected with a reason the provider can act on. Reconciliation then runs at three levels. Record level: line items sum to the bill total, and reads and multiplier produce the consumption. Period level: consecutive bills on a meter abut with no gaps or overlaps, and the interval sum matches the bill. Ledger level: the amounts your ERP posted for a period match the bills the API says exist for it, so a missing invoice or duplicate payment is caught by comparison. Each level needs the identifiers and versions above, which is why they are in the contract.
A provider that delivers only clean records has decided for you what clean means. Ask for every record with its validation status and flags, and set your own loading rules. You can tighten a filter downstream; you cannot recover a bill dropped upstream.
Security basics
Green Button's Connect My Data flow is a reasonable model: the customer gives a one-time authorization and the third party receives data through a transfer built on the IETF OAuth Authorization Framework; the Alliance's developer page references OAuth 2.0 RFCs 6749 and 6750. NAESB describes ESPI as a data exchange protocol for the transfer of energy usage information between a utility and a third party with customer authorization. For your own integration the rules are ordinary: OAuth 2.0 client credentials or scoped API keys rather than shared passwords, tokens scoped to the accounts and sites the consumer needs (least privilege), secrets in a vault, scheduled rotation, TLS everywhere, signed webhooks, and an access log, because utility data includes customer names and addresses.
Reference mapping: payload fields to destinations
The warehouse takes everything; the other destinations take a projection.
| Payload field | Warehouse | BI (Power BI or similar) | ERP or AP | ESG or benchmarking tool |
|---|---|---|---|---|
| Account, site, meter identifiers | Dimension tables with effective dates | Site and meter dimensions | Vendor and cost center mapping | Property and meter mapping |
| Bill period start and end | Fact grain (meter by period) | Date dimension via period allocation | Service period on the invoice | Bill start and end dates |
| Consumption, unit, normalized value | Fact measures, both raw and normalized | Measures: EUI, cost per unit | Not usually posted | Usage in the tool's unit |
| Line items with tariff component | Line-item fact table | Cost breakdown visuals | GL coding per component, tax lines | Not required |
| Source document reference | Lineage column | Drill-through link | Invoice image attachment | Verification package |
| Validation status and flags | Quarantine or status column | Data quality page | Hold or approve routing | Pre-submission check |
| Version and supersedes | Slowly changing fact handling | Latest-version filter | Credit and rebill handling | Replace prior entry |
The ERP and BI columns are expanded in integrating utility data with ERP and Power BI for utility data. Benchmarking tools add their own rules: ENERGY STAR Portfolio Manager wants 12 full calendar months per meter, and a mid-month billing cycle needs 13 bills to cover them, so deliver the full period, not just the calendar year. And where a utility already pushes to Portfolio Manager through its web services API, ENERGY STAR notes it typically delivers aggregate whole-building consumption data as opposed to meter-by-meter data, so your meter-level payload complements that feed.
Where MartinAI fits
MartinAI is the provider side of this contract. It reads every field on every bill and meter file for electricity, gas, water and steam, normalizes units and names while keeping the originals, validates each record, versions corrections and rebills, and delivers structured records with validation status, flags and a link to the source document.
A utility data API is only as useful as the fields it carries and the guarantees behind them. Ask for the full hierarchy, explicit units, versioned identifiers, validation flags and lineage, and the destination mappings become configuration rather than engineering.
Frequently asked questions
What fields should a utility bill data API return?
The full bill hierarchy: account and site identifiers, meter, bill period dates with actual or estimated read status, reads and quantities with units, every line item with its tariff component, rate class, currency and totals, a reference to the source document, validation status and flags, and lineage timestamps with a record version.
Should I use a webhook or polling for energy data?
Use a webhook when a downstream process should start the moment a bill or reading lands, such as an exception alert or an AP workflow. Use polling with an updated-since cursor when the consumer refreshes on its own schedule, such as a warehouse or BI model. Pair either with a backfill path that uses the same record shape.
How should corrected or rebilled utility bills be handled in an API?
Each bill keeps a stable identifier and gets a new version when corrected. The new version references the one it supersedes and states the reason. Deliveries are idempotent so retries are safe, and the consumer marks the earlier version superseded instead of deleting it, which preserves the audit trail and prevents double counting.
Is Green Button the same as a utility data API?
Green Button is a public standard, based on NAESB's ESPI, for usage data from utilities that offer it, delivered as XML with OAuth authorization. A provider's utility data API usually adds the bill hierarchy, line items and validation that Green Button does not carry, and can use Green Button files as one of its sources.
- 1Green Button Alliance: the Green Button standard (ESPI, DMD and CMD, granularity, OAuth)
- 2Green Button Alliance: developer resources (NAESB REQ.21, Atom, OAuth 2.0 RFCs, scaling, UUIDs)
- 3NAESB: Energy Services Provider Interface (ESPI) standards
- 4ENERGY STAR: utilities using Portfolio Manager web services
- 5ENERGY STAR Portfolio Manager glossary: 12 full calendar months
Automating Utility Data Collection: Portals, APIs, Green Button, and the Gaps Bill Parsing Fills
Portal downloads, utility APIs, Green Button Connect, aggregators, scraping, and PDF parsing compared on coverage, latency, and maintenance cost.
Integrating utility data with ERP and accounting systems
How to get clean utility data into your ERP or accounting system: the integration patterns (file, EDI 810, API), what has to be true before you connect, and how allocation works.
