Shopify Webhooks: Implementation Guide

Webhooks allow your systems to receive real-time notifications when events occur in your Shopify store. Instead of repeatedly polling the API to check for changes, webhooks push data to your server the moment something happens—an order is placed, a product is updated, or a customer registers. This guide covers how to implement and manage webhooks.

What Are Webhooks?

Webhooks are HTTP callbacks that send data to your server when events occur:

  • Event occurs: Customer places an order
  • Shopify sends data: POST request to your endpoint URL
  • Your server responds: Processes data and returns 200 OK

This enables real-time integrations without constantly checking for changes.

Common Webhook Events

Orders

  • orders/create: New order placed
  • orders/updated: Order modified
  • orders/cancelled: Order cancelled
  • orders/fulfilled: Order shipped
  • orders/paid: Payment completed

Products

  • products/create: New product added
  • products/update: Product modified
  • products/delete: Product removed

Customers

  • customers/create: New customer registered
  • customers/update: Customer info changed

Inventory

  • inventory_levels/update: Stock level changed

Creating Webhooks

Via Shopify Admin

  1. Go to Settings > Notifications
  2. Scroll to Webhooks
  3. Click Create webhook
  4. Select the event (e.g., "Order creation")
  5. Choose format (JSON recommended)
  6. Enter your endpoint URL
  7. Click Save

Via API

Create webhooks programmatically using the Admin API:

POST /admin/api/2024-01/webhooks.json
{
  "webhook": {
    "topic": "orders/create",
    "address": "https://example.com/webhooks/orders",
    "format": "json"
  }
}

Receiving Webhooks

Your endpoint must:

  • Accept POST requests
  • Return HTTP 200 within 5 seconds
  • Process data asynchronously for long operations

Example Payload (Order Created)

{
  "id": 820982911946154508,
  "email": "customer@example.com",
  "created_at": "2024-01-15T10:30:00-05:00",
  "total_price": "99.99",
  "line_items": [...]
}

Security: Verifying Webhooks

Always verify webhooks are authentic before processing:

  1. Get the X-Shopify-Hmac-Sha256 header from the request
  2. Compute HMAC-SHA256 of the raw request body using your shared secret
  3. Base64 encode your computed hash
  4. Compare to the header value (timing-safe comparison)
  5. Reject if they don't match

Verification Example (PHP)

$hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
$data = file_get_contents('php://input');
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, $shared_secret, true));
$verified = hash_equals($hmac_header, $calculated_hmac);

Handling Retries

Shopify retries failed webhooks:

  • Retries occur for 48 hours if endpoint fails
  • Exponential backoff between retries
  • Webhook is marked "failed" after 19 retries
  • Duplicate webhooks may arrive—design for idempotency

Best Practices

  • Respond quickly: Return 200 immediately, process asynchronously
  • Handle duplicates: Use order/event IDs to prevent double-processing
  • Log everything: Store raw payloads for debugging
  • Monitor failures: Set up alerts for endpoint errors

Webhook Use Cases

  • ERP integration: Sync orders to accounting/inventory systems
  • Email notifications: Trigger custom emails on events
  • Fulfillment: Send orders to 3PL providers
  • Analytics: Track events in external analytics platforms
  • CRM updates: Sync customer data to CRM systems

Product and Collection Updates

Webhooks for product events can trigger updates to related systems when your collections change:

  • Sync product changes to external catalogs
  • Update search indexes when products change
  • Notify systems when inventory levels change
Automate Collection Updates: AWSM Collections automatically manages collection membership based on rules, reducing the need for custom webhook-based collection management.

Troubleshooting

Common Issues

  • Webhook not triggering: Verify the subscription is active and the event type is correct
  • Endpoint returning errors: Check server logs, verify URL is accessible
  • Verification failing: Ensure you're using the correct shared secret
  • Timeouts: Return 200 faster, process in background

Conclusion

Webhooks enable real-time integrations that keep your systems synchronized with your Shopify store. Always verify webhook authenticity, respond quickly to avoid timeouts, and design your processing to handle duplicates. For complex integrations, consider using a message queue to decouple receiving webhooks from processing them.

Related Resources

Disclaimer: While we strive to provide accurate and up-to-date information, we cannot guarantee the correctness of all content.
Information may be outdated or incorrect, and we recommend verifying any information before relying on it.