Loading...
Loading...
Guide for handling Shopify Webhooks, including configuration, verification, and processing. Use this skill when the user needs to set up webhook subscriptions, verify authentic requests, or handle event payloads.
npx skill4agent add toilahuongg/shopify-agents-kit shopify-webhooksorders/createapp/uninstalledX-Shopify-Hmac-Sha256[!IMPORTANT] Always use the raw request body (Buffer) for verification. Parsed JSON bodies may have subtle differences that cause verification to fail.
const crypto = require('crypto');
function verifyWebhook(rawBody, hmacHeader, apiSecret) {
const digest = crypto
.createHmac('sha256', apiSecret)
.update(rawBody, 'utf8')
.digest('base64');
return crypto.timingSafeEqual(
Buffer.from(digest),
Buffer.from(hmacHeader)
);
}@shopify/shopify-app-remixauthenticate.webhook/* app/routes/webhooks.tsx */
import { authenticate } from "../shopify.server";
export const action = async ({ request }) => {
const { topic, shop, session, admin, payload } = await authenticate.webhook(request);
if (!admin) {
// The webhook request was not valid.
return new Response();
}
switch (topic) {
case "APP_UNINSTALLED":
if (session) {
await db.session.deleteMany({ where: { shop } });
}
break;
case "ORDERS_CREATE":
console.log(`Order created: ${payload.id}`);
break;
}
return new Response();
};shopify.app.tomlapp/uninstalled[webhooks]
api_version = "2025-10"
[[webhooks.subscriptions]]
topics = [ "app/uninstalled", "orders/create" ]
uri = "/webhooks"webhookSubscriptionCreatemutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {
webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
userErrors {
field
message
}
webhookSubscription {
id
}
}
}shopify.app.tomlcustomers/data_requestcustomers/redactshop/redact[!WARNING] Failure to handle these can result in app removal.
200 OKapp/uninstalledapp/uninstalledAPP_UNINSTALLEDORDERS_CREATEORDERS_PAIDPRODUCTS_UPDATE