Anchor to fileDeletefile
fileDelete
mutation
Requires access scope. Also: Users must have delete files permissions.
Deletes existing file assets that were uploaded to Shopify.
Anchor to Arguments
Arguments
- Anchor to fileIdsfile•
Ids [ID!]!required The IDs of the files to be deleted.
Was this section helpful?
Anchor to FileDeletePayload returnsFileDeletePayload returns
- Anchor to deletedFileIdsdeleted•
File Ids The IDs of the deleted files.
- Anchor to userErrorsuser•
Errors [FilesUser non-nullError!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a list of files
- Deleting a file that doesn't exist returns an error
- fileDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation fileDelete($input: [ID!]!) {6 fileDelete(fileIds: $input) {7 deletedFileIds8 }9 }`,10 {11 variables: {12 "input": [13 "gid://shopify/GenericFile/1072273199",14 "gid://shopify/MediaImage/1072273200",15 "gid://shopify/Video/1072273201"16 ]17 },18 },19);2021const data = await response.json();22
mutation fileDelete($input: [ID!]!) {
fileDelete(fileIds: $input) {
deletedFileIds
}
}
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 fileDelete($input: [ID!]!) { fileDelete(fileIds: $input) { deletedFileIds } }",
"variables": {
"input": [
"gid://shopify/GenericFile/1072273199",
"gid://shopify/MediaImage/1072273200",
"gid://shopify/Video/1072273201"
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileDelete($input: [ID!]!) {
fileDelete(fileIds: $input) {
deletedFileIds
}
}`,
{
variables: {
"input": [
"gid://shopify/GenericFile/1072273199",
"gid://shopify/MediaImage/1072273200",
"gid://shopify/Video/1072273201"
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileDelete($input: [ID!]!) {
fileDelete(fileIds: $input) {
deletedFileIds
}
}`,
"variables": {
"input": [
"gid://shopify/GenericFile/1072273199",
"gid://shopify/MediaImage/1072273200",
"gid://shopify/Video/1072273201"
]
},
},
});
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 fileDelete($input: [ID!]!) {
fileDelete(fileIds: $input) {
deletedFileIds
}
}
QUERY
variables = {
"input": ["gid://shopify/GenericFile/1072273199", "gid://shopify/MediaImage/1072273200", "gid://shopify/Video/1072273201"]
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": [3 "gid://shopify/GenericFile/1072273199",4 "gid://shopify/MediaImage/1072273200",5 "gid://shopify/Video/1072273201"6 ]7}
Response
JSON1{2 "fileDelete": {3 "deletedFileIds": [4 "gid://shopify/GenericFile/1072273199",5 "gid://shopify/MediaImage/1072273200",6 "gid://shopify/Video/1072273201"7 ]8 }9}