Webhook Configuration
Webhooks are a powerful way to receive real-time updates and notifications from OsmoX. This guide will help you configure and use webhooks effectively.Prerequisites
Before setting up webhooks, ensure you have:- An active OsmoX account
- A webhook URL that your application will listen to
- A provider ID on which you want to add the webhook
Registering a Webhook
Use the following GraphQL mutation to register a webhook:- GraphQL
- cURL
Response
Handling Webhook Events
Once registered, OsmoX will send POST requests to your webhook URL with notification updates.Example Payload
Payload Fields
Notification ID
The provider used to send the notification
The channel type (1=SMTP, 2=Mailgun, etc.)
The original notification data
Current delivery status (see Delivery Status)
Provider response data
The application ID
Number of retry attempts
Processing Webhooks
Your webhook handler should:- Receive the POST request
- Extract required information from the payload
- Perform necessary actions (e.g., update database, trigger workflows)
- Return a success response (HTTP 200)
Example Handler (Node.js/Express)
Retry Strategy
OsmoX uses an exponential backoff strategy for webhook retries. If a request fails, it will retry after increasing intervals.Webhook verification is planned for future releases.
Best Practices
Respond Quickly
Return HTTP 200 immediately to acknowledge receipt, then process asynchronously
Handle Duplicates
Use the notification ID to handle potential duplicate deliveries
Secure Endpoints
Consider implementing signature verification when available
Log Everything
Log all webhook payloads for debugging and auditing