Webhooks
The server posts an event to your webhook URLs when something happens to an envelope, so your backend never has to poll. Each event is one audit action; a target subscribes to the actions it wants, or * for all.
Webhook targets are set in the server options, or in workspace settings on the cloud. The webhooks guide covers setting them up and testing them.
Event types
envelope.createdenvelope.updatedenvelope.sentenvelope.completedenvelope.declinedenvelope.expiredenvelope.voidedrecipient.notifiedrecipient.remindedrecipient.viewedrecipient.authenticatedrecipient.signedrecipient.approvedrecipient.declinedrecipient.link_sharedrecipient.correctedrecipient.esign_startedrecipient.esign_failedrecipient.esign_name_differsenvelope.recalledenvelope.reviseddocument.sealed
Verify a delivery
Every delivery is signed with the secret of its target. Check the signature before you trust the body:
- Read the raw body exactly as received. Do not parse and re-serialise it first.
- Split
x-codevibe-signatureintot(unix seconds) andv1(hex). - Compute HMAC-SHA256 of
<t>.<raw body>with the secret, and compare it withv1in constant time. - Reject the delivery when
tis more than five minutes from your clock, so a captured request cannot be replayed.
Answer with a 2xx within 10 seconds and do the work afterwards. A delivery that fails is retried with the same id, so drop ids you have already handled.
import { createServer } from 'node:http';
import { readWebhook, SignApiError } from '@codevibe_technology/sign-client';
const secret = process.env.SIGN_WEBHOOK_SECRET!;
createServer(async (req, res) => {
const chunks: Buffer[] = [];
for await (const chunk of req) chunks.push(chunk as Buffer);
const rawBody = Buffer.concat(chunks).toString('utf8');
try {
const delivery = await readWebhook(secret, req.headers['x-codevibe-signature'], rawBody);
res.writeHead(204).end();
if (delivery.type === 'envelope.completed') {
console.log('completed', delivery.data.envelope.id);
}
} catch (error) {
res.writeHead(error instanceof SignApiError ? 401 : 500).end();
}
}).listen(4000);import hashlib
import hmac
import time
def verify_webhook(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> bool:
parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
timestamp, signature = parts.get("t", ""), parts.get("v1", "")
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > tolerance:
return False
signed = timestamp.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)package webhooks
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"math"
"strconv"
"strings"
"time"
)
func VerifyWebhook(secret, header string, rawBody []byte, tolerance time.Duration) bool {
var timestamp, signature string
for _, part := range strings.Split(header, ",") {
key, value, _ := strings.Cut(part, "=")
switch key {
case "t":
timestamp = value
case "v1":
signature = value
}
}
seconds, err := strconv.ParseInt(timestamp, 10, 64)
if err != nil || math.Abs(time.Since(time.Unix(seconds, 0)).Seconds()) > tolerance.Seconds() {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(timestamp + "."))
mac.Write(rawBody)
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(expected), []byte(signature))
}Envelope event
POSTyour webhook URL
Sent to each configured webhook URL for the audit actions it subscribes to (* for all), one delivery per action. The body is fixed when the event happens, so a retry delivers the same bytes with the same id. Failed deliveries (no 2xx within 10 s) are retried with backoff, from 30 seconds up to 12 hours, nine attempts in all.
Verify each delivery before trusting it: the x-codevibe-signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> with the target's secret. Reject it when the HMAC does not match or t is more than five minutes old. verifyWebhook(secret, header, rawBody) from the server or client package does this.
Headers
x-codevibe-signature string Required
t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">.
Matches ^t=\d+,v1=[0-9a-f]{64}$
x-codevibe-delivery string Required
The delivery id, the same as id in the body. Use it to drop duplicates.
user-agent string Required
Always codevibe-sign-webhooks
Body
id string
The delivery id; the same on every retry.
type string
One of envelope.created envelope.updated envelope.sent envelope.completed envelope.declined envelope.expired envelope.voided recipient.notified recipient.reminded recipient.viewed recipient.authenticated recipient.signed recipient.approved recipient.declined recipient.link_shared recipient.corrected recipient.esign_started recipient.esign_failed recipient.esign_name_differs envelope.recalled envelope.revised document.sealed
createdAt string (date-time)
data object
Attributes of data
envelope object
Attributes of envelope
id string
Not empty
title string
status string
completed, declined, expired and voided are final.
One of draft sent in_progress completed declined expired voided
metadata map
Your own data, for example an employee id. Echoed in webhooks.
completedAt string (date-time) or null
recipients array of objects
Attributes of recipients
id string
Not empty
name string
email string or null
role string
Signers fill fields, approvers approve without fields, viewers get a copy.
One of signer approver viewer
status string
One of pending notified viewed signed approved declined
actedAt string (date-time) or null
{
"id": "5a7e3c1d-8b2f-4d6a-9e0c-1f4b7a2d3e58",
"type": "envelope.completed",
"createdAt": "2026-03-02T09:14:31.000Z",
"data": {
"envelope": {
"id": "7f3c9a2e-5b1d-4e8a-9c6f-2d4b8e1a0c37",
"title": "Offer letter",
"status": "completed",
"metadata": {
"employeeId": "E-1042"
},
"completedAt": "2026-03-02T09:14:31.000Z",
"recipients": [
{
"id": "c4a1d9e2-7f3b-4c8d-a6e5-0b9f2d1c7e83",
"name": "Asha Rao",
"email": "asha@example.com",
"role": "signer",
"status": "signed",
"actedAt": "2026-03-02T09:12:05.000Z"
}
]
}
}
}Test event
POSTyour webhook URL
Sent when someone asks for a test delivery, for example with "Send test event" in the app, to check that the receiver is reachable and verifies signatures. It is signed and carries the same headers as an envelope event, but has no envelope and is never retried. Answer it like any other delivery.
Headers
x-codevibe-signature string Required
t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">.
Matches ^t=\d+,v1=[0-9a-f]{64}$
x-codevibe-delivery string Required
The delivery id, the same as id in the body.
user-agent string Required
Always codevibe-sign-webhooks
Body
id string
The delivery id.
type string
Always webhook.test
createdAt string (date-time)
data object
Attributes of data
message string
{
"id": "9c2e4b7a-1d3f-4a6e-8b0c-5e7f9a1b3d24",
"type": "webhook.test",
"createdAt": "2026-03-02T09:20:00.000Z",
"data": {
"message": "This is a test event from Codevibe Sign. Answer with any 2xx status."
}
}