Overview
ButterCMS webhooks enable real-time notifications when content changes occur in your account. When you publish a page, update a collection item, or create a blog post, ButterCMS sends an HTTP POST request to your configured endpoint with details about the change.Key use cases
- Cache Invalidation: Clear your CDN or application cache when content updates
- Static Site Rebuilds: Trigger a rebuild of your static site (Next.js, Gatsby, etc.)
- Multi-channel Publishing: Sync content to social media, email lists, or mobile apps
- Automated Workflows: Send Slack notifications, update analytics, or trigger deployments
How webhooks work
Configuring webhooks
Webhooks are configured through the ButterCMS dashboard.Step 1: access webhook settings
- Log in to your ButterCMS Dashboard
- Navigate to Settings > Webhooks
- Click Add Webhook
Step 2: configure endpoint
| Field | Description |
|---|---|
| URL | Your webhook endpoint URL (must be HTTPS) |
| Events | Select which content events trigger this webhook |
| Headers | Optional custom headers for authentication |
Webhooks require account-level enablement, and availability varies by plan. Contact support to enable webhooks for your account.
Step 3: select events
Choose which events should trigger webhooks: Page Events:page.published- Page is published or republishedpage.draft- Page is saved as draftpage.unpublished- Page is unpublishedpage.delete- Page is deletedpage.*- All page events
post.published- Post is publishedpost.draft- Post is saved as draftpost.delete- Post is deleted or unpublishedpost.*- All post events
collectionitem.published- Item is publishedcollectionitem.draft- Item is saved as draftcollectionitem.unpublished- Item is unpublishedcollectionitem.delete- Item is deletedcollectionitem.*- All collection events
Delivery guarantees
Webhooks are delivered asynchronously via a job queue. While webhook delivery is reliable under normal conditions, there is no automatic retry mechanism for failed deliveries. Implement idempotent handling in case the same event is delivered multiple times.
Response handling
| Scenario | ButterCMS Behavior |
|---|---|
| 2xx Response | Webhook delivered successfully |
| 4xx Response | Webhook failed (client error) |
| 5xx Response | Webhook failed (server error) |
| Timeout (5s) | Webhook failed (timeout) |
Timeout requirement
Your webhook endpoint must respond within 5 seconds. If your processing takes longer, return a200 immediately and process asynchronously.
Security best practices
Custom authentication headers
Add authentication headers to verify webhook requests originate from ButterCMS:Endpoint implementation
Additional security measures
- HTTPS Only: Always use HTTPS endpoints for encrypted transmission
- IP Allowlisting: Restrict access to ButterCMS IP ranges if possible
- Validate Payloads: Check that payload structure matches expected schema
- Idempotency: Handle duplicate deliveries using event timestamps or content IDs
Handling duplicates
Since webhooks may be delivered multiple times, implement idempotent processing:Testing webhooks
Local development
Use tools like ngrok or localtunnel to expose your local server:Webhook debugging
Log incoming webhooks for debugging:Next steps
Webhook Events
Event types and payloads
Cache Invalidation
Use webhooks for caching
Real-Time Sync
Real-time content sync
Monitoring
Monitoring and debugging