Overview
When enabled, Swipe will send HTTP POST requests to your configured webhook URL whenever specific events occur in your account. Each webhook request includes:- Event data: Details about what happened
- Signature: For request verification using HMAC
- Event type: The specific type of event
- Event id: The unique event id
Event Types
Document Events
Receive notifications for all document-related activities:| Event Type | Description | 
|---|---|
| document | Triggered when documents are created, updated, or modified | 
- document_type: Type of document (e.g., “purchase”, “invoice”)
- serial_number: Document serial number
- hash_id: Unique document identifier
- message: Event description (e.g., “Document Created”)
- timestamp: When the event occurred
Inventory Events
Get real-time updates about inventory changes:| Event Type | Description | 
|---|---|
| inventory | Triggered when inventory levels change (stock in/out) | 
- swipe_product_id: Internal Swipe product ID
- partner_product_id: Your system’s product ID (-1 if not mapped)
- product_name: Name of the product
- qty: Quantity changed
- movement: Direction of movement (“in” or “out”)
- timestamp: When the inventory change occurred
Security & Verification
HMAC Signature Verification
Every webhook request includes anX-Signature header containing an HMAC signature. This ensures the request is authentic and comes from Swipe.
Verification Process
- Extract the signature from the X-Signatureheader
- Create an HMAC using your webhook secret and the raw request body
- Compare the computed signature with the received signature
Code Examples
PythonWebhook Payloads
Document Event Payload
Inventory Event Payload
Sample Webhook Request
Here’s how a webhook request would look when sent to your endpoint:- POST Request: All webhooks are sent via HTTP POST
- Content-Type: Always application/json
- X-Signature: HMAC signature for request verification
- Payload: The actual event data in JSON format
Configuration
Setting Up Webhooks
- Access Settings: Go to Swipe dashboard
- Add Webhook URL: Enter your webhook endpoint URL
- Select Events: Choose which event types you want to receive
- Set Secret: Generate or provide a webhook secret for signature verification
Webhook URL Requirements
- Must be a valid HTTPS URL (HTTP not supported in production)
- Should respond with a 200 status code within 10 seconds
- Must be publicly accessible (no localhost or private IPs)
Troubleshooting
Common Issues
- 
Signature Verification Failures
- Ensure you’re using the raw request body
- Verify the webhook secret is correct
- Check that the signature header name is X-Signature
 
- 
Webhook Not Receiving Events
- Confirm the webhook URL is correct and accessible
- Check that the event types are properly configured
- Verify your endpoint returns a 200 status code
 
- 
Timeout Issues
- Ensure your webhook endpoint responds within 30 seconds
- Process webhooks asynchronously for heavy operations
- Implement proper error handling