Anchor to themeFilesDeletetheme
themeFilesDelete
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.
Deletes a theme's files.
Anchor to Arguments
Arguments
- Anchor to filesfiles•[String!]!required
The files to delete.
- Anchor to themeIdtheme•
Id ID!required Specifies the theme to deleted.
Was this section helpful?
Anchor to ThemeFilesDeletePayload returnsThemeFilesDeletePayload returns
- Anchor to deletedThemeFilesdeleted•
Theme Files The resulting theme files.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a theme file
- Deletes an asset from a theme
- themeFilesDelete reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation themeFilesDelete($themeId: ID!, $files: [String!]!) {
themeFilesDelete(themeId: $themeId, files: $files) {
deletedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
"templates/index.json"
]
},
},
);
const data = await response.json();
mutation themeFilesDelete($themeId: ID!, $files: [String!]!) {
themeFilesDelete(themeId: $themeId, files: $files) {
deletedThemeFiles {
filename
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation themeFilesDelete($themeId: ID!, $files: [String!]!) { themeFilesDelete(themeId: $themeId, files: $files) { deletedThemeFiles { filename } userErrors { field message } } }",
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
"templates/index.json"
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation themeFilesDelete($themeId: ID!, $files: [String!]!) {
themeFilesDelete(themeId: $themeId, files: $files) {
deletedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
"templates/index.json"
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation themeFilesDelete($themeId: ID!, $files: [String!]!) {
themeFilesDelete(themeId: $themeId, files: $files) {
deletedThemeFiles {
filename
}
userErrors {
field
message
}
}
}`,
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
"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 themeFilesDelete($themeId: ID!, $files: [String!]!) {
themeFilesDelete(themeId: $themeId, files: $files) {
deletedThemeFiles {
filename
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": ["templates/index.json"]
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"themeId": "gid://shopify/OnlineStoreTheme/529529152",
"files": [
"templates/index.json"
]
}
Response
JSON{
"themeFilesDelete": {
"deletedThemeFiles": [
{
"filename": "templates/index.json"
}
],
"userErrors": []
}
}