Webhooks
Webhook endpoints of the TOVR REST API. Endpoint object and its six operations, URL rules, the per-event scope rule, the delivery request and its headers, the HMAC-SHA256 signature with verification code, the retry ladder, disabling and re-enabling, and secret rotation.
A webhook endpoint receives each change-feed event of the types it
subscribes to as a signed HTTPS POST. Endpoints are managed through the API below or in
Settings → Developer → Webhook endpoints. Both manage the same endpoints.
| Endpoint | Scope | Idempotency-Key |
|---|---|---|
POST /api/v1/webhook_endpoints | webhooks:write | yes |
GET /api/v1/webhook_endpoints | webhooks:read | no |
GET /api/v1/webhook_endpoints/{id} | webhooks:read | no |
PATCH /api/v1/webhook_endpoints/{id} | webhooks:write | yes |
DELETE /api/v1/webhook_endpoints/{id} | webhooks:write | yes |
POST /api/v1/webhook_endpoints/{id}/rotate_secret | webhooks:write | yes |
{id} is the endpoint's whe_… id. A malformed id is 422 invalid_id.
The endpoint object
{
"object": "webhook_endpoint",
"id": "whe_4b8c1e2d-7f3a-4c5b-9e6d-0a1b2c3d4e5f",
"url": "https://hooks.example.com/tovr",
"description": "Shipment mirror, production",
"enabled_events": ["shipment.created", "shipment.updated", "shipment.unshared"],
"status": "active",
"signing_secret_hint": "whsec_…",
"created_at": "2026-11-06 09:20:41.007+00",
"last_success_at": "2026-11-16 07:42:11.512+00",
"last_failure_at": null,
"last_error_code": null,
"last_error_message": null,
"consecutive_failures": 0,
"disabled_at": null,
"disabled_reason": null
}| Field | Type | Notes |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_<uuid>. Sent on each delivery as tovr-webhook-id. |
url | string | See URL rules |
description | string | null | Up to 500 characters |
enabled_events | array | Event types delivered to this endpoint. At least one. |
status | active, disabled | |
signing_secret_hint | string | On the POST response, whsec_… and the last four characters of the secret. Every other response answers whsec_… alone. |
created_at | timestamp string | PostgreSQL text form, for example 2026-11-06 09:20:41.007+00, not RFC 3339. The same holds for every timestamp of this object. |
last_success_at, last_failure_at | timestamp string | null | |
last_error_code | string | null | For example http_500 (any non-2xx status, 3xx included, as http_<status>), transport, blocked_address, endpoint_gone, secret_unavailable |
last_error_message | string | null | A description of the failure. It does not contain your endpoint's response body. |
consecutive_failures | number | Deliveries in a row that used up all attempts |
disabled_at, disabled_reason | timestamp string | null, string | null | disabled_reason is consecutive_failures or endpoint_gone |
POST also returns secret. PATCH also returns replay_from.
Create an endpoint
POST /api/v1/webhook_endpoints
| Field | Required | Value |
|---|---|---|
url | yes | 12–2,048 characters. See URL rules. |
enabled_events | yes | One or more event types |
description | no | Up to 500 characters |
curl -X POST https://tovr.eu/api/v1/webhook_endpoints \
-H "Authorization: Bearer $TOVR_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"url": "https://hooks.example.com/tovr",
"description": "Shipment mirror, production",
"enabled_events": ["shipment.created", "shipment.updated", "shipment.unshared"]
}'The response is 201 with the endpoint object and secret, a whsec_… string. This is the only
response that contains the secret. A replay of the same request with the same Idempotency-Key
returns secret: null.
Scope rule
Each event type in enabled_events needs the read scope of its object, held by the token that
creates or changes the endpoint:
| Event types | Read scope |
|---|---|
shipment.* | shipments:read |
invoice.recorded | invoices:read |
chain.* | chains:read |
vehicle.availability.changed | vehicles:read |
match.created | matches:read |
quote.submitted | quotes:read |
outreach.logged | outreach:read |
A missing scope is 403 insufficient_scope. The rule is checked again at every delivery, against
the creating client application's scopes at that moment:
| At delivery time | Result |
|---|---|
| The client application no longer has the read scope | Deliveries of those event types are skipped (scope_revoked). Restoring the scope does not replay them. |
| The client application is deactivated | All its endpoints' deliveries are skipped (client_inactive) |
| The object is no longer visible to the organization | The delivery is skipped (no_longer_visible) |
Endpoints created in Settings → Developer belong to no client application and are not affected by the first two rows.
URL rules
| Rule | Refusal message |
|---|---|
https scheme | "The URL must use https." |
| Port 443 | "The URL must use port 443." |
| No user name or password in the URL | "The URL must not contain credentials." |
| A host name, not an IP address | "The URL must name a hostname, not an IP." |
Not localhost | "The URL must not point at localhost." |
| Resolves to a public address (no private, loopback or link-local range) | Names the host that could not be resolved to a public address |
A refused URL is 422 validation_failed, param: "url". The address is resolved again at each
delivery, and the delivery connects only to the address it resolved.
List and read endpoints
GET /api/v1/webhook_endpoints returns your organization's endpoints, newest first.
| Parameter | Default | Values |
|---|---|---|
limit | 50 | 1–100 |
The response is {object: "list", data, has_more}. There is no cursor parameter: an organization
with more than 100 endpoints cannot page past the first 100.
GET /api/v1/webhook_endpoints/{id} returns one endpoint, or 404.
Change an endpoint
PATCH /api/v1/webhook_endpoints/{id}
| Field | Value |
|---|---|
url | A new URL. The same URL rules apply. |
description | A string, or null to clear it |
enabled_events | The complete new list, at least one. It replaces the old list. |
status | "active" only, to re-enable a disabled endpoint |
Send at least one field. None of them changes the signing secret.
curl -X PATCH https://tovr.eu/api/v1/webhook_endpoints/whe_4b8c1e2d-7f3a-4c5b-9e6d-0a1b2c3d4e5f \
-H "Authorization: Bearer $TOVR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "status": "active" }'The response is the endpoint object plus replay_from. When the request sends
"status": "active" and the endpoint was disabled, replay_from is a change-feed cursor for the
moment it was disabled. Otherwise it is null.
Delete an endpoint
DELETE /api/v1/webhook_endpoints/{id} answers {"id": "whe_…", "deleted": true}. Deliveries
still queued for it are dropped.
Rotate the secret
POST /api/v1/webhook_endpoints/{id}/rotate_secret
| Field | Default | Values |
|---|---|---|
overlap_seconds | 86400 (24 h) | 0–604,800 (7 days). 0 retires the old secret at once. |
Send a JSON body. For the default overlap send {}; a request without a body is
422 validation_failed.
curl -X POST https://tovr.eu/api/v1/webhook_endpoints/whe_4b8c1e2d-7f3a-4c5b-9e6d-0a1b2c3d4e5f/rotate_secret \
-H "Authorization: Bearer $TOVR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "overlap_seconds": 86400 }'The response is 200 (the OpenAPI document says 201) with id, the new secret (shown once)
and previous_expires_at, an RFC 3339 time or null when overlap_seconds is 0. Until
previous_expires_at, each delivery is signed with both secrets. A replay with the same
Idempotency-Key returns secret: null. Rotating again while an overlap runs retires the older
secret at once.
The delivery request
TOVR sends each delivery as POST to the endpoint's URL with this body, one line, no trailing
newline:
{"object":"event","id":"aev_9c3f2b10-4d5e-4f6a-8b7c-1d2e3f4a5b6c","type":"shipment.updated","object_type":"shipment","object_id":"shp_7c2e5a90-3b1d-4f6e-9a4c-8d2b1e0f5a37"}The body is the event object without created.
| Header | Value |
|---|---|
content-type | application/json |
user-agent | TOVR-Webhooks/1.0 |
tovr-signature | t=<unix seconds>,v1=<hex>, with a second v1= during a rotation |
tovr-event-id | The event's aev_… id. Deduplicate on it. |
tovr-event-type | The event's type |
tovr-webhook-id | The endpoint's whe_… id. Use it to pick the secret. |
tovr-delivery-attempt | 1 to 7 |
Signature
| Part | Value |
|---|---|
| Signed string | `${t}.${rawBody}`: the timestamp, a full stop, and the body bytes as sent |
| Algorithm | HMAC-SHA256 |
| Key | The whole secret string, whsec_ included, as UTF-8 bytes. Do not decode it. |
| Encoding | Lower-case hex |
Several v1= | One per secret in use. Accept the delivery if any of them matches. |
| Replay window | Reject a delivery whose t is more than 300 s from your clock. t is inside the signed string, so it cannot be changed. |
Worked example
With the secret whsec_sandbox_example_do_not_use_0000000000000, t=1794814931
(2026-11-16 07:42:11 UTC) and the body above, the header is:
tovr-signature: t=1794814931,v1=a71291da8ce4dc60912510a2dad25fb85c4e6b7fdac221ec66926f2e7cc6b1b3Reproduce it:
SECRET='whsec_sandbox_example_do_not_use_0000000000000'
BODY='{"object":"event","id":"aev_9c3f2b10-4d5e-4f6a-8b7c-1d2e3f4a5b6c","type":"shipment.updated","object_type":"shipment","object_id":"shp_7c2e5a90-3b1d-4f6e-9a4c-8d2b1e0f5a37"}'
printf '%s' "1794814931.$BODY" | openssl dgst -sha256 -hmac "$SECRET"
# SHA2-256(stdin)= a71291da8ce4dc60912510a2dad25fb85c4e6b7fdac221ec66926f2e7cc6b1b3Node.js
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
// header: the tovr-signature header. rawBody: the body as received, before JSON parsing.
// secret: the whole whsec_… string.
export function verifyTovrSignature(header, rawBody, secret, now = Math.floor(Date.now() / 1000)) {
const parts = header.split(",").map((p) => p.trim());
const tPart = parts.find((p) => p.startsWith("t="));
if (!tPart) return false;
const t = Number(tPart.slice(2));
if (!Number.isFinite(t) || Math.abs(now - t) > TOLERANCE_SECONDS) return false;
const expected = Buffer.from(
createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex"),
"utf8",
);
return parts
.filter((p) => p.startsWith("v1="))
.some((p) => {
const actual = Buffer.from(p.slice(3), "utf8");
return actual.length === expected.length && timingSafeEqual(actual, expected);
});
}With Express, read this route's body raw: express.raw({ type: "application/json" }), then
req.body.toString("utf8"). A body parsed by express.json() and serialized again has different
bytes and never verifies. timingSafeEqual throws on inputs of different length, so keep the
length check.
Python
import hashlib
import hmac
import time
TOLERANCE_SECONDS = 300
def verify_tovr_signature(header: str, raw_body: bytes, secret: str, now: int | None = None) -> bool:
now = int(time.time()) if now is None else now
parts = [p.strip() for p in header.split(",")]
t_part = next((p for p in parts if p.startswith("t=")), None)
if t_part is None:
return False
try:
t = int(t_part[2:])
except ValueError:
return False
if abs(now - t) > TOLERANCE_SECONDS:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return any(
hmac.compare_digest(p[3:].encode(), expected.encode()) for p in parts if p.startswith("v1=")
)If every delivery fails verification, check the server clock first.
Delivery semantics
| Rule | Value |
|---|---|
| Guarantee | At least once. Deduplicate on tovr-event-id. |
| Order | None. An event tells you to refetch, and a refetch returns the current state. |
| Success | Any 2xx |
| Timeout | 10 s per attempt |
| Redirects | Not followed. A 3xx is a failure. |
410 Gone | Disables the endpoint at once (endpoint_gone). No further attempts. |
| Any other status, a timeout or a connection error | A failure. The next attempt follows the ladder below. |
| Attempt | Delay after the previous attempt |
|---|---|
| 1 | immediate |
| 2 | 30 s |
| 3 | 2 min |
| 4 | 10 min ± 10% |
| 5 | 1 h ± 10% |
| 6 | 6 h ± 10% |
| 7 | 24 h ± 10% |
After the 7th attempt, about 31 hours after the first, the delivery is abandoned. Five abandoned
deliveries in a row disable the endpoint (consecutive_failures). A success resets the count to
0. Delivery records are kept for 14 days.
Return a 2xx within 10 s and do the work after responding: put the event on a queue, then
refetch the object from there.
Disabled endpoints
| Disabled by | Events while disabled | On re-enable |
|---|---|---|
consecutive_failures | Held | Held events are delivered, oldest first, on the same ladder. Held deliveries older than 14 days are gone. |
endpoint_gone (a 410) | Not held | Delivery starts from the present |
To re-enable, send PATCH with {"status": "active"}, or select Re-enable in
Settings → Developer → Webhook endpoints. For any gap, page the change feed from the
replay_from cursor in the PATCH response, which reaches back 30 days:
curl "https://tovr.eu/api/v1/events?after=$REPLAY_FROM&limit=100" \
-H "Authorization: Bearer $TOVR_TOKEN"Events you already received have the same tovr-event-id and id, so drop the duplicates.
Change feed
The change feed of the TOVR REST API. GET /v1/events pages it with a cursor, GET /v1/events/stream pushes it as server-sent events, and webhooks POST it to your URL. Event object, event types, scopes, cursors, retention, stream frames and metering.
Factoring partners
The TOVR integration for factoring companies. One client application per consenting organization, the scopes, the invoice.recorded flow from webhook to refetch to catch-up, the limits that apply, and the indicative factoring offer TOVR shows carriers.