All jobs

Add the Mandatory Compliance Webhooks to a Shopify App

Yes. An agent subscribes your app to the three privacy compliance topics, writes a handler for each that reads your own data, tests them, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads how the app already receives webhooks before it adds three more, because Shopify refuses a public app listing until customers/data_request, customers/redact and shop/redact are handled, and the handlers have to fit the app's own data. In an app laid out like Shopify/shopify-app-template-react-router, shopify.app.toml declares webhook subscriptions under [webhooks] on API version 2026-10: app/uninstalled and app/scopes_update, each with a uri, plus a commented block that shows the three compliance topics declared with compliance_topics instead of topics. Routes are file-based through @react-router/fs-routes, so app/routes/webhooks.app.uninstalled.tsx exports an action that calls authenticate.webhook(request) from app/shopify.server.ts, logs the topic and shop, deletes the shop's sessions with Prisma and returns an empty Response; webhooks.app.scopes_update.tsx updates the session's scope. app/shopify.server.ts configures shopifyApp with PrismaSessionStorage, AppDistribution.AppStore and expiring offline tokens, and prisma/schema.prisma has a single Session model with shop, accessToken, userId, email and the person's name, which is the personal data this app holds. package.json pins @shopify/shopify-app-react-router 3 and Prisma 6, and .github/workflows/ci.yml runs tsc --noEmit, ESLint, prisma validate and the build on Node 22 and 24.

The agent uncomments and completes the three subscriptions in shopify.app.toml, each with its own uri under /webhooks/, and adds three route files. webhooks.customers.data_request.tsx reads the customer id and email from the payload, queries Session for rows whose email matches, and records the request with the shop, the customer and what was found, since the app must hand that data to the merchant within 30 days and the handler is where the trail starts. webhooks.customers.redact.tsx removes the matching personal fields from the shop's sessions and logs what was erased. webhooks.shop.redact.tsx, which arrives 48 hours after an uninstall, deletes every session for the shop, which the uninstall handler has usually done already, and is written so a second delivery finds nothing and still returns 200.

Every handler goes through authenticate.webhook, which verifies the HMAC and answers 401 on a bad signature before any code of the app's runs; the agent keeps that call first and returns an empty 200 only after the work, because Shopify retries a non-2xx and the handler must stay idempotent. Because the template has no afterAuth registration and the README says app-specific subscriptions belong in the TOML, nothing is registered in code; shopify app deploy syncs the subscriptions.

To check it, the agent runs npx tsc --noEmit, npm run lint, npx prisma generate && npx prisma validate and npm run build in its sandbox, exactly as CI does, and writes a small Vitest file that calls each action with a request signed with a test secret, once for a shop with sessions and once for an unknown shop, asserting the status and the rows left in a SQLite database. It also runs shopify webhook trigger for each topic against the local server to show the routes answer, and pastes the three deliveries into the pull request.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add the mandatory privacy compliance webhooks to this Shopify app. Read shopify.app.toml, app/shopify.server.ts, app/db.server.ts, app/routes.ts, every file under app/routes/ that starts with webhooks., prisma/schema.prisma, package.json, README.md and .github/workflows/ci.yml first. Declare customers/data_request, customers/redact and shop/redact as compliance_topics in the TOML, each with its own uri, and add one route file per topic that calls authenticate.webhook first, does the work against the Session model (report what personal data exists for the customer, erase the customer's personal fields, delete every session for the shop), stays idempotent on a repeated delivery, and returns an empty 200. Add Vitest tests that call each action with a signed request for a shop with sessions and for an unknown shop. Run tsc --noEmit, lint, prisma validate, the build and the tests in your sandbox, trigger each topic with the Shopify CLI against the local server, and open a pull request with the output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request changes shopify.app.toml and package.json and adds app/routes/webhooks.customers.data_request.tsx, app/routes/webhooks.customers.redact.tsx, app/routes/webhooks.shop.redact.tsx and a test file. Its description shows the three subscriptions as they now read in the TOML, the type check, lint, prisma validate and build output, the test results, and the response each topic got when triggered locally.

The CI workflow runs on the pull request across its Node and package manager matrix with the same steps. The existing uninstall and scopes handlers, the session storage and the Prisma schema are unchanged; the three new routes answer only their own paths. Nothing is deployed, so the subscriptions reach Shopify on the next shopify app deploy.

Before merging, a reviewer checks that the data request handler records enough to answer the merchant within the deadline, decides whether redaction should also reach any store the app keeps outside this database, and runs shopify app deploy so the Partner Dashboard shows the three topics as handled before the app is submitted.

Run it on every Shopify app about to be listed

An agency that ships several apps from the same template sends this body once per repository to POST /o/{org}/sessions, each with its own repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started instead of opening a second pull request. Each run reads its own data: an app with a Customer or Order table of its own gets handlers that erase those rows too, one on the Remix package gets the same routes with its imports, and one that already handles a topic gets only the missing ones.

A webhook_url on the key reports each run.completed with the pull request in result, and a run.failed names an app whose build did not pass in the sandbox before the change, which is worth fixing before a listing review anyway.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

The three topics are a listing requirement with a deadline attached, and the handlers are only right if they know where the app keeps personal data. The agent reads the schema and the existing handlers, writes the three routes in the app's own style, and proves them with signed requests and the Shopify CLI in its own sandbox, instead of leaving the first real delivery to be the test.

The type check, the tests, the build and the three triggered deliveries stay with the run and are pasted into the pull request, so the review is about what gets erased rather than whether the routes answer. Several apps can get the same handlers at once, each against its own data.

Frequently asked questions

Does Shopify send these to every app?

Public apps must handle all three to be listed; custom apps are not required to but may receive them. The handlers are the same either way, and authenticate.webhook verifies the signature before any handler runs.

What if the app stores no customer data?

Then the data request handler reports that nothing was found and the redact handler erases nothing, but both still exist and return 200, because Shopify checks that the endpoints respond. The pull request says what each handler found in this app's schema.

Why does shop/redact look redundant with app/uninstalled?

The uninstall handler already deletes the shop's sessions, and shop/redact arrives two days later as the final instruction to erase the shop. The handler is written to find nothing and still answer 200, so both orders are honoured without a duplicate-delete error.

Do I need to register anything in code?

No. The template's README recommends app-specific subscriptions in shopify.app.toml, which shopify app deploy syncs, and the pull request follows that. Shop-specific registration through afterAuth is not needed for compliance topics.

More Shopify app jobs

More jobs like this: Hand off a long task

Keep reading