Webhooks
Instead of asking the API every few minutes whether anything changed, let Canoprise tell you: a signed POST to your address within a minute or two of the change.
Setting one up
A group administrator adds a webhook in Group settings, under Apps and AI tools, Webhooks: an https:// address and the events it wants. A group can have up to 10. Each has its own signing secret, starting whsec_, shown to whoever added it for ten minutes and never again: keep it with the receiver. Lost it? Delete the webhook and add it again.
Send a test on the same page sends a ping event straight away; every attempt, with the answer your server gave, is listed under the webhook.
Events
| Type | When |
|---|---|
data_point.saved | A value was submitted: on the website, from a file, the phone app, the API, a survey or an approved policy. Drafts are not sent. A value held for checking (far from the usual figure) is SUBMITTED with `held` true; when someone confirms it, it is sent again with `held` false. A value changed in place (an amendment, a file or survey replacing it, a policy approval turning a No into a Yes) is sent again with `amended` true and its status as it now stands. |
data_point.reviewed | A submitted value was marked as reviewed by someone who may review values. |
task.created | A task was created by a person: on the website (also from a plan action or a survey follow-up), through the API or an AI tool, or as the next of a repeating task. Tasks Canoprise gives administrators itself are not sent. |
task.done | A task was marked done. Reopening a task sends nothing. |
policy.approved | A version of a policy, or of a property's addendum to one, was approved. |
period.locked | A group administrator set the reporting lock: values for periods ending on or before `lockedThrough` can no longer be changed, except by an administrator with a reason. |
import.staged | A file was uploaded, or a scheduled connection read its figures, and they wait for a person to check and save them. Nothing is saved yet: each value saved later sends its own `data_point.saved`. |
Events are for the subscription's own group only, and carry ids and what changed, nothing a group administrator's token could not read. To know more, read it through the API by its id. Events are not sent in a guaranteed order: use the times in them, or read the current state.
What is sent
A POST with a JSON body of at most 64 KB: the event's id, type, createdAt and its data. Every field of data is always there, null when empty.
POST /canoprise HTTP/1.1
Content-Type: application/json
User-Agent: Canoprise-Webhooks/1
Canoprise-Event-Id: 3f2e1d0c-9b8a-4765-a4b3-c2d1e0f9a8b7
Canoprise-Event-Type: data_point.saved
Canoprise-Signature: t=1764411300,v1=b63bc23c62825b7b1457eaa877d08b75f2765ce16fcc5b32e17601bc7efbb647{
"id": "3f2e1d0c-9b8a-4765-a4b3-c2d1e0f9a8b7",
"type": "data_point.saved",
"createdAt": "2026-11-29T10:15:00.000Z",
"data": {
"dataPointId": "9b7e1c20-4f3a-4d8e-b6a1-2c3d4e5f6a7b",
"propertyId": "5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f",
"measure": "ENV-01",
"point": 1,
"meterId": "3e1430e1-e9b1-4c4d-ac85-c43085a1b2c3",
"periodStart": "2026-10-01",
"periodEnd": "2026-11-01",
"value": 41250,
"unit": "kWh",
"status": "SUBMITTED",
"held": false,
"amended": false,
"importId": null
}
}{
"dataPointId": "9b7e1c20-4f3a-4d8e-b6a1-2c3d4e5f6a7b",
"propertyId": "5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f",
"measure": "ENV-01",
"point": 1,
"meterId": "3e1430e1-e9b1-4c4d-ac85-c43085a1b2c3",
"periodStart": "2026-10-01",
"periodEnd": "2026-11-01",
"status": "REVIEWED",
"reviewedBy": "u_7f3a9c"
}{
"taskId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
"propertyId": "5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f",
"title": "Read the main electricity meter",
"assigneeId": "u_7f3a9c",
"createdBy": "u_2b8e1d",
"dueDate": "2026-12-15",
"repeat": "NONE",
"status": "OPEN",
"measure": "ENV-01"
}{
"taskId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
"propertyId": "5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f",
"doneAt": "2026-11-29T10:15:00.000Z",
"doneBy": "u_7f3a9c"
}{
"policyId": "0d4c2b1a-7e6f-4a5b-9c8d-1e2f3a4b5c6d",
"kind": "environment",
"addendumId": null,
"propertyId": null,
"versionId": "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d",
"version": 3,
"approvedAt": "2026-11-29T10:15:00.000Z",
"approvedBy": "u_7f3a9c"
}{
"lockedThrough": "2026-09-30",
"reason": "Q3 report submitted",
"setBy": "u_7f3a9c"
}{
"importId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
"propertyId": "5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f",
"source": "connection",
"fileName": "Xero 2026 purchases.json",
"rows": 42,
"uploadedBy": "u_7f3a9c",
"connectionId": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a8b",
"period": "2025"
}Every event, with its schema, is also in the webhooks section of the OpenAPI description.
Checking the signature
Canoprise-Signature is t=<unix seconds>,v1=<signature>, where the signature is the hex HMAC-SHA256, keyed with your signing secret, of the time, a full stop and the raw body: `${t}.${body}`. Work it out over the bytes exactly as they arrived, before any JSON parsing, compare in constant time, and refuse a time more than five minutes from yours. A retry is signed again with its own time.
import crypto from "node:crypto";
import express from "express";
const SECRET = process.env["CANOPRISE_WEBHOOK_SECRET"]; // whsec_…, shown once when the webhook was added
/** True when the header was made from this exact body with your secret, less than five minutes ago. */
function verify(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(String(header ?? "").split(",").map((p) => p.split("=", 2)));
const t = Number(parts.t);
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const given = Buffer.from(parts.v1 ?? "", "hex"), wanted = Buffer.from(expected, "hex");
return given.length === wanted.length && crypto.timingSafeEqual(given, wanted);
}
const app = express();
// the raw body: the signature is over the bytes as sent, not over JSON parsed and written again
app.post("/canoprise", express.raw({ type: "application/json" }), (req, res) => {
if (!verify(req.body.toString("utf8"), req.get("Canoprise-Signature"), SECRET)) return res.sendStatus(400);
const event = JSON.parse(req.body.toString("utf8"));
res.sendStatus(204); // answer first, then work: you have 10 seconds
handle(event); // de-duplicate on event.id: the same event can come more than once
});
app.listen(3000);import hashlib, hmac, json, os, time
from flask import Flask, request
SECRET = os.environ["CANOPRISE_WEBHOOK_SECRET"] # whsec_…, shown once when the webhook was added
app = Flask(__name__)
def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
"""True when the header was made from this exact body with your secret, less than five minutes ago."""
parts = dict(p.split("=", 1) for p in (header or "").split(",") if "=" in p)
try:
t = int(parts["t"])
except (KeyError, ValueError):
return False
if abs(time.time() - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
@app.post("/canoprise")
def canoprise():
raw = request.get_data() # the bytes as sent, before any parsing
if not verify(raw, request.headers.get("Canoprise-Signature", ""), SECRET):
return "", 400
event = json.loads(raw)
handle(event) # de-duplicate on event["id"]: the same event can come more than once
return "", 204To test your check: with the secret whsec_example, the time 1764411300 and this body (one line, exactly as below), the signature is b63bc23c62825b7b1457eaa877d08b75f2765ce16fcc5b32e17601bc7efbb647. If yours differs, check that you sign the raw body and use the whole secret, whsec_ included. (Turn the time check off for this test: the time is in the past.)
{"id":"3f2e1d0c-9b8a-4765-a4b3-c2d1e0f9a8b7","type":"data_point.saved","createdAt":"2026-11-29T10:15:00.000Z","data":{"dataPointId":"9b7e1c20-4f3a-4d8e-b6a1-2c3d4e5f6a7b","propertyId":"5f0c2a3e-8d1b-4c7a-9e2f-1a2b3c4d5e6f","measure":"ENV-01","point":1,"meterId":"3e1430e1-e9b1-4c4d-ac85-c43085a1b2c3","periodStart":"2026-10-01","periodEnd":"2026-11-01","value":41250,"unit":"kWh","status":"SUBMITTED","held":false,"amended":false,"importId":null}}Answers and retries
Answer with any 2xx within 10 seconds and the event is delivered. Anything else is a failure: another status, no answer in time, a connection that fails, and a redirect, which is not followed. An event that can never be sent (larger than the limit, or a signing secret that can no longer be read) fails once and is not tried again. Delivery is at least once: an event can arrive more than once, with the same id and Canoprise-Event-Id, so de-duplicate on it.
| Attempt | After a failure, the next comes |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 6 hours |
| 6 and later | every 6 hours, the last one 24 hours after the first |
That is nine attempts over 24 hours, each signed and timed from its own moment of sending. Up to five attempts to one address are made each minute, so a backlog drains over several minutes. Answer quickly and do the work afterwards; a slow receiver times out and is sent the event again.
Pausing
When an event has failed for 24 hours, the webhook is paused: nothing new is queued for it, and whoever added it (or, if they have left the group, a group administrator) is given a task in Canoprise. Fix the receiver, use Send a test (a test goes even to a paused webhook), then Resume. Events from while it was paused are not sent later: catch up with updatedSince on GET /data-points. An administrator can also pause a webhook by hand; it then queues nothing until resumed.
Addresses Canoprise sends to
- Only
https://, with a valid certificate for the host name, and no user name or password in the address. - On every attempt the host name is looked up, and every address it gives must be on the public internet: private, loopback, link-local, carrier-grade NAT, multicast, cloud-metadata and local IPv6 (
fc00::/7,fe80::/10) addresses are refused, and the attempt fails without anything being sent. The connection is then made to the address that was checked. - Redirects are not followed, and a body over 64 KB is not sent.
So a receiver on localhost or inside a private network cannot be reached directly: use a public tunnel while developing.