Avelero handles webhooks from integrated platforms to keep data synchronized and comply with platform requirements. This guide covers Shopify webhooks, GDPR compliance handling, and webhook security.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Avelero/avelero/llms.txt
Use this file to discover all available pages before exploring further.
Shopify webhooks
Shopify sends webhooks to Avelero for GDPR compliance and data management.Mandatory compliance webhooks
Shopify requires all apps to handle three compliance webhooks:customers/data_request
customers/data_request
Purpose: Triggered when a customer requests their data from a Shopify store.Avelero’s handling: No action taken. Avelero only has
read_products scope and does not store any customer data.Response: 200 OK (acknowledges receipt)Payload structure:customers/redact
customers/redact
Purpose: Triggered when a store owner requests customer data deletion (GDPR right to erasure).Avelero’s handling: No action taken. Avelero does not store customer data.Response: 200 OK (acknowledges receipt)Payload structure:
shop/redact
shop/redact
Purpose: Sent 48 hours after a store uninstalls the Avelero app. Requires deletion of all shop data.Avelero’s handling:
- Deletes brand integration record for the shop
- Deletes any pending installation records
- Product data is retained (belongs to brand, not Shopify)
Webhook endpoint
All Shopify compliance webhooks are sent to a unified endpoint:X-Shopify-Topic header determines which handler processes the webhook.
Webhook headers
Shopify includes several headers with webhook requests:Webhook topic (e.g.,
customers/data_request, shop/redact)HMAC signature for verifying webhook authenticity (base64-encoded)
Shop domain that triggered the webhook
Shopify API version used to generate the webhook
Always
application/json for compliance webhooksHMAC verification
All Shopify webhooks must be verified to prevent spoofing and replay attacks.How HMAC works
Shopify signs webhooks using HMAC-SHA256:- Shopify generates a hash of the raw request body using the app’s client secret
- Shopify base64-encodes the hash and includes it in the
X-Shopify-Hmac-Sha256header - Avelero receives the webhook and recomputes the hash using the same secret
- Avelero compares the computed hash to the header value
- If hashes match, the webhook is authentic; otherwise, it’s rejected
HMAC verification implementation
Avelero verifies all incoming Shopify webhooks:Verification function
- Use the raw request body (before JSON parsing)
- Hash encoding is base64 (not hex)
- Use client secret (not access token)
- Comparison must be constant-time to prevent timing attacks
Verification flow
Avelero’s webhook handler verifies requests before processing:HMAC verification errors
Missing HMAC header
Missing HMAC header
Status: 401 UnauthorizedCause: Request doesn’t include
X-Shopify-Hmac-Sha256 header.Resolution: This indicates a spoofed request. Reject it.Invalid HMAC signature
Invalid HMAC signature
Status: 401 UnauthorizedCause: Computed hash doesn’t match header value.Possible reasons:
- Wrong client secret configured
- Request body was modified in transit
- Replay attack attempt
- Request not from Shopify
Server configuration error
Server configuration error
Status: 500 Internal Server ErrorCause:
SHOPIFY_CLIENT_SECRET environment variable not configured.Resolution: Set the client secret in environment configuration.Invalid Content-Type
Invalid Content-Type
Status: 400 Bad RequestCause: Content-Type is not
application/json.Resolution: Shopify compliance webhooks are always JSON. Reject non-JSON requests.Security best practices
Always verify HMAC
Never process webhooks without HMAC verification. This prevents webhook spoofing and injection attacks.
Use raw body
Compute HMAC using the raw request body before JSON parsing. Body modification invalidates the signature.
Protect client secret
Store client secret in environment variables, never in code. Rotate secrets if compromised.
Constant-time comparison
Use timing-safe comparison to prevent timing attacks that could leak hash information.
Webhook handler implementation
Unified handler
Avelero uses a single endpoint for all compliance webhooks:Webhook router
Error handling
Webhook handlers must handle errors gracefully: Return 200 OK even on errors:- Prevents Shopify from retrying (compliance webhooks don’t need retry)
- Logs errors for debugging without blocking Shopify
Error handling example
shop/redact implementation
Theshop/redact webhook requires special handling:
Data deletion logic
What gets deleted
Integration connection record linking brand to Shopify shop
Pending OAuth installations not yet claimed
Shopify access tokens (cascade delete via foreign key)
What gets retained
All product records remain in Avelero
Variant data is preserved for compliance and history
Links between Shopify entities and Avelero entities (orphaned but not deleted)
Product data is retained because it represents the brand’s catalog and may be required for regulatory compliance. The integration is removed, but the data persists.
Testing webhooks
Shopify provides tools for testing webhook handling:Using Shopify CLI
Trigger test webhook
Manual testing
Generate a valid HMAC signature for testing:Generate test HMAC
X-Shopify-Hmac-Sha256 header.
Validation checklist
Valid webhook is accepted
Valid webhook is accepted
- Generate valid HMAC signature
- Send POST request with correct headers
- Verify response is 200 OK
- Check logs confirm processing
Invalid HMAC is rejected
Invalid HMAC is rejected
- Send request with wrong HMAC
- Verify response is 401 Unauthorized
- Confirm webhook is not processed
Missing header is rejected
Missing header is rejected
- Send request without
X-Shopify-Hmac-Sha256 - Verify response is 401 Unauthorized
shop/redact deletes data
shop/redact deletes data
- Send valid
shop/redactwebhook - Verify integration record is deleted
- Confirm products are retained
Webhook retry behavior
Shopify’s webhook retry policy:- First attempt: Immediate
- Retry attempts: Up to 19 retries over 48 hours
- Backoff: Exponential backoff between retries
- Success criteria: HTTP 200-299 response
- Always return 200 OK for compliance webhooks
- Log errors internally without failing the webhook
- Prevents unnecessary retries for intentional no-ops
Security considerations
Webhook spoofing prevention
Replay attack prevention
While Shopify webhooks don’t include timestamps, Avelero mitigates replay attacks:- HMAC verification ensures request came from Shopify
- Idempotent handlers ensure duplicate webhooks are safe
- shop/redact handler deletes records only if they exist (no error if already deleted)
Debugging webhooks
When webhooks fail:Check logs
Avelero logs webhook activity:Webhook logging
Common issues
Webhook never arrives
Webhook never arrives
Causes:
- Webhook URL not registered in Shopify app settings
- Firewall blocking Shopify’s IP range
- Server not responding to Shopify requests
- Check Shopify Partner dashboard webhook settings
- Verify endpoint is publicly accessible
- Test with curl from external server
HMAC verification always fails
HMAC verification always fails
Causes:
- Wrong client secret configured
- Request body modified before verification
- Using hex encoding instead of base64
- Log computed hash and header hash for comparison
- Verify client secret matches Shopify app credentials
- Ensure raw body is used (not parsed JSON)
Data not deleted on shop/redact
Data not deleted on shop/redact
Causes:
- Database query error
- Shop domain mismatch
- Integration already deleted
- Check database logs for errors
- Verify shop_domain matches database record
- Confirm deletion query is executed
API reference
Webhook endpoint
X-Shopify-Topic(required) - Webhook topicX-Shopify-Hmac-Sha256(required) - HMAC signatureContent-Type: application/json(required)
200 OK- Webhook processed successfully400 Bad Request- Missing topic or invalid content type401 Unauthorized- Invalid HMAC signature500 Internal Server Error- Server configuration error
Database operations
Delete integration:Next steps
Shopify integration
Learn how to set up and configure the Shopify integration.
GDPR compliance
Understand data privacy and GDPR compliance in Avelero.