Skip to main content

SmartReports webhooks

Overview​

SmartReports and SmartBatch deliver lifecycle notifications over Verifik's shared Webhook and Smart Monitor delivery pipeline (WebhookEvents). Whenever a batch row settles, a batch completes, a report PDF finishes rendering (or fails), or an email delivery succeeds (or bounces), Verifik dispatches a typed smart_batch_* event via HTTP POST.

HTTP delivery format & security

Every delivery is an HTTP POST to your target URL with a 5000 ms (5 second) timeout and JSON envelope:

{
"type": "smart_batch_report_generated",
"object": { }
}
  • type — Exact smart_batch_* event identifier (smart_batch_report_generated, smart_batch_report_sent, etc.).
  • object — Event-specific payload. Sensitive internal fields (encryptedOcr and prompt) are stripped if present.
  • No HMAC signature header: smart_batch_* product deliveries do not currently send an x-verifik-signature header. Always use HTTPS, protect your listener URL with a secret path token or query/header secret on your configured URL, and validate object.reportId / object.batchId and object.externalRefId against GET https://api.verifik.co/v2/smart-reports/{id} (using Authorization: Bearer <VERIFIK_JWT>) before triggering irreversible downstream actions.

Treat new optional fields on object as additive.


How the target URL is chosen​

Target URL resolution depends on whether the event originates from a SmartReport operation or a SmartBatch execution:

Target URL resolution order
  1. Report events (smart_batch_report_generated, smart_batch_report_generation_failed, smart_batch_report_sent, smart_batch_report_delivery_failed):
    1. Per-report / per-run report.webhookUrl override (passed in POST /v2/smart-reports/run or POST /v2/smart-reports).
    2. batchConfiguration.notification.webhookUrl on the batch's BatchConfiguration.
    3. If neither exists, no webhook is sent.
  2. Batch and row execution events (smart_batch_row_completed, smart_batch_batch_completed):
    • Uses options.webhookUrl when explicitly passed, or batchConfiguration.notification.webhook / batchConfiguration.notification.webhookUrl.
    • Note: Async FeatureRunner runs (smart-batch-run-sync) emit smart_batch_batch_completed using batchConfiguration.notification.webhookUrl and include runId and creditsSpent in object.

When a webhookUrl is resolved, Verifik automatically looks up or creates an active client Webhook record (Smart Batch — <name>) and links the BatchConfiguration so delivery history appears in Smart Monitor.


Delivery guarantees & retry schedule​

  • Success criteria: Your endpoint must return an HTTP 2xx response within 5000 ms. Return 200 OK immediately and offload PDF downloads or database writes to a background worker.
  • Retry schedule: On non-2xx responses, timeouts, or connection errors, Verifik schedules up to 6 retry attempts using the backoff intervals [60, 60, 120, 120, 360, 720] minutes (1h, 1h, 2h, 2h, 6h, 12h), rounded to the nearest 10-minute boundary.
  • Optional failure/success notification emails: If the linked Webhook record configures notification.email and enables notification.success or notification.fail, Verifik sends a Mailgun alert on attempt 1.

Event lifecycle​

flowchart TD
B["Batch running"] -->|"smart_batch_row_completed\n(row-by-row mode)"| R["Rows finish"]
B -->|"smart_batch_batch_completed"| F["Batch settled"]
R --> F
F -->|"Render PDF + score"| G{"PDF result"}
G -->|"success"| EV1["smart_batch_report_generated"]
G -->|"error"| EV2["smart_batch_report_generation_failed"]
EV1 -->|"Optional emailTo / send-email"| E{"Email result"}
E -->|"sent"| EV3["smart_batch_report_sent"]
E -->|"failed"| EV4["smart_batch_report_delivery_failed"]

Event Catalog​

Event typeobject.eventWhen it firesKey object fields
smart_batch_report_generated"report.generated"Report PDF rendering succeeds (POST /v2/smart-reports/run, POST /v2/smart-reports/{id}/generate, or async batch finalization).reportId, batchId, templateId, status, rowIndex, pdfSize, pdfEngine, generationDurationMs, downloadUrl, htmlUrl, verificationScore, externalRefId, generatedAt
smart_batch_report_generation_failed"report.generation_failed"Report PDF rendering fails.reportId, batchId, templateId, status, error, externalRefId, failedAt
smart_batch_report_sent"report.sent"Report PDF email delivery succeeds (emailTo on /run or POST /v2/smart-reports/{id}/send-email).reportId, batchId, templateId, status, recipients, subject, messageId, downloadUrl, htmlUrl, externalRefId, sentAt
smart_batch_report_delivery_failed"report.delivery_failed"Report PDF email delivery fails or bounces.reportId, batchId, templateId, status, recipients, subject, messageId, error, downloadUrl, htmlUrl, externalRefId, sentAt
smart_batch_batch_completed"batch.completed"All rows in a SmartBatch reach a terminal state (completed or failed).batchId, runId, status, creditsSpent, stats
smart_batch_row_completed"row.completed"A non-final row in a SmartBatch reaches a terminal status (completed, failed, or partial).batchId, rowIndex, status, results, errors

Event schemas & payload examples​

1. smart_batch_report_generated​

Fired when a SmartReport PDF finishes rendering (status: "generated").

FieldTypeDescription
object.eventstringAlways "report.generated".
object.reportIdstringSmartReport ObjectId.
object.batchIdstringAssociated SmartBatch ObjectId.
object.templateIdstringSmartReportTemplate ObjectId used to render the PDF.
object.statusstring"generated".
object.rowIndexnumberZero-based batch row index rendered into the report.
object.pdfSizenumberRendered PDF file size in bytes.
object.pdfEnginestringEngine used ("puppeteer" or "pdfkit").
object.generationDurationMsnumberPDF rendering duration in milliseconds.
object.downloadUrlstringRelative API path /v2/smart-reports/{reportId}/download to fetch the PDF binary.
object.htmlUrlstringRelative API path /v2/smart-reports/{reportId}/html to fetch HTML + Verification Score JSON.
object.verificationScoreobject (optional)Score summary (score, verdict, coverage, profile) when scoring is enabled.
object.externalRefIdstring (optional)Caller correlation ID passed on /run or report creation.
object.generatedAtstring (ISO 8601)Timestamp when generation completed.
{
"type": "smart_batch_report_generated",
"object": {
"event": "report.generated",
"reportId": "6740a1b2c3d4e5f678901234",
"batchId": "6740a1b2c3d4e5f678901111",
"templateId": "6740a1b2c3d4e5f678902222",
"status": "generated",
"rowIndex": 0,
"pdfSize": 184320,
"pdfEngine": "puppeteer",
"generationDurationMs": 1420,
"downloadUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/download",
"htmlUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/html",
"verificationScore": {
"score": 0.9625,
"verdict": "approve",
"coverage": 1,
"profile": "cabify_driver"
},
"externalRefId": "case-12345",
"generatedAt": "2026-11-24T20:15:30.120Z"
}
}

2. smart_batch_report_generation_failed​

Fired when PDF generation fails (status: "failed").

FieldTypeDescription
object.eventstringAlways "report.generation_failed".
object.reportIdstringSmartReport ObjectId.
object.batchIdstringAssociated SmartBatch ObjectId.
object.templateIdstringSmartReportTemplate ObjectId.
object.statusstring"failed".
object.errorstringFailure message describing why rendering aborted.
object.externalRefIdstring (optional)Caller correlation ID if present on the report.
object.failedAtstring (ISO 8601)Timestamp when failure occurred.
{
"type": "smart_batch_report_generation_failed",
"object": {
"event": "report.generation_failed",
"reportId": "6740a1b2c3d4e5f678901234",
"batchId": "6740a1b2c3d4e5f678901111",
"templateId": "6740a1b2c3d4e5f678902222",
"status": "failed",
"error": "Chromium page timeout while rendering custom font asset",
"externalRefId": "case-12345",
"failedAt": "2026-11-24T20:16:02.450Z"
}
}

3. smart_batch_report_sent​

Fired when report email delivery succeeds (status: "sent").

FieldTypeDescription
object.eventstringAlways "report.sent".
object.reportIdstringSmartReport ObjectId.
object.batchIdstringAssociated SmartBatch ObjectId.
object.templateIdstringSmartReportTemplate ObjectId.
object.statusstring"sent".
object.recipientsstring[]Recipient email addresses.
object.subjectstringEmail subject line sent.
object.messageIdstringMail provider message ID.
object.downloadUrlstringRelative API path /v2/smart-reports/{reportId}/download.
object.htmlUrlstringRelative API path /v2/smart-reports/{reportId}/html.
object.externalRefIdstring (optional)Caller correlation ID if present on the report.
object.sentAtstring (ISO 8601)Timestamp when email dispatch completed.
{
"type": "smart_batch_report_sent",
"object": {
"event": "report.sent",
"reportId": "6740a1b2c3d4e5f678901234",
"batchId": "6740a1b2c3d4e5f678901111",
"templateId": "6740a1b2c3d4e5f678902222",
"status": "sent",
"recipients": ["compliance@yourcompany.com"],
"subject": "SmartReport: Colombia Citizen Comprehensive — 2026-11-24",
"messageId": "<20261124201535.1.abc123@mg.verifik.co>",
"downloadUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/download",
"htmlUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/html",
"externalRefId": "case-12345",
"sentAt": "2026-11-24T20:15:35.800Z"
}
}

4. smart_batch_report_delivery_failed​

Fired when report email delivery fails (status: "failed"), so your integration can distinguish a failed send from one that was never attempted.

FieldTypeDescription
object.eventstringAlways "report.delivery_failed".
object.reportIdstringSmartReport ObjectId.
object.batchIdstringAssociated SmartBatch ObjectId.
object.templateIdstringSmartReportTemplate ObjectId.
object.statusstring"failed".
object.recipientsstring[]Recipient email addresses.
object.subjectstringEmail subject line attempted.
object.messageIdstring (optional)Mail provider message ID if issued prior to failure.
object.errorstringEmail delivery error message.
object.downloadUrlstringRelative API path /v2/smart-reports/{reportId}/download.
object.htmlUrlstringRelative API path /v2/smart-reports/{reportId}/html.
object.externalRefIdstring (optional)Caller correlation ID if present on the report.
object.sentAtstring (ISO 8601)Timestamp when the failed send attempt completed.
{
"type": "smart_batch_report_delivery_failed",
"object": {
"event": "report.delivery_failed",
"reportId": "6740a1b2c3d4e5f678901234",
"batchId": "6740a1b2c3d4e5f678901111",
"templateId": "6740a1b2c3d4e5f678902222",
"status": "failed",
"recipients": ["invalid@nonexistent-domain.test"],
"subject": "SmartReport: Colombia Citizen Comprehensive — 2026-11-24",
"messageId": null,
"error": "Mailgun 400: invalid recipient domain",
"downloadUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/download",
"htmlUrl": "/v2/smart-reports/6740a1b2c3d4e5f678901234/html",
"externalRefId": "case-12345",
"sentAt": "2026-11-24T20:15:36.210Z"
}
}

5. smart_batch_batch_completed​

Fired once when a SmartBatch transitions to a terminal state ("completed" or "failed").

FieldTypeDescription
object.eventstringAlways "batch.completed".
object.batchIdstringSmartBatch ObjectId.
object.runIdstring (optional)FeatureRunner run ObjectId (present on async FeatureRunner syncs).
object.statusstring"completed" or "failed".
object.creditsSpentnumber (optional)Total Verifik credits spent by the run (present on async FeatureRunner syncs).
object.statsobjectAggregate counts: { totalRows, completedRows, failedRows, partialRows }.
{
"type": "smart_batch_batch_completed",
"object": {
"event": "batch.completed",
"batchId": "6740a1b2c3d4e5f678901111",
"runId": "6740a1b2c3d4e5f678903333",
"status": "completed",
"creditsSpent": 12,
"stats": {
"totalRows": 2,
"completedRows": 2,
"failedRows": 0,
"partialRows": 0
}
}
}

6. smart_batch_row_completed​

Fired in row-by-row batch update flows when a row reaches a terminal state ("completed", "failed", or "partial") before all rows in the batch are done.

FieldTypeDescription
object.eventstringAlways "row.completed".
object.batchIdstringSmartBatch ObjectId.
object.rowIndexnumberZero-based row index within the batch.
object.statusstring"completed", "failed", or "partial".
object.resultsobjectMap of verification step outputs keyed by step sequence.
object.errorsarrayList of { step, message, code } errors recorded for failed steps.
{
"type": "smart_batch_row_completed",
"object": {
"event": "row.completed",
"batchId": "6740a1b2c3d4e5f678901111",
"rowIndex": 0,
"status": "completed",
"results": {
"1": {
"fullName": "JUAN CARLOS PEREZ GOMEZ",
"documentNumber": "123456789"
}
},
"errors": []
}
}

Webhook receiver examples​

The receiver implementations below acknowledge requests immediately within 5 seconds (200 OK), deduplicate repeated deliveries idempotently, verify the report via GET /v2/smart-reports/{id}, and download the PDF using Authorization: Bearer <VERIFIK_JWT>.

import express from 'express';
import fs from 'node:fs/promises';

const app = express();
app.use(express.json({ limit: '2mb' }));

const VERIFIK_API_URL = 'https://api.verifik.co';
const VERIFIK_JWT = process.env.VERIFIK_JWT;

// Replace with Redis or a unique DB index in production
const processedEvents = new Set();

async function verifyAndDownloadPdf(obj) {
// Verify the event directly against Verifik API before trusting payload fields
const metaRes = await fetch(`${VERIFIK_API_URL}/v2/smart-reports/${obj.reportId}`, {
headers: { Authorization: `Bearer ${VERIFIK_JWT}` },
});
if (!metaRes.ok) {
throw new Error(`Report lookup failed: HTTP ${metaRes.status}`);
}
const { data: report } = await metaRes.json();

const pdfRes = await fetch(`${VERIFIK_API_URL}${obj.downloadUrl}`, {
headers: { Authorization: `Bearer ${VERIFIK_JWT}` },
});
if (!pdfRes.ok) {
throw new Error(`PDF download failed: HTTP ${pdfRes.status}`);
}

const pdfBuffer = Buffer.from(await pdfRes.arrayBuffer());
const outPath = `./reports/${report.externalRefId || obj.reportId}.pdf`;
await fs.mkdir('./reports', { recursive: true });
await fs.writeFile(outPath, pdfBuffer);
console.log(`Saved ${outPath} (${pdfBuffer.length} bytes), score:`, report.verificationScoreSummary);
}

app.post('/webhooks/verifik-reports', (req, res) => {
const { type, object: obj } = req.body ?? {};
if (!type || !obj) {
return res.status(400).json({ error: 'Invalid webhook payload' });
}

const idempotencyKey = `${type}:${obj.reportId || obj.batchId}:${obj.rowIndex ?? ''}:${obj.status || ''}`;
if (processedEvents.has(idempotencyKey)) {
return res.status(200).json({ received: true, duplicate: true });
}
processedEvents.add(idempotencyKey);

// Acknowledge within 5 seconds before downloading PDFs or updating downstream systems
res.status(200).json({ received: true });

setImmediate(async () => {
try {
switch (type) {
case 'smart_batch_report_generated':
await verifyAndDownloadPdf(obj);
break;
case 'smart_batch_report_generation_failed':
console.error('Report generation failed:', obj.reportId, obj.externalRefId, obj.error);
break;
case 'smart_batch_report_sent':
console.log('Report emailed:', obj.reportId, obj.recipients, obj.messageId);
break;
case 'smart_batch_report_delivery_failed':
console.error('Email delivery failed:', obj.reportId, obj.recipients, obj.error);
break;
case 'smart_batch_batch_completed':
console.log('Batch settled:', obj.batchId, obj.status, obj.stats, 'credits:', obj.creditsSpent);
break;
case 'smart_batch_row_completed':
console.log('Row completed:', obj.batchId, obj.rowIndex, obj.status);
break;
default:
console.log('Unhandled SmartBatch event:', type);
}
} catch (err) {
console.error('Async webhook handler failed:', err);
}
});
});

app.listen(3000, () => console.log('SmartReports webhook listener on :3000'));