Security
How to handle Shopify's mandatory compliance webhooks
data_request, customers/redact and shop/redact: what each asks, the 30 days you have, the 401 rule, and mistakes that pass review but delete nothing.
· 6 min read
Every app in the Shopify App Store must answer three privacy webhooks, whether or not it keeps any personal data. Shopify checks that they are there before it reviews your app, and rejects the app if they are missing. What review cannot check is whether your endpoint actually finds and deletes anything. This guide covers both: what Shopify requires, and how to make the three webhooks do their job.
The three topics
Shopify takes one approach for everyone: public apps give the same privacy rights for all personal data, wherever the person lives, rather than one set of rules per country.
| Topic | What it asks | When it comes |
|---|---|---|
customers/data_request | Give the store owner the data you keep about one customer | When a customer asks the store for their data |
customers/redact | Delete the data you keep about one customer | 5 days after the store owner asks for the deletion (later if the customer is waiting for a scheduled gift card) |
shop/redact | Delete the data you keep about the whole store | 48 hours after the store uninstalls your app |
The first two reach your app only if it has access to the store's customer or order data. shop/redact reaches every app.
What Shopify requires
- Subscribe to all three before you submit the app for review. Without them the app is rejected.
- Accept a
POSTwith a JSON body andContent-Type: application/json. - Answer
401 Unauthorizedwhen the HMAC signature is wrong. - Answer with a 2xx status to confirm you received a genuine request, quickly: Shopify allows one second to connect and five seconds for the whole request, and treats anything outside 2xx, redirects included, as a failure.
- Do what was asked within 30 days. If a law requires you to keep some of the data, you keep it: Shopify says you should not complete a redaction the law forbids.
Subscribe in shopify.app.toml
Apps configured with the Shopify CLI list the three topics in their app configuration. One endpoint can take all three:
[webhooks]
api_version = "2026-10"
[[webhooks.subscriptions]]
compliance_topics = ["customers/data_request", "customers/redact", "shop/redact"]
uri = "https://app.example.com/webhooks"Then deploy the app configuration. Your endpoint learns which topic arrived from the X-Shopify-Topic header.
Verify the signature first
Each HTTPS delivery carries X-Shopify-Hmac-Sha256: a base64 HMAC-SHA256 of the raw request body, keyed with your app's client secret. Compute the same and compare in constant time; if it doesn't match, answer 401 and stop.
$raw = file_get_contents('php://input');
$sent = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'] ?? '';
$ours = base64_encode(hash_hmac('sha256', $raw, $clientSecret, true));
if (!hash_equals($ours, $sent)) {
http_response_code(401);
exit;
}A mistake Shopify warns about: a framework that parses the JSON body before your check runs. The parsed and re-encoded body is not the bytes Shopify signed, so the check fails for every real delivery. Read the raw body first, or put the verification before any body parser.
If you rotate your client secret, Shopify says it can take up to an hour before deliveries are signed with the new one.
Make each one do its job
customers/data_request
The payload names the customer (id, email, phone) and the orders they asked about. You give the data to the store owner, not to the customer. A good answer needs a way to find everything you keep about one customer, across every table, which is easier to build before the first request than during it.
customers/redact
The payload names the customer and orders_to_redact. Delete or anonymise what you keep about that customer in that store only: the same email can belong to a customer of another store that still uses your app.
shop/redact
The store has been gone for 48 hours: delete what you keep about it. The risk here is forgetting a table. A list of tables written today misses the table someone adds next year.
Mistakes that pass review but delete nothing
- An endpoint that only verifies the signature. It answers
401to bad requests and200to good ones, so it passes every automatic check, and deletes nothing. - Searching encrypted columns with a plain
WHERE. If personal data is encrypted with a random nonce, the same email encrypts to a different value each time, soWHERE email = ?never matches. Find the rows another way (by order IDs, or by decrypting within one store) and test that a known row actually disappears. - Deleting what the law says to keep. Invoices and similar records can have a legal retention period. Keep them, and keep only them.
- Doing the work inside the request. A deletion that runs longer than five seconds counts as a failure. Answer
200first and do the work in a queue.
How to test it
shopify app webhook triggersends a test delivery of a topic to your endpoint. Shopify notes that it doesn't test your subscriptions.- Send one request with a wrong signature and check you get
401. - Seed two stores, redact one, and check that its rows are gone and the other store's are all still there. This is the test that catches the "verifies but deletes nothing" endpoint.
- Watch real deliveries, and failed ones, in your app's Logs in the Dev Dashboard.
A use case: the endpoint that did nothing
Our cash on delivery app had a compliance endpoint from the start. It verified the signature and answered correctly, so it passed review, and its body did nothing. Shopify received a 200 for every request and no row was ever deleted. We found it while checking our privacy policy against the code.
The fix did three things:
- One endpoint, three handlers. The existing endpoint now verifies the signature and hands each topic to its own handler, so the app configuration did not have to change.
- Customer erasure starts from the order IDs. Some of our customer data is encrypted, so a plain
WHEREon the email could never match; the handler works fromorders_to_redactand only then decrypts and compares, inside the one store. - Store erasure finds its own tables.
shop/redactlooks up every table with a shop column instead of keeping a list, so a table added later is covered without anyone remembering it. A data request is logged with its 30-day due date.
We checked it against the live endpoint with signed requests: an unsigned request got 401, and a signed shop/redact removed the test store's rows while another store's stayed exactly as they were.
The other app requirements Shopify is phasing in are in Shopify app security deadlines 2026–2027. If you run several apps, Hybrid Workspace keeps them on one screen, including the installs and uninstalls that start these webhooks.
Sources
- Privacy law compliance, Shopify developer documentation
- Verify webhook deliveries, Shopify developer documentation
- Webhook delivery structure, Shopify developer documentation
- App requirements checklist, Shopify developer documentation
- shopify app webhook trigger, Shopify CLI reference
- Monitoring and logs in the Dev Dashboard, Shopify developer documentation