Anchor to collectionDeletecollection
collectionDelete
mutation
Requires access scope. Also: The store must not be on the Starter or Retail plans and user must have a permission to delete collection.
Deletes a collection.
Anchor to Arguments
Arguments
- Anchor to inputinput•Collection
Delete requiredInput! The collection to delete.
Was this section helpful?
Anchor to CollectionDeletePayload returnsCollectionDeletePayload returns
- Anchor to deletedCollectionIddeleted•
Collection Id The ID of the collection that was deleted. Returns
null
if the collection doesn't exist.- Anchor to shopshop•Shop!non-null
The shop associated with the collection.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a collection
- Delete a collection that doesn't exist
- Delete collection fails if call to CollectionsAccess returns false
- Deletes a custom collection
- Removes a smart collection
- collectionDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation collectionDelete($input: CollectionDeleteInput!) {6 collectionDelete(input: $input) {7 deletedCollectionId8 shop {9 id10 name11 }12 userErrors {13 field14 message15 }16 }17 }`,18 {19 variables: {20 "input": {21 "id": "gid://shopify/Collection/1009501285"22 }23 },24 },25);2627const data = await response.json();28
mutation collectionDelete($input: CollectionDeleteInput!) {
collectionDelete(input: $input) {
deletedCollectionId
shop {
id
name
}
userErrors {
field
message
}
}
}
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 collectionDelete($input: CollectionDeleteInput!) { collectionDelete(input: $input) { deletedCollectionId shop { id name } userErrors { field message } } }",
"variables": {
"input": {
"id": "gid://shopify/Collection/1009501285"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation collectionDelete($input: CollectionDeleteInput!) {
collectionDelete(input: $input) {
deletedCollectionId
shop {
id
name
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/Collection/1009501285"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation collectionDelete($input: CollectionDeleteInput!) {
collectionDelete(input: $input) {
deletedCollectionId
shop {
id
name
}
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"id": "gid://shopify/Collection/1009501285"
}
},
},
});
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 collectionDelete($input: CollectionDeleteInput!) {
collectionDelete(input: $input) {
deletedCollectionId
shop {
id
name
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"id": "gid://shopify/Collection/1009501285"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": {3 "id": "gid://shopify/Collection/1009501285"4 }5}
Response
JSON1{2 "collectionDelete": {3 "deletedCollectionId": "gid://shopify/Collection/1009501285",4 "shop": {5 "id": "gid://shopify/Shop/26371970",6 "name": "Snowdevil"7 },8 "userErrors": []9 }10}