Detecting app blocks and app embed blocks

It appears that I can detect whether my app is embedded via the dying REST, but how to do it with graphQL? This is part of my app install automation …

Detecting app blocks and app embed blocks

Anchor link to section titled “Detecting app blocks and app embed blocks”

If you want to identify whether a merchant has added app blocks to their theme, or enabled app embed blocks, you can use the Asset REST Admin API resource to look for blocks that match your app type. …

Any suggestions?

1 Like

I believe you should be able to use this to get the content of theme files.

With that you should be able to query for the files and check the templates to see if any of them are using the app blocks and app embed blocks.

You may want to use the .dev Assistant to help generate some code for fetching what you want.

Check this one admin-graphql

I’ve completed the implementation, and it works 100% on my side.

  1. Add permission to read theme: scopes = “write_products,read_themes”
  2. Then make a request to get the configuration of theme, you will see the data response contains all the apps embed enable or not
export const action: ActionFunction = async ({request}) => {
  const body = await request.json()

  try {
    const {session} = await authenticate.admin(request);

    if (!session.accessToken) {
      throw new Error("Missing access token");
    }

    const response = await fetch(
      `https://${session.shop}/admin/api/2025-07/themes/${body.themeId}/assets.json?asset[key]=config/settings_data.json`,
      {
        method: "GET",
        headers: {
          "X-Shopify-Access-Token": session.accessToken as string, // ✅ force to string
          "Content-Type": "application/json",
        },
      }
    );
    if (!response.ok) {
      throw new Error(
        `Failed to fetch settings_data.json: ${response.status} ${response.statusText}`
      );
    }

    const result = await response.json();

    const settingsData = result.asset?.value
      ? JSON.parse(result.asset.value)
      : {};
    return json({settingsData});
  } catch (error) {
    return json({error: "Failed to load shop data"}, {status: 500});
  }
};