Duplicate theme via API

Highlighted
Shopify Partner
12 0 7

As far as I can tell there is no way to duplicate a theme via the API, and it is only possible to create a new theme by passing the URL to some .zip file:

I guess the only way to do it right now would be to do something crazy like copy asset by asset, but I don't think that is really a solution. Could the 'src' field not also simply accept a theme ID from which to duplicate, or some special store path like '/admin/themes/123456789.zip'? Is there another way?

By the way, I bet this would be useful for Theme Kit too (not sure how they were planning to do it):

1 Like
Highlighted
Shopify Expert
9925 103 1765

Theme ID is nice in theory but what stops someone from grabbing a theme they shouldn't have access to via just that ID? You can assume theme ownership on a single store based on the owner of the key calling the "duplicate" function, but it gets trickier when you're wanting to clone into a totally different store. That needs two points of authentication.

Many themes are not licenced for multiple store uses in any case.

The themes also don't live in a ZIP file so the export feature (the one that triggers when you click on theme download) would need to be wrapped into a new API endpoint.

So right now it's an asset transfer. What's the issue with that method? Once the automation is setup it's generally pretty swift to duplicate themes.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
12 0 7

I really only mean to match the functionality present in the admin (duplicating an existing theme, e.g. to work on without affecting the currently published theme). I don't think there would be any need to duplicate across stores, and as such, I don't think there should be anything wrong with using the theme ID.

The asset transfer method seems incredibly wasteful (some themes have many many files) when it could be handled so much more efficiently server side (and the API call rate is limited, so even with good concurrency, this would be quite slow for larger themes). I'm hoping to automate our workflow for customising client themes, but if I had to do it this way, it would likely just slow us down (think a full theme download with Theme Kit vs duplicate theme in the Shopify admin). If this were for some background task I might be able to live with that, but my use case is interactive.

0 Likes
Highlighted
Shopify Partner
12 0 7

As an example, one of the themes used by a client of ours has around 300 files. Presumably it takes a GET and a PUT request to transfer an asset. So with a limit of 2 calls per second, I can potentially tranfer all the assets in around 6 minutes. On the other hand, duplicating a theme takes a matter of seconds. Sorry if I've got something fundamentally wrong here by the way!

0 Likes
Highlighted
Shopify Partner
3 0 2

We are looking for a programmatic method to duplicating the theme as well.

 

Our standard procedure for updating a theme on live is to duplicate the theme prior to overwriting the live theme as a backup measure. It also generally contains settings json files that we do not track in the theme after release.

 

Since there's no way to duplicate the theme outside of the admin portal, we need a human to do this each time. This would end up saving us countless hours for release control purposes. Absolutely nothing out there doing this now.

2 Likes
Highlighted
Excursionist
12 0 2

Same issue here. Our pre-deployment process involves duplicating the live theme of all our stores, of which we have 4, renaming each so it doesn't say "Copy of..." - quite painful and you'd think would be quite easy to implement into the API. Shame this forum is full of great suggestions that get ignored for years :D

0 Likes