Overview
Webhooks are HTTP callbacks that allow SendLayer to notify your application in real-time when specific email events occur. Instead of polling the API to check for updates, webhooks automatically send data to your specified URL when events happen, such as when an email is opened, clicked, or bounced.How Webhooks Work
- Setup: You create a webhook by providing a URL endpoint and specifying which events you want to monitor
- Monitoring: SendLayer monitors your email activity for the specified events
- Notification: When an event occurs, SendLayer sends an HTTP POST request to your webhook URL with event data
- Processing: Your application receives and processes the webhook data
Prerequisites
- Authorize your domain
- Create or retrieve your API key
- A publicly accessible webhook endpoint URL
- Install the SendLayer SDK
Creating a Webhook
To create a webhook, you need to specify the event type you want to monitor and the URL where SendLayer should send notifications.Replace
<apiKey>
with your actual SendLayer API key in the request header.Available Event Types
You can monitor the following email events:Event | Description |
---|---|
delivery | Email successfully delivered to recipient’s inbox |
open | Recipient opened the email |
click | Recipient clicked a link in the email |
bounce | Email failed to deliver and bounced back |
unsubscribe | Recipient unsubscribed from emails |
complaint | Recipient marked email as spam |
Retrieving Webhooks
You can retrieve all webhooks associated with your account to see their current status and configuration.Get Webhook Response Format
When you retrieve webhooks, you’ll receive data in this format:Deleting a Webhook
You can delete a webhook by providing its ID. This action cannot be undone.Deleting a webhook cannot be undone. You won’t be able to recover or access your webhook after deleting it.
Webhook Payload Format
When SendLayer sends a webhook notification to your endpoint, it includes detailed information about the event. Below, we’ve provided examples of the payload for each event:Best Practices
- Use HTTPs: Always use HTTPs URLs for your webhook endpoints to ensure data security
- Monitor Status: Regularly check your webhook status and response codes
- Error Handling: Implement proper error handling for webhook processing
FAQs
How many webhooks can I create?
How many webhooks can I create?
You can create multiple webhooks for different events and endpoints. There’s no strict limit, but it’s recommended to keep the number manageable for easier maintenance.
What happens if my webhook endpoint is down?
What happens if my webhook endpoint is down?
SendLayer will retry sending webhook notifications if your endpoint is unavailable. Check the
LastResponseCode
and LastResponseTryCounter
fields to monitor delivery status.Can I update an existing webhook?
Can I update an existing webhook?
Currently, webhooks cannot be updated. You’ll need to delete the existing webhook and create a new one with the updated configuration.
How do I test my webhook endpoint?
How do I test my webhook endpoint?
You can use tools like webhook.site or ngrok to create temporary public URLs for testing webhook functionality during development.
What should I do if webhooks stop working?
What should I do if webhooks stop working?
Check your webhook endpoint’s availability, verify the URL is correct, and ensure your server can handle POST requests. Review the
LastResponseCode
field for error details.