Webhooks
Thin, signed events for everything that happens to a document; fetch the object for the details.
Endpoints
curl https://api2.sendforsign.com/v2/webhook_endpoints \
-H "Authorization: Bearer $SENDFORSIGN_KEY" -H "Content-Type: application/json" \
-d '{ "url": "https://example.com/monoclan", "enabled_events": ["document.completed", "party.signed"] }'
The answer carries the endpoint's secret (whsec_…); it is shown once.
Events
document.created, document.updated, document.sent, document.viewed, document.completed, document.declined, document.voided, document.unsent, document.expired, document.content_updated, document.deleted, document.approved, party.notified, party.viewed, party.signed, party.declined, party.updated, party.reminded, party.delivery_failed, template.created, template.updated. Use ["*"] for all.
An event is thin: its type, the object it is about, and the time. Fetch the object for the current state, so an old event never overwrites newer data.
Verifying signatures
Each delivery has Sendforsign-Signature: t=<unix time>,v1=<hex>: an HMAC-SHA256 of <t>.<raw body> with the endpoint secret. Reject anything older than five minutes. With the SDK:
import { constructEvent } from '@monoclan/node';
const event = await constructEvent(rawBody, request.headers.get('sendforsign-signature'), process.env.WHSEC!);
Sendforsign-Event-Id and Sendforsign-Delivery-Id identify the event and the attempt; deduplicate on the event id.
Retries
Answer with a 2xx within ten seconds. Anything else is retried with growing delays for about three days. GET /v2/webhook_endpoints/{id}/deliveries lists attempts, and …/deliveries/{delivery}/retry sends one again.