You can use these triggers to start a job when a Shopify event occurs.


Triggers

All triggers can be create folllowing the same pattern:

shopify.on("topic")
topic
string

The webhook topic you want to subscribe to. Generally a pattern of <resource>/<action>.

Helpers

The filter() method returns a new trigger with the applied payload filter:

const trigger = shopify.on("topic").filter(filter)
filter
EventFilter
required

A filter to apply to the event. See our EventFilter guide.

Events

What follows is a small selection of webhook topics and associated payloads. A complete list of possible topic names and payloads can be found here.

fulfillments/create

Occurs when a fulfillment is created. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("fulfillments/create"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

inventory_items/update

Occurs when an inventory item is updated. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("inventory_items/update"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

orders/delete

Occurs when a order is deleted. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("orders/delete"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

orders/paid

Occurs when an order is paid. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("orders/paid"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

products/create

Occurs when a product is created. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("products/create"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

products/delete

Occurs when a product is deleted. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("products/delete"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

subscription_billing_attempts/failure

Occurs when a subscription billing attempt has failed. Official Shopify docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: shopify.on("subscription_billing_attempts/failure"),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});