Overview
The webhooks API provides functions for managing shop-specific webhook subscriptions and validating webhook requests. For most apps, app-specific webhooks are recommended. Access the webhooks API through your configured Shopify instance:validate()
Validates an incoming HTTP webhook request from Shopify. This is the primary function you’ll use for both app-specific and shop-specific webhooks.Signature
Parameters
The raw request body as a string.
The raw HTTP request object from your framework.
The raw HTTP response object from your framework.
Returns
Returns aPromise<WebhookValidation> with the following possible structures:
Valid Webhook
Indicates the webhook is valid.
The shop domain.
The webhook topic (e.g.,
PRODUCTS_CREATE).The HMAC signature from the request.
The API version of the webhook.
The webhook ID (for webhooks).
The event ID.
The webhook sub-topic (if applicable).
Invalid Webhook
Indicates the webhook is invalid.
The reason for validation failure:
missing_headers- Required headers are missinginvalid_hmac- HMAC validation failedinvalid_body- Body is invalid
Array of missing header names (when reason is
missing_headers).Example
addHandlers()
Adds shop-specific webhook handlers to the library registry. Only needed for shop-specific webhooks. Use app-specific webhooks instead in most cases.Signature
Parameters
An object mapping webhook topics to their handlers.
Handler Types
HTTP Handler
EventBridge Handler
PubSub Handler
Example
register()
Registers shop-specific webhooks with Shopify. Only needed for shop-specific webhooks.Signature
Parameters
The session for the shop to register webhooks.
Returns
Returns aPromise<RegisterReturn> - an object mapping topics to their registration results.
Array of registration results for each topic.
Example
process()
Processes an incoming shop-specific webhook request and calls the registered callback. Only needed for shop-specific webhooks.Signature
Parameters
The raw request body.
The raw HTTP request.
The raw HTTP response.
Example
getTopicsAdded()
Returns all topics that have been added to the registry.Signature
Example
getHandlers()
Returns the handlers for a specific topic.Signature
Example
Types
DeliveryMethod
WebhookOperation
WebhookHandlerFunction
Common Webhook Topics
Some commonly used webhook topics:PRODUCTS_CREATE- Product createdPRODUCTS_UPDATE- Product updatedPRODUCTS_DELETE- Product deletedORDERS_CREATE- Order createdORDERS_UPDATED- Order updatedORDERS_PAID- Order paidORDERS_FULFILLED- Order fulfilledCUSTOMERS_CREATE- Customer createdCUSTOMERS_UPDATE- Customer updatedCUSTOMERS_DELETE- Customer deletedCUSTOMERS_DATA_REQUEST- GDPR data requestCUSTOMERS_REDACT- GDPR redaction requestSHOP_REDACT- GDPR shop data deletion
Notes
Use app-specific webhooks for most use cases. They’re easier to set up and don’t require shop-specific registration.Learn about app-specific vs shop-specific webhooks
The
validate() function works for both app-specific and shop-specific webhooks.Always validate webhooks before processing them to ensure they came from Shopify.
You must use
express.text() or equivalent middleware to get the raw body for webhook validation.