{"openapi":"3.1.0","info":{"title":"werkfluss Datahub API","version":"1.8.0","summary":"Building consumption data, checked and consented per purpose.","description":"Preview. The sandbox answers every operation with synthetic data of the building Musterweg 8. Sandbox keys start with wf_test_."},"servers":[{"url":"https://api.werkfluss.app/v1","description":"Sandbox and production; the key decides"}],"tags":[{"name":"portfolio"},{"name":"mandates"},{"name":"deliveries"},{"name":"outcomes"}],"paths":{"/portfolio":{"get":{"operationId":"list-portfolio","tags":["portfolio"],"summary":"List the portfolio","description":"Returns the buildings your key holds a mandate for, with readiness and open signals.","security":[{"bearer":["portfolio:read"]}],"x-access-record":false,"x-since":"v1.0","parameters":[{"name":"lens","in":"query","required":false,"description":"View of the portfolio. Default: the role of your key.","schema":{"type":"string","enum":["advisor","installer","bank"],"description":""}},{"name":"readiness","in":"query","required":false,"description":"Only buildings in this state.","schema":{"type":"string","enum":["ready","partial","waiting"],"description":""}},{"name":"limit","in":"query","required":false,"description":"Page size, at most 100. Default: 50.","schema":{"type":"integer","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"ID of the building."},"name":{"type":"string","description":"Name of the building."},"mandate":{"type":"string","description":"ID of your mandate for it."},"readiness":{"type":"string","enum":["ready","partial","waiting"],"description":"ready, partial or waiting."},"signals":{"type":"array","items":{"type":"string"},"description":"Open signals of the building."}}}},"next":{"type":"string","description":"Cursor of the next page, or null."}}},"example":{"data":[{"id":"bld_Mw8","name":"Musterweg 8","mandate":"mnd_8Kq2","readiness":"ready","signals":["heat_high_unit_2_1"]}],"next":null}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/portfolio/summary":{"get":{"operationId":"get-portfolio-summary","tags":["portfolio"],"summary":"Summarise the portfolio","description":"Returns the counts behind the portfolio view: buildings by readiness and open signals.","security":[{"bearer":["portfolio:read"]}],"x-access-record":false,"x-since":"v1.2","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"buildings":{"type":"integer","description":"Buildings with a mandate."},"readiness":{"type":"object","properties":{},"additionalProperties":{"type":"integer","description":"Buildings per state."}},"signals":{"type":"integer","description":"Open signals in total."}}},"example":{"buildings":12,"readiness":{"ready":7,"partial":3,"waiting":2},"signals":3}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/buildings/{id}":{"get":{"operationId":"get-building","tags":["portfolio"],"summary":"Read a building","description":"Returns the master data of a building: units, meters and where the data comes from.","security":[{"bearer":["portfolio:read"]}],"x-access-record":false,"x-since":"v1.0","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the building, e.g. bld_Mw8","schema":{"type":"string","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the building."},"name":{"type":"string","description":"Name of the building."},"built":{"type":"integer","description":"Year of construction."},"units":{"type":"integer","description":"Flats and commercial units."},"meters":{"type":"integer","description":"Meters in the building."},"source":{"type":"string","enum":["sandbox","live"],"description":"sandbox or live."}}},"example":{"id":"bld_Mw8","name":"Musterweg 8","built":1972,"units":13,"meters":39,"source":"sandbox"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"building_not_found: No building with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mandates/{id}":{"get":{"operationId":"get-mandate","tags":["mandates"],"summary":"Read a mandate","description":"Returns purpose, period and state of a mandate, and which sections the owner has consented to.","security":[{"bearer":["mandates:read"]}],"x-access-record":false,"x-since":"v1.0","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the mandate, e.g. mnd_8Kq2","schema":{"type":"string","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the mandate."},"building":{"type":"string","description":"ID of the building."},"purpose":{"type":"string","enum":["isfp","offer","credit_review"],"description":"Purpose of the mandate: isfp, offer, credit_review."},"status":{"type":"string","enum":["requested","granted","expired","revoked"],"description":"requested, granted, expired or revoked."},"sections":{"type":"array","items":{"type":"string"},"description":"Sections the owner consented to."},"valid_until":{"type":"string","format":"date-time","description":"Last day of the consent."}}},"example":{"id":"mnd_8Kq2","building":"bld_Mw8","purpose":"isfp","status":"granted","sections":["heat_36m","power_common"],"valid_until":"2027-11-30"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"mandate_expired: The mandate has expired. consent_revoked: The consent was revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"mandate_not_found: No mandate with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mandates/{id}/package":{"get":{"operationId":"get-mandate-package","tags":["mandates"],"summary":"Read the package of a mandate","description":"Returns every consented section with its version and a link to its lineage. Locked sections appear with their status and without values.","security":[{"bearer":["packages:read"]}],"x-access-record":true,"x-since":"v1.0","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the mandate, e.g. mnd_8Kq2","schema":{"type":"string","description":""}},{"name":"sections","in":"query","required":false,"description":"Only these sections. Default: all consented ones.","schema":{"type":"array","items":{"type":"string"},"description":""}},{"name":"version","in":"query","required":false,"description":"A specific version. Default: the latest.","schema":{"type":"integer","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"building":{"type":"string","description":"Name of the building."},"purpose":{"type":"string","enum":["isfp","offer","credit_review"],"description":"Purpose of the mandate: isfp, offer, credit_review."},"version":{"type":"integer","description":"Version of the package."},"sections":{"type":"object","properties":{},"additionalProperties":{"type":"object","properties":{"kwh":{"type":"number","description":"Sum of the section."},"quality":{"type":"string","enum":["checked","estimated","partial"],"description":"checked, estimated or partial."},"status":{"type":"string","enum":["granted","requested","locked"],"description":"granted, requested, locked."}}}},"lineage":{"type":"string","format":"uri-reference","description":"Lineage per section."}}},"example":{"building":"Musterweg 8","purpose":"isfp","version":3,"sections":{"heat_36m":{"kwh":412000,"quality":"checked","status":"granted"},"power_common":{"kwh":9800,"quality":"checked","status":"granted"},"units":{"status":"locked"}},"lineage":"/v1/mandates/mnd_8Kq2/lineage"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"mandate_expired: The mandate has expired. consent_revoked: The consent was revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"mandate_not_found: No mandate with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mandates/{id}/lineage":{"get":{"operationId":"get-mandate-lineage","tags":["mandates"],"summary":"Read the lineage of a package","description":"Returns, per section, the sources, the checks that ran and what was estimated.","security":[{"bearer":["packages:read"]}],"x-access-record":true,"x-since":"v1.1","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the mandate, e.g. mnd_8Kq2","schema":{"type":"string","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"sections":{"type":"object","properties":{},"additionalProperties":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string"},"description":"Where the values come from."},"checks":{"type":"array","items":{"type":"string"},"description":"Checks that ran on the values."},"estimated":{"type":"array","items":{"type":"string"},"description":"Months that were estimated and are marked."},"version":{"type":"integer","description":"Version of the section."}}}}}},"example":{"sections":{"heat_36m":{"sources":["radio_meter","owner_portal"],"checks":["monotonic","weather_adjusted"],"estimated":["2025-03"],"version":3},"power_common":{"sources":["smart_meter_gateway"],"checks":["monotonic"],"estimated":[],"version":2}}}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"mandate_expired: The mandate has expired. consent_revoked: The consent was revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"mandate_not_found: No mandate with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mandates/{id}/access-requests":{"post":{"operationId":"request-access","tags":["mandates"],"summary":"Request access to a section","description":"Asks the owner to consent to a locked section. The answer arrives as a webhook.","security":[{"bearer":["mandates:write"]}],"x-access-record":true,"x-since":"v1.3","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the mandate, e.g. mnd_8Kq2","schema":{"type":"string","description":""}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"sections":{"type":"array","items":{"type":"string"},"description":"Sections you ask for."},"reason":{"type":"string","description":"What you need them for. The owner reads this."}},"required":["sections","reason"]},"example":{"sections":["units"],"reason":"Hydraulic balancing per flat"}}}},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the request."},"status":{"type":"string","enum":["requested"],"description":"Always requested."},"sections":{"type":"array","items":{"type":"string"},"description":"Sections asked for."}}},"example":{"id":"req_5Hd1","status":"requested","sections":["units"]}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"mandate_expired: The mandate has expired. consent_revoked: The consent was revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"mandate_not_found: No mandate with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mandates/{id}/deliverables":{"post":{"operationId":"return-deliverable","tags":["mandates"],"summary":"Return a deliverable","description":"Hands a report, an offer or a review back to the owner, who sees what came of the data.","security":[{"bearer":["deliverables:write"]}],"x-access-record":true,"x-since":"v1.4","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the mandate, e.g. mnd_8Kq2","schema":{"type":"string","description":""}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["report","offer","review"],"description":"report, offer or review."},"title":{"type":"string","description":"Title the owner sees."},"url":{"type":"string","format":"uri-reference","description":"Link to the document, if there is one."}},"required":["type","title"]},"example":{"type":"report","title":"iSFP Musterweg 8","url":"https://example.org/isfp-musterweg-8.pdf"}}}},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the deliverable."},"status":{"type":"string","enum":["received"],"description":"Always received."}}},"example":{"id":"res_9Pc4","status":"received"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"mandate_expired: The mandate has expired. consent_revoked: The consent was revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"mandate_not_found: No mandate with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deliveries":{"post":{"operationId":"send-delivery","tags":["deliveries"],"summary":"Send a delivery","description":"Takes meter readings for any number of sites. Accepted and rejected values come back in the same answer, each rejection with a fixed reason.","security":[{"bearer":["deliveries:write"]}],"x-access-record":false,"x-since":"v1.0","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"site_ref":{"type":"string","description":"Your ID of the site. Assigned once, then fixed."},"meter_id":{"type":"string","description":"Device ID of the meter, as on the type plate."},"readings":{"type":"array","items":{"type":"object","properties":{"at":{"type":"string","format":"date-time","description":"Time of the value in UTC."},"value":{"type":"number","description":"Meter reading. Must rise monotonically."},"unit":{"type":"string","enum":["kWh","m³","MWh"],"description":"kWh, m³ or MWh."}},"required":["at","value","unit"]}}},"required":["site_ref","meter_id"]},"example":{"site_ref":"FS-00412","meter_id":"7ED4-0193","readings":[{"at":"2026-11-01T00:00:00Z","value":18412.6,"unit":"kWh"}]}}}},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the delivery."},"accepted":{"type":"integer","description":"Values taken over."},"rejected":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"Position of the value in readings."},"reason":{"type":"string","enum":["reading_decreasing","meter_unknown","timestamp_future","unit_invalid"],"description":"Fixed code of the reason."}}}},"stored":{"type":"boolean","description":"false in the sandbox: values are checked, not kept."}}},"example":{"id":"dlv_3Tn7","accepted":1,"rejected":[],"stored":false}}}},"400":{"description":"body_invalid: The body is not valid JSON or a required field is missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"too_many_values: More than 10,000 values in one request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deliveries/{id}":{"get":{"operationId":"get-delivery","tags":["deliveries"],"summary":"Read the status of a delivery","description":"Returns how far a delivery has come: checked, versioned, partners notified.","security":[{"bearer":["deliveries:read"]}],"x-access-record":false,"x-since":"v1.0","parameters":[{"name":"id","in":"path","required":true,"description":"ID of the delivery, e.g. dlv_3Tn7","schema":{"type":"string","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the delivery."},"status":{"type":"string","enum":["received","checked","versioned","notified"],"description":"received, checked, versioned or notified."},"accepted":{"type":"integer","description":"Values taken over."},"rejected":{"type":"integer","description":"Values rejected."},"received_at":{"type":"string","format":"date-time","description":"When the delivery arrived."}}},"example":{"id":"dlv_3Tn7","status":"notified","accepted":412,"rejected":3,"received_at":"2026-11-25T06:02:11Z"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"delivery_not_found: No delivery with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/corrections":{"post":{"operationId":"send-correction","tags":["deliveries"],"summary":"Send a correction","description":"Corrects a value that was already delivered. Nothing is overwritten: a new version is created and the old one stays visible.","security":[{"bearer":["deliveries:write"]}],"x-access-record":false,"x-since":"v1.2","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"meter_id":{"type":"string","description":"Device ID of the meter."},"at":{"type":"string","format":"date-time","description":"Time of the value you correct."},"value":{"type":"number","description":"The correct reading."},"reason":{"type":"string","enum":["reading_error","meter_exchange","estimate_replaced"],"description":"reading_error, meter_exchange or estimate_replaced."}},"required":["meter_id","at","value","reason"]},"example":{"meter_id":"7ED4-0193","at":"2026-10-01T00:00:00Z","value":18102.4,"reason":"reading_error"}}}},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"ID of the correction."},"version":{"type":"integer","description":"New version of the series."},"previous_version":{"type":"integer","description":"Version that stays visible."},"stored":{"type":"boolean","description":"false in the sandbox."}}},"example":{"id":"cor_2Vx8","version":4,"previous_version":3,"stored":false}}}},"400":{"description":"body_invalid: The body is not valid JSON or a required field is missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/outcomes/{building}":{"get":{"operationId":"get-outcomes","tags":["outcomes"],"summary":"Read the outcome for a building","description":"Returns what changed after a measure: consumption before and after, adjusted for weather.","security":[{"bearer":["outcomes:read"]}],"x-access-record":true,"x-since":"v1.6","parameters":[{"name":"building","in":"path","required":true,"description":"ID of the building, e.g. bld_Mw8","schema":{"type":"string","description":""}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"building":{"type":"string","description":"ID of the building."},"measure":{"type":"string","description":"The measure that was carried out."},"before_kwh":{"type":"number","description":"Twelve months before, weather-adjusted."},"after_kwh":{"type":"number","description":"Twelve months after, weather-adjusted."},"change_percent":{"type":"number","description":"Change in percent."}}},"example":{"building":"bld_Mw8","measure":"hydraulic_balancing","before_kwh":141200,"after_kwh":124300,"change_percent":-12}}}},"401":{"description":"key_missing or key_invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"building_not_found: No building with this ID for your key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited: Too many requests. Honour Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{"mandate.approved":{"post":{"summary":"The owner consented to a mandate or a section.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}},"mandate.declined":{"post":{"summary":"The owner declined a request.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}},"mandate.revoked":{"post":{"summary":"The owner revoked a consent. Access ends at once.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}},"package.updated":{"post":{"summary":"A package has a new version.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}},"signal.raised":{"post":{"summary":"A building has a new signal.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}},"delivery.checked":{"post":{"summary":"A delivery was checked.","parameters":[{"name":"werkfluss-signature","in":"header","required":true,"schema":{"type":"string"},"description":"t=<unix time>,v1=<HMAC-SHA256 of \"t.body\" with your webhook secret>"}],"responses":{"200":{"description":"Received"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Authorization: Bearer <key>. Sandbox keys start with wf_test_, live keys with wf_live_."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}}}}