Skip to main content

PowerBox and BillSense AI integration guide

This guide is for backend engineers at a utility. It covers what you need to connect your systems to EnergyGrid so that the EnergyGrid app, BillSense AI bill analysis, and the DataBridge Hub work for your customers.

The integration has two layers:

  1. Real-time layer (PowerBox API): middleware you host that handles customer sign-in and profile sync.
  2. Bulk data layer (SFTP or object storage): scheduled file transfers with usage data (MDM), billing data, billing cycles, and rate information. BillSense AI depends on this layer.
Prefer to try it first?

The 30-minute tutorial walks through the real-time layer against the sandbox.

Step 1: Host the PowerBox middleware​

The PowerBox API translates between EnergyGrid and your systems. Host it in your own infrastructure, on premises or in your cloud, and make it reachable from EnergyGrid over HTTPS with TLS 1.2 or later.

Protect it with mutual TLS (mTLS), OAuth token validation, or both. IP allowlisting is a common extra layer.

Step 2: Configure authentication (OAuth)​

EnergyGrid uses the OAuth authorization code flow with OpenID Connect (OIDC) to link the customer's utility account to their EnergyGrid profile.

Recommendation

Use OIDC. If your identity provider doesn't support it yet, SAML also works, but most utility partners are moving to OIDC.

Authentication flow​

  1. The mobile app sends a token request to the utility identity provider (IDP).
  2. The customer signs in on the utility's sign-in page with their existing credentials.
  3. The IDP returns an authorization code to the mobile app.
  4. The mobile app exchanges the code for a token with the utility IDP.
  5. The token response returns to the app.
  6. The app sends the token to the EnergyGrid backend.
  7. EnergyGrid validates the token against the utility IDP.
  8. After validation, EnergyGrid issues its own internal session token for subsequent API calls.
note

EnergyGrid uses the utility IDP only for the first sign-in. After it validates the token, EnergyGrid runs the session with its own token. EnergyGrid doesn't store customers' personally identifiable information (PII).

JWT claims​

The claims in the JSON Web Token (JWT) vary by utility. The two common patterns:

Utility modelClaim used
Business partner modelBPID (Business Partner ID)
Profile-based modelsubject, custom claims, or Profile ID

The claim must resolve to a unique, permanent customer identifier (see clientId in Step 3).

Login endpoint​

Endpoint: POST /powerbox/login

Authenticates a utility customer against your customer database.

Request payload: OAuth token (Bearer header)

Response (success, HTTP 200):

{
"clientId": "123456789"
}

Response (error, HTTP 401 or 404):

{
"errorCode": 1
}
FieldData typeNotes
clientIdAlphanumericUnique customer identifier within the utility

For every error code, see Appendix A.

Step 3: Customer synchronization​

After sign-in, EnergyGrid fetches the customer's account details, service addresses (premises), and meter configuration from your customer information system (CIS).

Endpoint: POST /powerbox/customer

EnergyGrid calls this endpoint right after login, to get current customer data. It calls it again whenever a token expires, the customer signs out, or the customer reinstalls the app.

Request payload: OAuth token (Bearer header)

The data model​

ConceptWhat it identifiesExamples
Client IDThe person (sign-in profile). Stays the same when they move.Business Partner ID (BPID), Business Partner Number (BPN), Profile ID
Account numberThe billing account. Changes when the customer moves.Contract account number
External site ID (premise number)The physical location. Stays the same between tenants.Premise number, site number
Meter IDThe physical meter. Permanent and unique.Utility meter ID

Key relationships:

  • One person (clientId) can have multiple premises (customerSites).
  • One premise can have multiple meters (meters).
  • Account number plus premise ID identifies one site in EnergyGrid.
  • If only one premise or meter exists, isPrimary defaults to true.
Detecting a tenant move

When premise and meter IDs stay the same between tenants, EnergyGrid detects when a new tenant moves in and removes the premise from the previous tenant's client ID. When two client IDs share the same account number and premise, EnergyGrid treats them as a shared account: several sign-in profiles with access to the same premises.

Response (full model)​

{
"clientId": "123456789",
"firstName": null,
"lastName": null,
"businessName": null,
"AcctStatus": "A",
"customerSites": [
{
"externalSiteId": "5113305555",
"isPrimary": true,
"firstName": "John",
"lastName": "Doe",
"address1": "123 Main St.",
"city": "Detroit",
"state": "MI",
"postalCode": "48067",
"meters": [
{
"accountNumber": "85000000",
"meterId": "123456789",
"meterType": "Electric",
"unitOfMeasure": "kWh",
"isPrimary": true,
"isAMI": true,
"isAMR": true,
"rateCode": "ABCRATE1",
"billingCycleId": 1
}
]
}
]
}

Customer fields​

FieldData typeRequiredNotes
clientIdAlphanumericYesUnique customer identifier. Use a permanent profile ID (BPID, BPN, or Profile ID) so the record persists across moves.
firstNameStringOptionalCustomer's first name.
lastNameStringOptionalCustomer's last name.
businessNameStringOptionalIf present, EnergyGrid marks the customer as a business account.
AcctStatusStringOptionalCurrent account state. See Appendix B. The API returns this field name in PascalCase.
customerSitesArrayYesPremises associated with the customer.

CustomerSite fields​

FieldData typeRequiredNotes
externalSiteIdAlphanumericYesPremise or site number. Use the permanent value if available. With the account number, it identifies one premise in EnergyGrid.
isPrimaryBooleanYestrue if this is the customer's primary location. Always true if only one site exists.
firstNameStringOptionalFirst name on the billing account.
lastNameStringOptionalLast name on the billing account.
address1StringYesStreet address.
cityStringYesCity.
stateStringYesTwo-character state or province code.
postalCodeStringYesUS: 5-digit zip code. Canada: 6-character postal code with space (for example, V6M 2T5).
metersArrayYesMeters at this site. A site can have more than one meter of any type.

Meter fields​

FieldData typeRequiredNotes
accountNumberAlphanumericConditionalContract account number. Required if permanent client and premise IDs are used (where only the account number changes on move). Apply the same account number to all meters at a billing account. Account numbers must differ across premises.
meterIdAlphanumericYesPermanent unique meter identifier. Used for DataBridge Hub binding requests if applicable.
meterTypeStringYes"Electric" or "Gas".
unitOfMeasureStringOptionalElectric: kWh or Wh. Gas: ccf or cm.
isPrimaryBooleanYestrue for the main meter when multiple meters exist at a site. If a site has an interruptible HVAC meter and a standard meter, the standard meter is marked primary.
isAMIBooleanYestrue if this is an Advanced Metering Infrastructure (AMI) smart meter. AMI meters have radios that form a mesh network and send data automatically. If isAMI = true, a DataBridge Hub can be added.
isAMRBooleanOptionaltrue if this is an Automated Meter Reading (AMR) meter, which a passing vehicle reads over RFID.
PANIDAlphanumericOptionalObsolete. Personal Area Network (PAN) ID of the AMI meter. Previously used by DataBridge Hub for mesh binding.
rateCodeAlphanumericYesMeter rate code that determines which billing calculator to use. See Step 6.
rateMultiplierNumericOptionalObsolete. Rate multiplier for usage computation.
billingCycleIdIntegerYesCustomer's billing cycle ID. References the billing cycle schedule. See Step 5.
dialCountIntegerOptionalObsolete. Number of dials on a meter, previously used for AMR gas meters.
Minimum fields for launch

The customer response must include at least: clientId, at least one customerSite with externalSiteId and postalCode, and at least one meter with meterId, meterType, isAMI, rateCode, and billingCycleId.

Step 4: Bulk data ingestion (required for BillSense AI)​

The PowerBox API tells EnergyGrid who the customer is. To explain a bill, BillSense AI also needs how much energy the customer used and what they were charged.

caution

Without billing data and rate information, BillSense AI can't work. Projected bills won't match real bills, and customers call your support line to ask why.

4.1 Usage data (MDM)​

Usage data drives every chart in the app. It comes from your meter data management (MDM) system.

AttributeDescription
SourceMeter Data Management (MDM) system
Electric granularity15-minute or hourly
Gas granularityDaily (standard) or hourly (if using AMR adapters)
LatencyVaries by utility, from a few hours to about 36 hours behind
AMI dependency

Without AMI meters and hourly data, there's little for the app to chart or analyze, and the platform loses most of its value.

Ingestion methods​

  • Full batch: send data for every customer. EnergyGrid stores it and loads it when a customer registers.
  • Registered only: send data only for customers who have registered.
  • API backfill: EnergyGrid requests history through the API at registration, then regular SFTP or object-storage updates start the next day.

File format​

Format: CSV via SFTP

File naming convention:

  • Electric: CompanyCode_DDMMYYYY_Electric.csv
  • Gas: CompanyCode_DDMMYYYY_Gas.csv

CSV structure:

AccountNumber,ExternalSiteID,MeterID,TimeStamp,TotalUnit
910020087577,5113018555,5532879,1/1/2017,22.556
910020087577,5113018555,5532879,1/2/2017,12.898
910020087577,5113018555,5532879,1/3/2017,0.256
910020087577,5113018555,5532879,1/4/2017,10.256
note

EnergyGrid loads data only for registered customers, matched by the identifiers from /powerbox/customer. You can still send data for every customer.

4.2 Billing and financial data​

To explain why a bill changed, for example because the rate went up, BillSense AI needs detailed billing data.

Meter Contract History (MCH)​

The meter contract history (MCH) is the record of what the customer was billed. Include these fields:

FieldDescription
Contract accountBilling account identifier
Billing start dateStart of the billing period
Billing end dateEnd of the billing period
Total consumptionTotal energy used in the period
Usage valueUsage in billing units
CostAmount charged, in dollars
Tax amountsTax breakdown
Meter effective dateWhen the meter became active for this contract
tip

Billing line items, with every charge broken out, work best. If you can't export them, the fields above are enough. You can usually drop about 25% of the columns in a typical billing export.

Other data sets​

Data setDescriptionFrequency
Invoice detailsLine items (taxes, fees, riders). BillSense AI uses them to attribute each charge.Daily
Payment plansCustomers on payment arrangements or budget billingDaily
Account terminationClosed accounts, so EnergyGrid can delete their dataDaily, or as needed
Solar billing

Solar billing varies a lot between utilities. EnergyGrid supports net metering today and handles other solar structures case by case.

Step 5: Billing cycle schedule​

Billing cycles, also called the meter reading schedule or meter reading units (MRU), define the periods customers are billed for. The billingCycleId on each meter references this schedule.

Utilities stagger billing cycles to spread the processing load, often around 100,000 customers per cycle per day. A utility can have as few as 20 cycles or several thousand MRUs.

EnergyGrid needs the complete schedule to calculate the costs of each billing period.

Example: cycle 1 schedule for 2025​

Cycle IDStart dateEnd date
12024-12-032025-01-02
12025-01-032025-01-30
12025-01-312025-03-03
12025-03-042025-04-01
12025-04-022025-05-01
12025-05-022025-06-02
12025-06-032025-07-02
12025-07-032025-08-01
12025-08-022025-09-02
12025-09-032025-10-01
12025-10-022025-10-30
12025-10-312025-12-02
note

Cycle IDs can be alphanumeric, depending on your system.

Step 6: Rate information (required for BillSense AI)​

Required

Without rate information, BillSense AI can't calculate a bill. Projections won't match real bills, and customers call your support line to ask why.

The rateCode on each meter tells EnergyGrid which billing calculator to use. Send every rate code you offer for residential customers.

Meter rate codes​

Rate codeDescription
EFR_D1_8Residential Dynamic Peak Pricing, Exp. D1_8
EFR_D1-AResidential Time-of-Day Pilot I
EFR_D1-BResidential Time-of-Day Pilot II
EFR_D1.11Residential Service Rate, Standard Time-of-Use D1.11
EFR_D1.13Residential Service Rate, Overnight Savers

Supported rate types​

EnergyGrid supports three ways to calculate rates. Fixed costs (service and facility fees, taxes, and non-taxable program charges) apply on top of any of them.

Time of use (TOU)​

TOU rates need:

  • A schedule of observed holidays (generally treated as off-peak)
  • Peak intervals with start and end hours for each day type

Example: summer TOU schedule

NameAmount ($/kWh)Start hourEnd hourRate start dateRate end date
Off-peak M-F0.0479072025-06-012025-09-30
Mid-Peak M-F0.09227152025-06-012025-09-30
On-peak M-F0.166015192025-06-012025-09-30
Off-Peak M-F0.047923242025-06-012025-09-30
Off-Peak Wknd/Holiday0.04790242025-06-012025-09-30

EnergyGrid splits each day into intervals on a 24-hour clock. Weekends and holidays count as off-peak. The start and end dates define the summer period. Winter periods follow the same structure with different amounts, typically running from October 1 to May 31, then cycling back to summer rates.

Concurrent rates (delivery, energy waste reduction, distribution) can be rolled into the peak windows or evaluated separately.

Tiered​

Tiered rates use a prorate factor for the daily Tier 1 allowance. For example, with a factor of 22.1918 kWh a day, a 30-day billing period has a Tier 1 limit of about 665.75 kWh. Usage above that limit is priced at Tier 2 for the rest of the period. Delivery, distribution, and other charges still apply.

Flat​

One price per kWh for all usage.

Step 7: Hardware binding (optional)​

If your rollout includes the DataBridge Hub, the bind endpoint links the device to the customer's AMI meter over your wireless mesh radio.

Endpoint: POST /powerbox/bind

Binding uses a service account, not the customer's credentials. Each request carries a basic authentication header and, during the TLS 1.2 handshake, a client certificate for mutual TLS (mTLS) that EnergyGrid provides.

Request payload​

{
"hemProfileId": "a3f1c8d2-44bc-4e1a-b9f0-5c2e7d81a6b4",
"macAddress": "70:B3:D5:4A:1C:9E",
"installCode": "A1B2C3D4E5F6A7B8",
"meterId": "123456789",
"actionCode": 1
}
FieldDescription
hemProfileIdEnergyGrid customer profile ID (GUID)
macAddressMAC address on the DataBridge Hub label
installCodeInstall code on the same label
meterIdMeter to bind, from customer sync
actionCode1 to bind, 0 to release the meter

Response​

200 with no body means the request was accepted. Pairing finishes afterward, usually within 15 minutes and at most 48 hours.

Binding isn't idempotent. A second bind for the same meter returns 400:

{
"errorCode": "METER_ALREADY_BOUND",
"message": "Meter 123456789 is already bound. Send actionCode 0 to release it first."
}

For the other error codes, see Appendix A.

Step 8: Data transport options​

EnergyGrid can exchange bulk data in any of these ways:

MethodNotes
SFTPStandard method for MDM data
FTPLegacy option
Object-storage replicationBucket-to-bucket sync between your object store and EnergyGrid's
APIOn-demand backfill or real-time feeds
File exchangeA generic file drop

At the integration kickoff, agree on the method and on who hosts it, you or EnergyGrid.

Appendix A: Error codes​

HTTP statusError codeDescription
4011Invalid credentials. The customer does not have a utility account.
4012Invalid credentials. Two authentication attempts remaining.
4013Invalid credentials. One authentication attempt remaining.
4014Account is locked. The customer must contact the utility to remove the lock.
40186Account is closed, finaled, or no longer accessible. EnergyGrid might still have a record for it.
503NonePowerBox API outage or maintenance. The response has no body.
note

Error codes 2 to 4 apply only to existing utility customers.

Appendix B: Account status codes​

Status codeNameDescription
AActiveActive account
CCharge offAccount charged off
DActive service disconnectActive account with service disconnected
FFinalFinal account billing complete
LClosedClosed account with unpaid final bill
NNewActive new account
PPendingPending account with a future open date
SSoldSold receivables account
UFinal account funds dueFinal account with unclaimed funds
XFinal account still billedFinal account still receiving charges
ZCancelCancelled account
Was this page helpful?