Webhook Events
PDF-Sign sends webhooks for various events. This page documents each event type and its payload structure.
Event Types
| Event | Trigger | Priority |
|---|---|---|
pdf.generated | PDF successfully created | High |
pdf.failed | PDF generation failed | High |
quota.warning | Usage reached 80% of quota | Medium |
quota.exceeded | Monthly quota limit reached | High |
pdf.generated
Triggered when a PDF is successfully generated and stored.
Payload
{
"event": "pdf.generated",
"timestamp": "2024-01-15T10:30:45.123Z",
"data": {
"template_id": "550e8400-e29b-41d4-a716-446655440000",
"pdf_url": "https://api.pdf-sign.com/storage/v1/object/public/pdfs/user-id/template-id/1705312245123.pdf",
"storage_path": "user-id/template-id/1705312245123.pdf",
"file_size": 156789,
"render_time_ms": 2450,
"variables": {
"clientName": "John Doe",
"invoiceNumber": "INV-2024-001",
"amount": "1500.00"
},
"created_at": "2024-01-15T10:30:45.123Z"
}
}
Fields
| Field | Type | Description |
|---|---|---|
template_id | string | UUID of the template used |
pdf_url | string | Public URL to download the PDF |
storage_path | string | Storage path in the bucket |
file_size | number | PDF file size in bytes |
render_time_ms | number | Time to render the PDF in milliseconds |
variables | object | Variables used in the generation |
created_at | string | ISO 8601 timestamp of creation |
Example Use Cases
- Download and process the generated PDF
- Send the PDF to customers via email
- Store metadata in your database
- Trigger downstream workflows
pdf.failed
Triggered when PDF generation fails for any reason.
Payload
{
"event": "pdf.failed",
"timestamp": "2024-01-15T10:30:45.123Z",
"data": {
"template_id": "550e8400-e29b-41d4-a716-446655440000",
"error_code": "RENDER_FAILED",
"error_message": "Failed to render PDF: Template contains invalid HTML",
"variables": {
"clientName": "John Doe"
}
}
}
Fields
| Field | Type | Description |
|---|---|---|
template_id | string | UUID of the template that failed |
error_code | string | Error code for programmatic handling |
error_message | string | Human-readable error description |
variables | object | Variables that were provided |
Error Codes
| Code | Description |
|---|---|
RENDER_FAILED | PDF rendering failed (invalid HTML, timeout, etc.) |
STORAGE_FAILED | Failed to store PDF in storage |
TEMPLATE_NOT_FOUND | Template does not exist |
INVALID_VARIABLES | Variables validation failed |
Example Use Cases
- Alert your team about failures
- Retry the generation with corrected data
- Log errors for debugging
- Notify affected customers
quota.warning
Triggered when usage reaches 80% of the monthly quota.
One-Time Alert
This event is triggered once when crossing the 80% threshold, not on every request after that.
Payload
{
"event": "quota.warning",
"timestamp": "2024-01-15T10:30:45.123Z",
"data": {
"current_usage": 240,
"quota_limit": 300,
"percentage": 80,
"subscription_plan": "starter"
}
}
Fields
| Field | Type | Description |
|---|---|---|
current_usage | number | Current number of PDFs generated this month |
quota_limit | number | Maximum PDFs allowed per month |
percentage | number | Percentage of quota used |
subscription_plan | string | Current subscription plan |
Example Use Cases
- Send alert to administrators
- Display warning in your application
- Proactively upgrade the plan
- Pause non-critical PDF generation
quota.exceeded
Triggered when the monthly quota limit is reached and a PDF generation is blocked.
Payload
{
"event": "quota.exceeded",
"timestamp": "2024-01-15T10:30:45.123Z",
"data": {
"current_usage": 300,
"quota_limit": 300,
"subscription_plan": "starter"
}
}
Fields
| Field | Type | Description |
|---|---|---|
current_usage | number | Current number of PDFs generated |
quota_limit | number | Maximum PDFs allowed per month |
subscription_plan | string | Current subscription plan |
Example Use Cases
- Immediately notify administrators
- Trigger plan upgrade workflow
- Pause PDF generation features
- Queue PDFs for next month
Handling Multiple Events
You can subscribe to multiple events with a single webhook. Handle them using a switch statement:
app.post('/webhooks/pdf-sign', (req, res) => {
const { event, data } = req.body;
switch (event) {
case 'pdf.generated':
handlePdfGenerated(data);
break;
case 'pdf.failed':
handlePdfFailed(data);
break;
case 'quota.warning':
handleQuotaWarning(data);
break;
case 'quota.exceeded':
handleQuotaExceeded(data);
break;
case 'test':
console.log('Test webhook received');
break;
default:
console.log(`Unknown event: ${event}`);
}
res.status(200).send('OK');
});
Event Timing
| Event | When It's Sent |
|---|---|
pdf.generated | Immediately after successful storage |
pdf.failed | Immediately after failure detection |
quota.warning | When crossing 80% threshold |
quota.exceeded | When a request is blocked due to quota |
Async Delivery
Webhooks are sent asynchronously ("fire and forget") and do not block the API response. There may be a slight delay between the event and webhook delivery.