Skip to main content

Authentication

Custom headers

Use custom authentication headers (e.g., X-API-Key, Authorization) to verify webhook source. Configure your endpoint to reject requests that don’t include the expected authentication header.

IP allowlisting

Restrict webhook endpoints to accept requests only from ButterCMS IP ranges. This provides an additional layer of security by ensuring only legitimate sources can reach your endpoint.

HTTPS only

Always use HTTPS endpoints to ensure encrypted data transmission. Never accept webhooks over plain HTTP in production environments.

Payload validation

Verify headers

Check authentication headers before processing webhook payload. Reject requests immediately if authentication fails.

Validate structure

Ensure payload matches expected webhook event schema. Malformed payloads may indicate tampering or misconfiguration.

Idempotency

Handle duplicate webhook deliveries gracefully using event IDs or timestamps. The same webhook may be delivered multiple times.

Implementing custom header authentication

The most common approach to securing webhooks is using a shared secret in a custom header:

Step 1: Generate a secret key

Create a strong, random secret key to use for webhook authentication:

Step 2: Configure ButterCMS

When setting up your webhook in ButterCMS, add a custom header:
Custom headers are configured in the ButterCMS webhook settings alongside the endpoint URL and event selection.

Step 3: Verify the secret in your endpoint

Node.js / Express

Python / Flask

PHP / Laravel

IP allowlisting

For additional security, configure your firewall or web server to only accept webhook requests from ButterCMS IP addresses.
IP addresses may change over time. Contact ButterCMS support for the current list of IP ranges used for webhook delivery, and subscribe to updates.

Nginx configuration example

AWS Security Group

If hosting on AWS, create a security group rule that only allows inbound traffic on your webhook port from ButterCMS IP ranges.

Request validation

Beyond authentication, validate the incoming request to ensure it’s a legitimate webhook:

Validate content type

Validate payload structure

Validate timestamp freshness

Reject webhooks with timestamps that are too old to prevent replay attacks:

Handling duplicate webhooks

ButterCMS may deliver the same webhook multiple times (at-least-once delivery). Implement idempotency to handle duplicates gracefully:

Using database tracking

Using Redis for distributed systems

Security checklist

Use this checklist to ensure your webhook endpoint is properly secured:
  • HTTPS enabled - Endpoint uses TLS encryption
  • Secret header configured - Custom authentication header is set and verified
  • Content-Type validated - Only accept application/json requests
  • Payload structure validated - Check for required fields
  • Event types validated - Only process known event types
  • Timestamp checked - Reject stale webhooks
  • Idempotency implemented - Handle duplicate deliveries
  • Rate limiting configured - Protect against abuse
  • Logging enabled - Track all webhook activity
  • Errors handled gracefully - Don’t leak internal details

Rate limiting

Protect your endpoint from abuse by implementing rate limiting: