TOVRReference

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.

EndpointScopeIdempotency-Key
POST /api/v1/webhook_endpointswebhooks:writeyes
GET /api/v1/webhook_endpointswebhooks:readno
GET /api/v1/webhook_endpoints/{id}webhooks:readno
PATCH /api/v1/webhook_endpoints/{id}webhooks:writeyes
DELETE /api/v1/webhook_endpoints/{id}webhooks:writeyes
POST /api/v1/webhook_endpoints/{id}/rotate_secretwebhooks:writeyes

{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
}
FieldTypeNotes
object"webhook_endpoint"
idstringwhe_<uuid>. Sent on each delivery as tovr-webhook-id.
urlstringSee URL rules
descriptionstring | nullUp to 500 characters
enabled_eventsarrayEvent types delivered to this endpoint. At least one.
statusactive, disabled
signing_secret_hintstringOn the POST response, whsec_… and the last four characters of the secret. Every other response answers whsec_… alone.
created_attimestamp stringPostgreSQL 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_attimestamp string | null
last_error_codestring | nullFor example http_500 (any non-2xx status, 3xx included, as http_<status>), transport, blocked_address, endpoint_gone, secret_unavailable
last_error_messagestring | nullA description of the failure. It does not contain your endpoint's response body.
consecutive_failuresnumberDeliveries in a row that used up all attempts
disabled_at, disabled_reasontimestamp string | null, string | nulldisabled_reason is consecutive_failures or endpoint_gone

POST also returns secret. PATCH also returns replay_from.

Create an endpoint

POST /api/v1/webhook_endpoints

FieldRequiredValue
urlyes12–2,048 characters. See URL rules.
enabled_eventsyesOne or more event types
descriptionnoUp 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 typesRead scope
shipment.*shipments:read
invoice.recordedinvoices:read
chain.*chains:read
vehicle.availability.changedvehicles:read
match.createdmatches:read
quote.submittedquotes:read
outreach.loggedoutreach: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 timeResult
The client application no longer has the read scopeDeliveries of those event types are skipped (scope_revoked). Restoring the scope does not replay them.
The client application is deactivatedAll its endpoints' deliveries are skipped (client_inactive)
The object is no longer visible to the organizationThe 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

RuleRefusal 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.

ParameterDefaultValues
limit501–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}

FieldValue
urlA new URL. The same URL rules apply.
descriptionA string, or null to clear it
enabled_eventsThe 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

FieldDefaultValues
overlap_seconds86400 (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.

HeaderValue
content-typeapplication/json
user-agentTOVR-Webhooks/1.0
tovr-signaturet=<unix seconds>,v1=<hex>, with a second v1= during a rotation
tovr-event-idThe event's aev_… id. Deduplicate on it.
tovr-event-typeThe event's type
tovr-webhook-idThe endpoint's whe_… id. Use it to pick the secret.
tovr-delivery-attempt1 to 7

Signature

PartValue
Signed string`${t}.${rawBody}`: the timestamp, a full stop, and the body bytes as sent
AlgorithmHMAC-SHA256
KeyThe whole secret string, whsec_ included, as UTF-8 bytes. Do not decode it.
EncodingLower-case hex
Several v1=One per secret in use. Accept the delivery if any of them matches.
Replay windowReject 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=a71291da8ce4dc60912510a2dad25fb85c4e6b7fdac221ec66926f2e7cc6b1b3

Reproduce 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)= a71291da8ce4dc60912510a2dad25fb85c4e6b7fdac221ec66926f2e7cc6b1b3

Node.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

RuleValue
GuaranteeAt least once. Deduplicate on tovr-event-id.
OrderNone. An event tells you to refetch, and a refetch returns the current state.
SuccessAny 2xx
Timeout10 s per attempt
RedirectsNot followed. A 3xx is a failure.
410 GoneDisables the endpoint at once (endpoint_gone). No further attempts.
Any other status, a timeout or a connection errorA failure. The next attempt follows the ladder below.
AttemptDelay after the previous attempt
1immediate
230 s
32 min
410 min ± 10%
51 h ± 10%
66 h ± 10%
724 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 byEvents while disabledOn re-enable
consecutive_failuresHeldHeld events are delivered, oldest first, on the same ladder. Held deliveries older than 14 days are gone.
endpoint_gone (a 410)Not heldDelivery 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.

On this page