Skip to content

Latest commit

 

History

History
377 lines (332 loc) · 18 KB

api-notes.md

File metadata and controls

377 lines (332 loc) · 18 KB

Zenner web API — discovery notes

Read-only reverse engineering of the Zenner (UAE) customer area, for zenner-cli. All values below are placeholders. Never paste real tokens, cookies or personal data here.

Overview

  • Base URL: https://myzenner.ae/online/

  • Stack: ASP.NET Core on IIS 10. Paths follow /{app}/{Controller}/{Action}[/{id}].

  • Format: all data endpoints return JSON (application/json; charset=utf-8).

  • Two serializer styles coexist:

    • camelCase, plain JSON (most endpoints).
    • PascalCase with $id / $values wrappers (GetTransactions): Newtonsoft.Json with reference preservation. Lists live under "$values".
  • Inconsistent types: amounts are floats in some endpoints and strings in others; IDs are ints in some and strings in others. The CLI normalizes everything.

  • Date formats seen (normalize all to ISO 8601 in the CLI):

    Where Format Example
    Balance / statements ISO 8601 local, no TZ, variable fraction 2026-11-10T12:05:51.272536, 2026-11-10T12:05:53.92
    Transactions, meter readings DD/MM/YYYY 10/11/2026
    Graph labels DD MonthName YY (English) 08 November 26
    Graph request param JS Date.toDateString() Sun Nov 15 2026

    Timestamps carry no timezone; assume Asia/Dubai (UTC+4). To confirm.

Auth & session

  • Cookies:
    • app_auth — auth cookie (ASP.NET Core cookie auth, custom name). The only thing required for GET requests (confirmed 2026-11-21). No other header needed.
    • .AspNetCore.Antiforgery.<suffix> — CSRF protection. Not needed for GET. Expected for POST (login), paired with a __RequestVerificationToken form field.
  • Unauthenticated → 302 (not 401) to https://myzenner.ae/online/Account/LogIn?ReturnUrl=<url-encoded original path>. → The CLI must NOT follow redirects; a 302 whose Location contains /Account/LogIn means "not logged in / session expired".
  • Session lifetime: a copied app_auth expired < ~52 min after first use (upper bound, creation time unknown) while Safari stayed logged in.
    • Hypothesis: sliding expiration (browser gets renewed cookie via Set-Cookie).
    • None of the 7 API responses probed carried Set-Cookie: app_auth with a fresh cookie. Consistent with ASP.NET Core's default: it only renews once more than half of the lifetime has elapsed. Still unconfirmed.
    • → The CLI must persist any renewed app_auth it receives, and detect expiry via the 302.
  • Login (partially captured 2026-11-21): classic HTML form post (ASP.NET MVC + jquery.validate.unobtrusive), not a JSON API.
    1. GET /online/Account/LogIn → HTML page with the form (and, presumably, a hidden __RequestVerificationToken + antiforgery cookie).
    2. POST /online/Account/LogIn, Content-Type: application/x-www-form-urlencoded → on success 302 with Location: https://myzenner.ae/online (and presumably Set-Cookie: app_auth=…).
    3. GET /online → dashboard.
    • Form (read from the public login HTML, 2026-11-21): <form id="account" method="post" action="/online/Account/LogIn"> with fields ReturnUrl (hidden), Email, Password, __RequestVerificationToken (hidden). No "remember me" field.
    • CLI login recipe (to implement and verify):
      1. GET /online/Account/LogIn with a cookie jar → keep the .AspNetCore.Antiforgery.* cookie and extract the hidden __RequestVerificationToken from the HTML. Cookie and token are a pair: both must come from the same GET.
      2. POST /online/Account/LogIn (form-urlencoded): ReturnUrl= (empty), Email, Password, __RequestVerificationToken. Do not follow redirects.
      3. Success = 302 to /online + Set-Cookie: app_auth=… → store app_auth in the keychain.
    • app_auth cookie after a login at 17:34:35 Dubai: expires 22/11/2026 17:34:35 → exactly 24 h after login (persistent cookie). ⚠️ Contradiction: an earlier copied cookie stopped working in < ~52 min. So the server may invalidate sessions before the cookie's own expiry (server-side check; main.js references /Identity/Login?message=Session). Unresolved. The CLI must rely on the 302 check, never on the cookie's expires.
    • Failure response (wrong password): TBD. Expected 200 re-rendering the login page. → CLI rule: success = 302 to /online + app_auth cookie received.
    • Request had Origin: null (caused by the site's Referrer-Policy: no-referrer).
    • Response Expires: Thu, 01 Jan 1970 is an HTTP cache-busting header, NOT the cookie expiry.
    • Login page also offers "Continue with Google / Apple" (OAuth). Out of scope for the CLI: we support email + password only.
  • Server headers: cache-control: no-cache,no-store. CSP mentions Stripe and Zendesk, plus a leftover http://localhost:61317 dev entry. Irrelevant for the CLI.

Endpoint inventory

All GET, under https://myzenner.ae/online/. Probed once each on 2026-11-21.

Path Params Status CLI use
Home/AccountBalance — 200 balance
Home/GetBalanceBreakdown — 200 balance (due date)
Home/RecentStatement — 200 bills (latest only)
Transactions/GetTransactions Offset? 200 history
Transactions/PendingTransactions — 404 from curl ?
MeterRead/GetProperties — 200 account info, propertyId
Home/AccountAddresses — 200 account info
AccountConsumption/GetConsumptionForProperty/<PROPERTY_ID> path id 200 consumption (readings)
AccountConsumption/GetConsumptionGraphData see below 200 consumption (daily)
locales/en-GB/account.json — not probed UI translations
Home/PaymentMethodsAvailable — not probed payment setup — not needed
Home/StripePaymentType — not probed payment setup — not needed
Payment/GetAccountIdStripePublicKey — not probed payment setup — not needed

Endpoints

Account balance

  • Path: GET /online/Home/AccountBalance
  • Shape:
    {
      "balance": -312.45,
      "balanceAsOfDateTime": "2026-11-10T12:05:51.272536",
      "totalPrepaymentBalance": 0,
      "prepaymentBalanceAsOfDateTime": null,
      "prepaymentHubBalances": [],
      "currency": "<3 letters>",
      "accountHasCreditHub": false,
      "accountHasPrepaymentHub": false
    }
  • Notes:
    • balance is a float. Sign convention (confirmed by user 2026-11-21): negative = amount owed by the customer. -312.45 = customer owes 312.45. Matches transactions: running balance goes negative after a statement. Positive would be credit in the customer's favour.
    • balanceAsOfDateTime equals the last statement date → balance is as of the last bill, not real time. The CLI must expose as_of.
    • currency: 3 letters, presumably AED.
    • Prepayment / "hub" fields are empty for this account. Ignore, but parse tolerantly.

Balance breakdown

  • Path: GET /online/Home/GetBalanceBreakdown
  • Shape:
    { "creditBalance": -312.45, "hubBalances": [], "latestBillDueDate": "2026-11-24T00:00:00" }
  • Notes: creditBalance = AccountBalance.balance. latestBillDueDate is the due date of the latest bill.

Recent statement

  • Path: GET /online/Home/RecentStatement
  • Shape: list with one item (latest statement only):
    [ { "id": 2000002, "statementNo": "<10 digits>", "statementDate": "2026-11-10T12:05:53.92" } ]
  • Notes: id (int) is probably what a PDF download uses. Full bills list and PDF download not captured yet.

Transactions

  • Path: GET /online/Transactions/GetTransactions
  • Shape (PascalCase + $values):
    {
      "$id": "1",
      "AccountName": "<NAME>",
      "AccountNumber": "<LETTERS+DIGITS>",
      "CurrencySymbol": "<3 letters>",
      "Offset": 0,
      "TransactionsRows": {
        "$id": "2",
        "Transactions": {
          "$id": "3",
          "$values": [
            {
              "$id": "4",
              "OrderId": "<e.g. N/A>",
              "Type": "<e.g. Statement | Payment>",
              "Date": "10/11/2026",
              "DebitAmount": "999.99",
              "CreditAmount": "9.99",
              "CurrencyType": null,
              "RunningBalance": "-999.99",
              "GrossAmount": "-999.99",
              "Description": "<text>"
            }
          ]
        },
        "CurrencySymbol": "<3 letters>",
        "Offset": 0
      }
    }
  • Notes:
    • 6 transactions returned, newest first, roughly the last few months.
    • Amounts are strings with 2 decimals, may be negative. Parse with Decimal, not float.
    • Type masked lengths fit Statement (9) and Payment (7). To confirm.
    • Both DebitAmount and CreditAmount can be non-zero in the same row. Meaning of Debit / Credit / Gross / Running TBD (compare with the UI).
    • Offset suggests paging. "Load more" request not captured yet.

Pending transactions

  • Path: GET /online/Transactions/PendingTransactions
  • Returns 404 to curl. Does the browser get 404 too (dead endpoint) or does it need something else?

Properties

  • Path: GET /online/MeterRead/GetProperties
  • Shape:
    {
      "properties": [ { "disabled": false, "group": null, "selected": false,
                        "text": "<street>, <unit>", "value": "<PROPERTY_ID>" } ],
      "meterList":  [ { "disabled": false, "group": null, "selected": false,
                        "text": "<8 letters, e.g. Chilling>", "value": "<5 digits>" } ],
      "selectedMeter": 0,
      "selectedProperty": 0,
      "accountName": "<NAME>",
      "accountNumber": "<LETTERS+DIGITS>",
      "returnStatus": null,
      "success": false,
      "reading": null,
      "selectedEnergyType": null,
      "meterSerial": "<8 digits>"
    }
  • Notes:
    • properties / meterList are ASP.NET SelectListItem dropdown options. IDs are strings here.
    • meterList[].value is NOT the supplyId (22222 was not found here). It is a different meter ID.
    • Useful for account info: accountName, accountNumber, property label, meter serial.
    • success: false on a 200 response, apparently meaningless. Do not rely on it.

Account addresses

  • Path: GET /online/Home/AccountAddresses
  • Shape: array of arrays of strings, positional, no keys: [ ["<street>", "<city>", "<postal code>"] ]
  • Notes: postal code is a 1-digit filler (the UAE has no real postal codes). Positional format is fragile: validate length and fail loudly.

Consumption: readings table

  • Path: GET /online/AccountConsumption/GetConsumptionForProperty/<PROPERTY_ID>
  • Shape:
    {
      "supplyTypeConsumptionRows": [
        { "supplyPointId": 0, "supplyName": "Chilling",
          "consumptionReadings": [
            { "date": "19/11/2026", "reading": "<5 digits>", "type": "Automatic Meter Read",
              "meterSerialNumber": "<8 digits>", "unit": "kWh" } ] } ],
      "selectedGraphTimeInterval": 1,
      "graphTimeIntervals": null
    }
  • Notes:
    • 1 supply (Chilling = district cooling, kWh), 30 readings, newest first.
    • reading is a cumulative meter index as a string. Consumption = difference between readings.
    • type: only Automatic Meter Read seen. Treat as an open string.
    • Exact duplicate rows exist (18/11 twice, same value). Latest reading 19/11 while today is 21/11 → reporting delay or date shift. Unresolved.
    • supplyPointId is the supplyId for the graph endpoint (name mismatch!).

Consumption: graph

  • Path: GET /online/AccountConsumption/GetConsumptionGraphData?propertyId=<PROPERTY_ID>&supplyId=<SUPPLY_ID>&graphTimeInterval=1&timeDirection=past&skipInterval=true&startDate=Sun%20Nov%2015%202026 (prev-arrow request; the initial request was captured without the last three params)
  • Shape:
    { "dataToDisplay": { "data": [42.0], "timeUnit": ["08 November 26"] },
      "atPresent": false, "atStart": false }
  • Notes:
    • data / timeUnit are parallel arrays = daily consumption already computed.
    • Window for startDate=Sun Nov 15, past: 08–12 and 15 Nov. 13–14 missing (gaps, not zeros). The CLI must not invent zeros.
    • One cross-check suggests a day's consumption is assigned to the start day (15 Nov = reading(16/11) − reading(15/11)). Needs more points.
    • atPresent / atStart are likely "no newer / no older data" → stop condition for paging.
    • graphTimeInterval: 1 = Daily. Other values (weekly/monthly?) not captured.

Static analysis of main.js (2026-11-21)

Public bundle at /online/jsdist/main.js (~1 MB, Vue app). Endpoints found that we had not seen:

  • Paginated tables (component VuePagTable): request GET {url}?offset={(page-1)*pageSize}&pageSize={10|20|30}, response envelope { "isSuccess": bool, "data": { "list": [...], "total": int } }. Used by:
    • /Statements/GetStatements → bills list. Row fields: reference (statement no.), billFromDate, billToDate, generationDate, grossAmount, hasBeenCredited, billSummaryId.
    • /Statements/GetCreditNotes → credit notes (same table style).
    • /Transactions/ViewMoreTransactions → full transaction history (paged).
    • /Correspondence/GetCorrespondence → letters/documents.
  • Bill PDF: GET /online/Statements/DownloadStatement?statementId={billSummaryId} → PDF blob.
  • /Transactions/GetAccountCurrency → { data: { currency } }.
  • /AccountSettings/GetAccountContactDetails, /AccountSettings/GetAccountProperties, /AccountSettings/GetPropertyAddress → account info (not probed).
  • /MeterRead/GetMetersFromProperty/{propertyId}, /MeterRead/GetMeterSerial/{id}, /MeterRead/GetReading/{id} → meter-read page (submitting readings is a write: out of scope).
  • Graph: timeDirection=future also exists; initial graph call is just graphTimeInterval=N.
  • Do not call: /Payment/GoCardlessMandateStartFlow, /Payment/NetworkPaymentSetup (start payment flows), /Language/SetLanguage (changes account settings).

Probed from main.js findings (2026-11-21, cookie from keychain)

Common envelope for the newer endpoints: { "isSuccess": bool, "errorMessage": str|null, "errorCode": int, "data": {...} } → the CLI must check isSuccess even on HTTP 200.

GET /online/Statements/GetStatements?offset=0&pageSize=10 → bills list:

{ "isSuccess": true, "errorMessage": null, "errorCode": 0,
  "data": {
    "list": [ {
      "statementId": null,
      "billSummaryId": 2000002,
      "reference": "<10 digits>",
      "billType": "<9 letters>",
      "billFromDate": "2026-10-01T00:00:00",
      "billToDate": "2026-10-31T00:00:00",
      "generationDate": "2026-11-10T08:22:14.3014561",
      "publishedDate": "2026-11-10T12:05:51.4766667",
      "netAmount": 0, "vatAmount": 0,
      "grossAmount": "999.99",
      "hasBeenCredited": false,
      "canBeReversed": true } ],
    "currency": "<3 letters>",
    "total": 2 } }
  • 2 bills in total: a short first period (28–30 Sep) and October.
  • billSummaryId = RecentStatement[].id = statementId param of DownloadStatement.
  • grossAmount is a string; netAmount / vatAmount are 0 ints → unreliable, do not expose.
  • statementId is null: the real ID is billSummaryId.
  • canBeReversed relates to payment/dispute actions: ignore.

GET /online/Transactions/ViewMoreTransactions?offset=0&pageSize=10 → same 6 rows as GetTransactions, but clean camelCase inside the standard envelope, with paging info (total, currentPage, itemsPerPage). Prefer this over GetTransactions.

GET /online/Transactions/GetAccountCurrency → { ..., "data": { "currency": "<3 letters>" } }.

Payments (discovery only — scope changed by user 2026-11-21 to explore a pay command)

GET /online/Home/PaymentMethodsAvailable (read-only) → which payment provider the account uses:

{ "isSuccess": true, "errorMessage": null, "errorCode": 0,
  "data": {
    "hasStripeAccount": false,
    "hasNetworkSolutionsAccount": true,
    "hasGoCardLessAccount": false,
    "hasGoCardlessMandate": false,
    "hasPaypointUrl": false,
    "paypointUrl": null,
    "clientName": "<operator / building company>",
    "contactEmail": "<support email>",
    "noPaymentProviderMessage": "<text>" } }
  • Our account pays through Network International ("Network Solutions"), a UAE card gateway. Not Stripe, no GoCardless → direct debit is not offered to this account (explains why the user never saw it).
  • Provider is per account/operator → a generic CLI must detect it, not assume it.
  • Web code: Network → showNetworkModal() → presumably POST/GET /Payment/NetworkPaymentSetup, which likely returns a hosted payment page URL. GoCardless → GET /Payment/GoCardlessMandateStartFlow → { success, redirectUrl }. Paypoint → opens paypointUrl.
  • NetworkPaymentSetup not called yet. It probably creates a payment order (a write). To be observed in Safari during a real payment.

GET /online/Home/StripePaymentType → { hasCreditHub, hasPaygHub, hasHub }, all false.

⚠️ Both responses carried Set-Cookie: app_auth=… (renews_cookie: true): first observed cookie renewal. Supports the sliding-expiration hypothesis → the CLI must persist renewed cookies.

Dependency chains

  • Consumption: GetProperties → properties[i].value (propertyId) → GetConsumptionForProperty/{propertyId} → supplyTypeConsumptionRows[j].supplyPointId (supplyId) → GetConsumptionGraphData?propertyId=…&supplyId=…
  • Balance, statements, transactions: no IDs needed. The account comes from the cookie.

Still open (phase 1 closed 2026-11-21)

  • Login failure response (wrong password): verify once in phase 3, carefully (lockout risk).
  • Why a valid-looking session died in < 1 h while the cookie says 24 h.
  • Meaning of debitAmount / creditAmount / grossAmount / runningBalance per row.
  • PendingTransactions returns 404 to curl (the web calls it; low priority).
  • Graph dropdown values ↔ graphTimeInterval; missing days; day-assignment convention.
  • Timezone of timestamps (assumed Asia/Dubai).