Guide menu · Webhooks
API guide
Webhooks
Get told when documents are issued, revoked or checked.
How it works
#- An organization admin opens API and webhooks, chooses Add endpoint, and picks which events to send.
- When one of those events happens, we send a
POSTwith a JSON body to the endpoint. - Your server checks the signature, answers
2xxquickly, and then does its work.
Endpoints must be https addresses on the public internet. Each has its own signing secret, starting whsec_, shown on request on the same page.
Headers
Content-Type- application/json
User-Agent- TrueSealed-Webhooks/1
TrueSealed-Event- The event type, such as document.issued.
TrueSealed-Event-Id- The event id, the same on every retry.
TrueSealed-Signature- t=<unix time>,v1=<signature>
Events
#Every event has the same envelope: id, type, created_at and data. Open one to see a full example.
document.issued
A document was issued: from your organization's area, a bulk issue, a PDF upload or the API. data is the document.
document.issued
{
"id": "evt_k3j9x0q2m8w1v7c5b4n6z2a1",
"type": "document.issued",
"created_at": "2026-03-01T09:30:02+00:00",
"data": {
"id": "rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"object": "document",
"type": "generated",
"status": "valid",
"title": "Certificate in First Aid",
"recipient_name": "Ada Lovelace",
"recipient_email": "[email protected]",
"fields": {
"grade": "Distinction"
},
"issued_at": "2026-03-01",
"expires_at": "2028-03-01",
"revoked_at": null,
"revoked_reason": null,
"template_id": "01m7p0nr39388waqvbw0radjxa",
"replaces": null,
"verification_url": "https://truesealed.com/v/rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"file_sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-03-01T09:30:00+00:00"
}
}
document.revoked
A document was revoked. data is the document, with revoked_at and revoked_reason. A correction sends document.revoked for the old document and document.issued for the new one.
document.revoked
{
"id": "evt_k3j9x0q2m8w1v7c5b4n6z2a1",
"type": "document.revoked",
"created_at": "2026-03-01T09:30:02+00:00",
"data": {
"id": "rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"object": "document",
"type": "generated",
"status": "revoked",
"title": "Certificate in First Aid",
"recipient_name": "Ada Lovelace",
"recipient_email": "[email protected]",
"fields": {
"grade": "Distinction"
},
"issued_at": "2026-03-01",
"expires_at": "2028-03-01",
"revoked_at": "2026-04-12T14:05:00+00:00",
"revoked_reason": "Issued in error",
"template_id": "01m7p0nr39388waqvbw0radjxa",
"replaces": null,
"verification_url": "https://truesealed.com/v/rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"file_sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-03-01T09:30:00+00:00"
}
}
document.verified
Someone checked a document: by scanning its QR code, opening its link, or uploading the PDF. data is the document plus a verification object. Only the method, the result and the country are sent; nothing else about the person is ever stored or sent.
document.verified
{
"id": "evt_k3j9x0q2m8w1v7c5b4n6z2a1",
"type": "document.verified",
"created_at": "2026-03-01T09:30:02+00:00",
"data": {
"id": "rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"object": "document",
"type": "generated",
"status": "valid",
"title": "Certificate in First Aid",
"recipient_name": "Ada Lovelace",
"recipient_email": "[email protected]",
"fields": {
"grade": "Distinction"
},
"issued_at": "2026-03-01",
"expires_at": "2028-03-01",
"revoked_at": null,
"revoked_reason": null,
"template_id": "01m7p0nr39388waqvbw0radjxa",
"replaces": null,
"verification_url": "https://truesealed.com/v/rut4qvhw55lxp5zjzeduxv3qhkqkdqi2",
"file_sha256": "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
"created_at": "2026-03-01T09:30:00+00:00",
"verification": {
"object": "verification",
"method": "qr_scan",
"result": "valid",
"country": "LK",
"occurred_at": "2026-03-02T08:14:27+00:00"
}
}
}
batch.finished
A bulk issue finished. data has the counts of documents issued and rows that failed. status is completed, or failed when no row could be issued.
batch.finished
{
"id": "evt_k3j9x0q2m8w1v7c5b4n6z2a1",
"type": "batch.finished",
"created_at": "2026-03-01T09:30:02+00:00",
"data": {
"id": "01m7temf1teydh8swh02mamqj1",
"object": "batch",
"title": "March graduates",
"status": "completed",
"total_rows": 120,
"issued": 118,
"failed": 2,
"completed_at": "2026-03-01T10:02:41+00:00"
}
}
ping
Sent only when you choose Send test event, to check your receiver.
ping
{
"id": "evt_k3j9x0q2m8w1v7c5b4n6z2a1",
"type": "ping",
"created_at": "2026-03-01T09:30:02+00:00",
"data": {
"message": "Test event from TrueSealed"
}
}
Checking signatures
#Anyone can send a request to your endpoint, so check every one before trusting it. The TrueSealed-Signature header holds:
t, the time it was signed, in seconds since 1970.v1, the HMAC-SHA256 oft, a full stop, and the raw body, keyed with your endpoint's secret, in hexadecimal.
Compute the same value and compare them in constant time. Use the body exactly as it arrived, before any JSON parsing, and refuse anything signed more than five minutes ago, so an old request cannot be replayed.
A receiver that checks signatures
<?php
// $body is the raw request body, before any JSON decoding.
function truesealedSignatureIsValid(string $header, string $body, string $secret): bool
{
parse_str(str_replace(',', '&', $header), $parts);
$time = (int) ($parts['t'] ?? 0);
$expected = hash_hmac('sha256', $time.'.'.$body, $secret);
return abs(time() - $time) <= 300
&& hash_equals($expected, (string) ($parts['v1'] ?? ''));
}
$body = file_get_contents('php://input');
$header = $_SERVER['HTTP_SEALCHECK_SIGNATURE'] ?? '';
if (! truesealedSignatureIsValid($header, $body, getenv('TRUESEALED_WEBHOOK_SECRET'))) {
http_response_code(400);
exit;
}
$event = json_decode($body, true);
// Ignore repeats: you may already have handled $event['id'].
http_response_code(200);
const crypto = require('crypto');
const express = require('express');
function truesealedSignatureIsValid(header, rawBody, secret) {
const parts = Object.fromEntries(header.split(',').map((part) => part.split('=')));
const time = Number(parts.t);
const expected = crypto.createHmac('sha256', secret).update(`${time}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 || '', 'hex');
return Math.abs(Date.now() / 1000 - time) <= 300
&& given.length === expected.length
&& crypto.timingSafeEqual(expected, given);
}
const app = express();
// Read the raw body: the signature covers the exact bytes that were sent.
app.post('/webhooks/truesealed', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('TrueSealed-Signature') || '';
if (!truesealedSignatureIsValid(header, req.body.toString('utf8'), process.env.TRUESEALED_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
// Ignore repeats: you may already have handled event.id.
res.sendStatus(200);
});
app.listen(3000);
import hashlib
import hmac
import os
import time
from flask import Flask, request
def truesealed_signature_is_valid(header: str, body: bytes, secret: str) -> bool:
parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
timestamp = int(parts.get("t", "0"))
expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
return abs(time.time() - timestamp) <= 300 and hmac.compare_digest(expected, parts.get("v1", ""))
app = Flask(__name__)
@app.post("/webhooks/truesealed")
def truesealed_webhook():
# request.get_data() is the raw body: the signature covers the exact bytes that were sent.
header = request.headers.get("TrueSealed-Signature", "")
if not truesealed_signature_is_valid(header, request.get_data(), os.environ["TRUESEALED_WEBHOOK_SECRET"]):
return "", 400
event = request.get_json()
# Ignore repeats: you may already have handled event["id"].
return "", 200
Signature checker
#Answering and retries
#- Answer fast. Any
2xxwithin 10 seconds counts as received. Do slow work after answering, for example in a queue. - We retry. Any other answer, a timeout or a refused connection is a failure. We try again after 1 minute, 5 minutes, 30 minutes, 2 hours, 8 hours and 12 hours, then mark the delivery failed. An admin can send any delivery again from API and webhooks.
- Expect repeats. The same event can arrive more than once. Store the ids you have handled and skip repeats.
- Expect any order. Events can arrive out of order. Use
created_at, or fetch the document, when order matters. - No redirects. A
3xxanswer is a failure; give the final address. - History. Deliveries are listed on the API and webhooks page for 30 days.