All guides

What webhooks are for

Banner illustration: a single white card on the left with three clay lines curving out of it to three tinted panels stacked on the right.

The difference between asking every five minutes and being told: the events Updocly emits, what a delivery contains, how to prove it came from us, and when a webhook is the wrong tool.

About 8 minutes to read and follow along.

A webhook is the arrangement where your system stops asking. Instead of calling Updocly to find out whether anything has happened, you give Updocly an address, and it sends a small JSON document to that address each time one of your envelopes changes state.

The alternative is polling: a job that calls the API every few minutes and works out what is new since last time. Polling works, and for some jobs it is the right answer. But it costs you a schedule, a memory of what you already handled, and a delay as long as the gap between calls. A delivery arrives within seconds and carries the change with it.

The events Updocly emits

There are seven. Six are envelope transitions: envelope.sent, envelope.viewed for the first time any recipient opens it, envelope.completed, envelope.declined, envelope.voided and envelope.expired. They fire once per transition rather than once per recipient, so a second person opening an envelope that has already been viewed delivers nothing.

The seventh is recipient.signed, and it covers a gap the other six leave. A three-party envelope emits nothing at all between sent and completed, so anything wanting to record each signature as it arrives could otherwise only poll. It fires once per signature, including the signature that completes the envelope, and its delivery names that signer alongside the usual envelope.

The Settings form lists the six envelope events as checkboxes. recipient.signed is subscribable through the API, and it is what the Zapier connector's "Document Signed" trigger listens to, but it has no checkbox on the settings form yet.

The Webhooks card in API settings: an endpoint URL field, six event checkboxes, and two endpoints below, one delivered and one with no deliveries yet.
Endpoints, the events they take, and how the last delivery went.

Adding an endpoint

  1. Settings, API tab, the Webhooks card. Paste the "Endpoint URL" and tick the events to deliver. As the hint says, https is required and http is allowed for localhost while you develop a receiver.
  2. Private and internal addresses are refused. An endpoint is an address Updocly's server will POST to on a schedule, and an unchecked one could be aimed at things a browser could never reach, cloud metadata services among them.
  3. "Add endpoint" shows the signing secret once, a string beginning whsec_. Unlike an API key you can reveal it here again later, because it has to stay usable: it signs every delivery.
  4. "Send test" queues a delivery through the real pipeline, signature and retries included, so a test that arrives proves the whole path rather than a lookalike of it. Its type is ping, which is a test knob and not something an endpoint can subscribe to.
  5. Each row then shows what happened last: delivered with a time, failing and retrying, or stopped.

What a delivery contains

The body is JSON with four keys: an id like evt_5f2c1a9d, a type like envelope.completed, a createdAt, and data. Inside data, envelope is exactly the shape GET /v1/envelopes/:id returns, so a receiver parses one shape whether it polled or was pushed. A recipient.signed delivery adds data.recipient with that signer's name, email, role, order and signing time.

Two headers carry the rest. X-Updocly-Event repeats the type, so a receiver can route before parsing, and X-Updocly-Signature carries the proof. Answer with any 2xx inside ten seconds; the response body is ignored.

The id is stable across retries, which makes it your idempotency key. Ignore a delivery whose id you have already processed, because the same event can genuinely arrive twice and a completion handled twice is an invoice raised twice.

Verifying the signature, and why it is not optional

Your endpoint is a public URL. Anyone who learns it can post a convincing envelope.completed at it, and if your system files paperwork or releases something on that event, that is the entire attack. The signature is what tells a delivery from Updocly apart from a delivery from anyone else.

The header reads t=1757067300,v1=5257a869 and so on. The v1 half is an HMAC-SHA256, keyed with your endpoint's secret, of the timestamp, a full stop, and the raw request body. Recompute it and compare: if it matches, the delivery is ours and nothing in it has been altered.

  1. Read the raw bytes of the body before any JSON parsing. Re-serializing a parsed object changes those bytes, and the signature then never matches.
  2. Compare the two values with a constant-time comparison rather than ordinary string equality.
  3. Reject a delivery whose t is far from your own clock. The timestamp is inside the signed material precisely so a captured delivery cannot be replayed later behind a fresh-looking header, and five minutes is a sensible bound.

docs/API.md in the repository carries a Node implementation with no dependencies, roughly fifteen lines. It is the same function the API tests its own signing against, so the two directions cannot drift.

Retries, and what happens when they run out

A delivery that does not get a 2xx, whether that is another status, a timeout, or a refused connection, is retried after 1 minute, 5 minutes, 30 minutes and 2 hours. Five attempts in all, spread across about two and a half hours: long enough to ride out a deploy, short enough that a dead endpoint is not still being retried tomorrow. After the last attempt the delivery is marked failed and is not tried again.

Deliveries are stored on the server, so restarting the API delays them rather than losing them. Order is not guaranteed once retries are involved: a completed event whose receiver was down can land after events that happened later, so where order matters, read createdAt rather than trusting arrival.

Answering 410 Gone means something different from failing. It is the receiver saying stop, and it deactivates the endpoint: no further deliveries for any event. It is the right answer when you tear a receiver down. The endpoint then sits in Settings with its URL struck through and "Receiver answered 410 Gone; deliveries stopped" underneath; bringing it back is a call to the API, or deleting the endpoint and adding it again.

What the application does not have yet is a per-delivery log. You see each endpoint's last delivery and its status, not the history, so a receiver that quietly answers 500 shows as failing rather than as a list of exactly what failed and when.

When a webhook is the wrong tool

If what you want is a message in Slack when a contract completes, you do not need to run a server for it. The Zapier and Make triggers subscribe to these same events underneath, so the automation is just as immediate and you host nothing. See "Connect Updocly to your CRM".

If you only need to know by the end of the day, or you are reconciling rather than reacting, read the API instead. GET /v1/envelopes walks the list by cursor without skipping a record or reading one twice, which page numbers cannot promise while new records are being created.

And if you cannot expose a public https address, this is not the route. Deliveries go to https on the public internet, plus localhost while you develop; there is nothing to aim at a laptop behind a firewall.

A webhook earns its keep when something has to happen promptly and reliably in a system you control: file the record, release the order, notify the finance queue. What you are taking on is a small server of your own, with a signature check, an idempotency check, and a 2xx you have to return inside ten seconds.

Keep going

How to write a business proposal

Updocly sets 2 strictly necessary cookies, used only to keep you signed in, and stores preferences and unsaved drafts in this browser's local storage.

Cookieless analytics only. No tracking, and no third-party cookies.