App install on a store - how to add an app block to an existing theme template?

i’m developing an app.

When the app is installed on a store, it should change an online store template by adding an app block (or section).

For example, add an app block or add a collapsible row to the template.

How can I accomplish this task?

Thanks! jb

@den232 your app needs to provide the admin user with a deep link, which once user clicks or navigates to, it adds the app block to the theme.

1 Like

Thanks so much, @kjchabra . Next: Is it possible for a deep link to duplicate a template or add a new template?

Cheers jb

@den232 apologies for the late reply.

Yes you can duplicate a template via the Admin REST API using the Asset resource. You can call the PUT method if you know which template to duplicate.

Just be careful that if you are planning to build an app for the Shopify store you do need to request access from Shopify.

Starting with Admin API 2023-04, Asset resource PUT or DEL requests are restricted using the write_themes [access scope](https://shopify.dev/docs/api/usage/access-scopes).
If an app that's distributed in the Shopify App Store needs to use Asset resource PUT or DEL requests, then it needs to be
granted an exemption by Shopify to use the write_themes access scope.