Anchor to themeFilesCopytheme
themeFilesCopy
mutation
Requires The user needs write_themes and an exemption from Shopify to modify theme files. If you think that your app is eligible for an exemption and should have access to this API, then you can submit an exception request.
Copy theme files. Copying to existing theme files will overwrite them.
Anchor to Arguments
Arguments
- Anchor to filesfiles•[Theme
Files requiredCopy File Input!]! The files to update.
- Anchor to themeIdtheme•
Id ID!required The theme to update.
Was this section helpful?
Anchor to ThemeFilesCopyPayload returnsThemeFilesCopyPayload returns
- Anchor to copiedThemeFilescopied•
Theme Files The resulting theme files.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
- Copy the content of a file into another file
- Creates or updates an asset for a theme
- themeFilesCopy reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) {
themeFilesCopy(files: $files, themeId: $themeId) {
copiedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
{
"dstFilename": "templates/index.alt.json",
"srcFilename": "templates/index.json"
}
]
},
},
);
const data = await response.json();
mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) {
themeFilesCopy(files: $files, themeId: $themeId) {
copiedThemeFiles {
filename
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) { themeFilesCopy(files: $files, themeId: $themeId) { copiedThemeFiles { filename } userErrors { field message } } }",
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
{
"dstFilename": "templates/index.alt.json",
"srcFilename": "templates/index.json"
}
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) {
themeFilesCopy(files: $files, themeId: $themeId) {
copiedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
{
"dstFilename": "templates/index.alt.json",
"srcFilename": "templates/index.json"
}
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) {
themeFilesCopy(files: $files, themeId: $themeId) {
copiedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
{
"dstFilename": "templates/index.alt.json",
"srcFilename": "templates/index.json"
}
]
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation themeFilesCopy($files: [ThemeFilesCopyFileInput!]!, $themeId: ID!) {
themeFilesCopy(files: $files, themeId: $themeId) {
copiedThemeFiles {
filename
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [{"dstFilename"=>"templates/index.alt.json", "srcFilename"=>"templates/index.json"}]
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
{
"dstFilename": "templates/index.alt.json",
"srcFilename": "templates/index.json"
}
]
}
Response
JSON{
"themeFilesCopy": {
"copiedThemeFiles": [
{
"filename": "templates/index.alt.json"
}
],
"userErrors": []
}
}