If you need shop-specific webhooks (e.g., different topics for different shops), you can manage them via the ShopifyApp.configure block. ShopifyApp will automatically queue a background job during the OAuth callback or token exchange to ensure the specified webhooks exist for that shop.
Configuration Options
- Basic Subscription: Define
topic and path. - Field Filtering: Use
fields to receive only specific fields (note: you still receive a request on every update). - Metafields: Use
metafield_namespaces to include metafield data. If using fields, you must also include metafields in that array. - Webhook Filters: Use the
filter parameter to apply Shopify's webhook filters (e.g., price thresholds). - Job Namespacing: Use
webhook_jobs_namespace to change the directory where webhook jobs are located (e.g., shopify/webhooks).
Delivery Methods
You can also target external services:
- Amazon EventBridge: Set
delivery_method: :event_bridge and provide the ARN as the path. - Google Cloud Pub/Sub: Set
delivery_method: :pub_sub and provide a path in the format pubsub://[PROJECT-ID]:[PUB-SUB-TOPIC-ID].
Note: For EventBridge and Pub/Sub, you must implement your own handler to fetch and process webhooks from the queue.
ShopifyApp.configure do |config|
config.webhook_jobs_namespace = 'shopify/webhooks'
config.webhooks = [
{
topic: 'products/update',
path: 'api/webhooks/products_update',
fields: ['title', 'vendor'],
filter: "variants.price:>=10.00"
},
{
topic: 'orders/create',
path: 'api/webhooks/orders_create',
metafield_namespaces: ['app-namespace'],
},
{
delivery_method: :event_bridge,
topic: 'carts/update',
path: 'arn:aws:events....'
},
{
delivery_method: :pub_sub,
topic: 'carts/update',
path: 'pubsub://project-id:pub-sub-topic-id'
}
]
end