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
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();
mutation fileDelete($input: [ID!]!) {
fileDelete(fileIds: $input) {
deletedFileIds
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/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
JSON{
"input": [
"gid://shopify/GenericFile/1072273199",
"gid://shopify/MediaImage/1072273200",
"gid://shopify/Video/1072273201"
]
}
Response
JSON{
"fileDelete": {
"deletedFileIds": [
"gid://shopify/GenericFile/1072273199",
"gid://shopify/MediaImage/1072273200",
"gid://shopify/Video/1072273201"
]
}
}