Contentful Webhook Not Triggering Fix
In this tutorial, you'll learn about Contentful Webhook Not Triggering Fix. We cover key concepts, practical examples, and best practices.
The Problem
A Contentful webhook does not fire when content is published or updated. The webhook URL is configured but the receiving server never gets a POST request.
Quick Fix
Step 1: Verify the webhook URL is correct and accessible
# Test the webhook endpoint
curl -X POST https://your-server.com/webhook/contentful \
-H "Content-Type: application/json" \
-d '{"test": true}'
Expected output: The server responds with 200 OK.
Step 2: Check webhook logs in Contentful
Contentful Dashboard → Settings → Webhooks → Select webhook → Logs tab
Look for failed deliveries with HTTP status codes:
200— success4xx— server rejected the request5xx— server errorECONNREFUSED— server not reachableETIMEDOUT— request timed out
Expected output: Webhook logs show delivery attempts and responses.
Step 3: Select the correct content type events
{
"topics": [
// Wrong — no events selected
// Right — select specific events
"ContentManagement.Entry.publish",
"ContentManagement.Entry.unpublish",
"ContentManagement.Entry.delete]
]
}
Configure the webhook to trigger on specific events:
Entry.publish— content is publishedEntry.unpublish— content is unpublishedEntry.delete— content is deletedAsset.publish— assets are published
Expected output: The webhook triggers on the selected events.
Step 4: Check for SSL/TLS issues
# Test SSL handshake
curl -v https://your-server.com/webhook/contentful
If the SSL certificate is self-signed or expired, Contentful rejects the connection:
# Use a valid SSL certificate from Let's Encrypt or a trusted CA
sudo certbot --nginx -d your-server.com
Expected output: The SSL handshake succeeds with a trusted certificate.
Step 5: Test with Contentful's webhook testing tool
# Use the "Test" button in Contentful webhook settings
# This sends a sample payload to test the connection
Expected output: The test result shows whether the delivery succeeded.
Step 6: Handle webhook retries
Contentful retries failed webhooks up to 3 times with exponential backoff:
Retry 1: after 10 seconds
Retry 2: after 60 seconds
Retry 3: after 300 seconds
Ensure your server responds within 30 seconds. If the server takes longer, Contentful times out.
Step 7: Add webhook authentication
// Server-side verification (Node.js example)
const crypto = require('crypto');
function verifyWebhook(req, res, next) {
const signature = req.headers['x-contentful-webhook-signature'];
const body = JSON.stringify(req.body);
const expected = crypto
.createHmac('sha256', process.env.CONTENTFUL_WEBHOOK_SECRET)
.update(body)
.digest('hex');
if (signature !== expected) {
return res.status(401).send('Invalid signature');
}
next();
}
Expected output: Only verified webhook requests are processed.
Step 8: Check for IP allowlisting
If your server has IP allowlisting, add Contentful's webhook IPs:
Contentful webhook IPs:
52.58.254.190
52.57.138.38
18.156.100.214
Expected output: Contentful can reach your server through the firewall.
Prevention
- Test webhook endpoints with
curlbefore configuring in Contentful - Use a valid SSL certificate from a trusted CA
- Respond to webhook requests within 30 seconds
- Monitor webhook logs for failed deliveries
Common Mistakes with webhook
- Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
These mistakes appear frequently in real-world CONTENTFUL code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro