Overview
While FacturaScripts provides a comprehensive REST API for pulling data and performing operations, webhook support for pushing events to external systems depends on your specific installation and plugins.FacturaScripts core does not include built-in webhook functionality. However, webhooks can be implemented through plugins or custom extensions.
Event System
FacturaScripts has an extensive event system that can be leveraged to create webhook functionality:Available Events
The system fires events during various operations:- Document Events: Created, updated, deleted, approved
- Model Events: Save, delete, load
- Payment Events: Receipt paid, payment recorded
- User Events: Login, logout, permission changes
Event Hooks
Plugins can subscribe to events using the event hook system:Implementing Webhooks
If you need webhook functionality, you have several options:Option 1: Custom Plugin
Create a custom plugin that:- Registers webhook URLs in the database
- Hooks into relevant FacturaScripts events
- Sends HTTP POST requests to registered webhook URLs
- Handles retries and error logging
Option 2: Polling with API
Use the REST API to periodically check for changes:Option 3: Database Triggers
Implement database-level triggers that call external APIs when data changes.Webhook Event Structure
If implementing webhooks, we recommend the following event structure:Webhook Payload
Event Types
Recommended event naming convention:| Event | Description |
|---|---|
invoice.created | New invoice created |
invoice.updated | Invoice modified |
invoice.deleted | Invoice deleted |
invoice.paid | Invoice marked as paid |
customer.created | New customer created |
customer.updated | Customer information updated |
product.created | New product added |
product.updated | Product information updated |
receipt.paid | Payment receipt marked as paid |
Webhook Security
Signature Verification
Implement webhook signature verification to ensure authenticity:Receiving Webhooks
Verify the signature when receiving webhooks:Webhook Best Practices
Idempotency
Idempotency
Include a unique event ID in each webhook. Receiving systems should track processed event IDs to handle duplicate deliveries.
Retry Logic
Retry Logic
Implement exponential backoff for failed webhook deliveries:
- First retry: After 5 seconds
- Second retry: After 25 seconds
- Third retry: After 125 seconds
- Maximum retries: 5 attempts
Timeout Handling
Timeout Handling
Set reasonable timeouts for webhook HTTP requests (e.g., 10 seconds) to avoid blocking the application.
Logging
Logging
Log all webhook deliveries, including:
- Event type and ID
- Destination URL
- Response status code
- Timestamp
- Error messages if failed
Webhook Management UI
Webhook Management UI
Provide a user interface for:
- Registering webhook URLs
- Selecting event types to receive
- Viewing delivery logs
- Testing webhooks
- Disabling/enabling webhooks
Testing Webhooks
Local Testing
Use tools like ngrok to test webhooks locally:Webhook Testing Tools
- RequestBin: https://requestbin.com
- Webhook.site: https://webhook.site
- Beeceptor: https://beeceptor.com
Alternative: API Polling
If implementing webhooks is not feasible, use API polling with timestamps:Custom Webhook Plugin Example
Here’s a basic structure for a webhook plugin:Need Help?
If you need custom webhook functionality:- Check the FacturaScripts plugin marketplace for existing webhook plugins
- Hire a FacturaScripts developer to create a custom webhook plugin
- Use the API with polling as an alternative
- Join the FacturaScripts community forum for guidance
Next Steps
API Overview
Learn about the REST API
Endpoints
Explore available endpoints

