Webhooks
Webhooks allow you to receive real-time HTTP notifications when events occur in your sajn account.Overview
When an event occurs (e.g., a document is signed), sajn sends an HTTP POST request to your configured webhook URL with details about the event.Supported Events
Event | Description |
---|---|
DOCUMENT_CREATED | A new document was created |
DOCUMENT_SENT | A document was sent to signers |
DOCUMENT_OPENED | A signer opened a document |
DOCUMENT_SIGNED | A signer signed a document |
DOCUMENT_COMPLETED | All signers have signed |
DOCUMENT_REJECTED | A signer rejected a document |
Webhook Payload
Each webhook request includes:Configuring Webhooks
Via Dashboard
- Log in to app.sajn.se
- Navigate to Organization Settings > Webhooks
- Click Add Webhook
- Enter your webhook URL
- Select which events to receive
- Save
Via API
Configure webhooks programmatically:Implementing a Webhook Endpoint
Node.js Example
Python Example
Verifying Webhooks
Always verify webhook signatures to ensure requests come from sajn:- Get the
X-Sajn-Signature
header - Compute HMAC-SHA256 of the request body using your webhook secret
- Compare signatures
Best Practices
Respond quickly
Respond quickly
Return a 200 response within 5 seconds. Process the webhook asynchronously if needed.
Verify signatures
Verify signatures
Always verify webhook signatures to prevent spoofing attacks.
Handle retries
Handle retries
Make your endpoint idempotent - sajn will retry failed webhooks up to 3 times.
Use HTTPS
Use HTTPS
Always use HTTPS webhook URLs to encrypt webhook data in transit.
Monitor failures
Monitor failures
Set up monitoring to alert you when webhooks fail consistently.
Retry Logic
If your webhook endpoint returns a non-2xx status or times out:- First retry after 1 minute
- Second retry after 5 minutes
- Third retry after 15 minutes
Troubleshooting
Webhooks Not Receiving
- Check webhook URL is correct and publicly accessible
- Verify HTTPS certificate is valid
- Check firewall/security group settings
- Look for webhook failures in dashboard
Signature Verification Failing
- Ensure you’re using the correct webhook secret
- Verify you’re hashing the raw request body
- Check character encoding (should be UTF-8)