gitlabEdit

๐Ÿ””Webhook Fundamentals

Learn how to set up and use webhooks with Docs-Dispatcher for real-time event notifications.

What are Webhooks?

Webhooks are HTTP callbacks that notify your application when events occur in Docs-Dispatcher. Instead of polling for status updates, your application receives automatic notifications when:

  • Documents are signed

  • Mail is delivered

  • Invoices are created

  • Errors occur

Benefits

Real-time notifications:

  • Instant updates without polling

  • Reduced API calls and latency

  • Better user experience

Automated workflows:

  • Trigger actions based on events

  • Update databases automatically

  • Send notifications to users

Async operation support:

  • Handle long-running operations

  • Scale without blocking

  • Retry failed operations

Supported Services

Service
Webhooks Supported
Providers

eSign

โœ… Yes

Universign, Signaturit

Postal

โœ… Yes

MySendingBox

Invoicing

โŒ No

N/A

Email

โŒ No

N/A

SMS

โŒ No

N/A

File

โŒ No

N/A

Upload

โŒ No

N/A

๐Ÿ‘‰ See all webhook events

How Webhooks Work

Workflow:

  1. Your app dispatches request with ?async=true

  2. Dispatcher returns immediately with dispatchId

  3. Dispatcher processes request with provider

  4. Provider sends event to Dispatcher

  5. Dispatcher forwards event to your webhook URL

Setting Up Webhooks

1. Create Webhook Endpoint

Create an HTTP endpoint that accepts POST requests:

Node.js (Express):

PHP:

Java (Spring Boot):

2. Configure Webhook URL

Provide your webhook URL when dispatching:

3. Handle Webhook Events

Process events in your webhook handler:

Webhook Payload Structure

All webhooks include:

Common Fields:

  • event - Event type (e.g., "document_signed")

  • timestamp - ISO 8601 timestamp when event occurred

  • dispatchId - Original dispatch ID from your request

  • service - Service name (esign, postal, etc.)

  • provider - Provider name (universign, signaturit, mysendingbox)

  • data - Event-specific data

Security

Verify Webhook Signatures

All webhooks include a signature header for verification:

Verify signature (Node.js):

Get webhook secret: Contact support to obtain your webhook secret, or configure it in Templater UI settings.

HTTPS Only

Webhook URLs must use HTTPS. HTTP endpoints will be rejected.

IP Whitelisting

For additional security, whitelist Dispatcher IPs:

Best Practices

1. Respond Quickly

Always return 200 OK within 5 seconds:

2. Handle Idempotency

Webhooks may be delivered multiple times - use idempotency:

3. Implement Retry Logic

If your webhook fails, Dispatcher retries:

  • Retry schedule: 1min, 5min, 15min, 1hr, 6hr

  • Max retries: 5 attempts

  • Timeout: 10 seconds per attempt

Your endpoint should be idempotent to handle retries gracefully.

4. Log Everything

Log all webhook events for debugging:

5. Monitor Webhook Health

Track webhook delivery success:

  • Count successful vs failed webhooks

  • Alert on consecutive failures

  • Monitor response times

  • Track event processing delays

Testing Webhooks

Local Testing with ngrok

Test webhooks locally using ngrok:

Webhook Testing Tools

  • RequestBin: https://requestbin.com

  • Webhook.site: https://webhook.site

  • ngrok: https://ngrok.com

Mock Webhook Events

Test your handler with mock events:

Troubleshooting

Webhook Not Received

Check:

  1. โœ… Webhook URL is HTTPS

  2. โœ… Endpoint returns 200 OK within 5 seconds

  3. โœ… No firewall blocking Dispatcher IPs

  4. โœ… Using ?async=true query parameter

401/403 Errors

Signature verification failing:

  • Check webhook secret is correct

  • Verify signature algorithm matches

  • Ensure payload hasn't been modified

Timeout Errors

Endpoint too slow:

  • Respond with 200 OK immediately

  • Process webhook asynchronously

  • Optimize slow database queries

  • Use background job queues

Duplicate Events

Multiple webhooks received:

  • Implement idempotency using dispatchId + event

  • Check for duplicate processing in logs

  • Use database unique constraints

Next Steps

Last updated