collection Deletemutation
mutation
2024-10latest
Requires write
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.
Arguments
The collection to delete.
Was this section helpful?
CollectionDeletePayload returns
Anchor to CollectionDeletePayload.deletedCollectionIddeletedCollection Id The ID of the collection that was deleted. Returns
null
if the collection doesn't exist.The shop associated with the collection.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: collectionDelete
Query Reference for MUTATION: collectionDelete
"mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n # Shop fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: collectionDelete
"{\n \"input\": {\n \"id\": \"gid://shopify/<objectName>/10079785100\"\n }\n}"
Schema Reference for MUTATION: collectionDelete
"input CollectionDeleteInput {\n id: ID!\n}\n"
Display Examples for MUTATION: collectionDelete
[ { "example": { "type_name": "collectiondelete", "title": "Delete a collection", "description": "Deletes the collection with the specified ID.\n", "query_string": "mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "id": "gid://shopify/Collection/1009501285" } }, "response": { "data": { "collectionDelete": { "deletedCollectionId": "gid://shopify/Collection/1009501285", "shop": { "id": "gid://shopify/Shop/26371970", "name": "Snowdevil" }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/mutations/collection_delete_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation collectionDelete($input: CollectionDeleteInput!) { collectionDelete(input: $input) { deletedCollectionId shop { id name } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Collection/1009501285\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The collection to delete.", "type": { "kind": "INPUT_OBJECT", "name": "CollectionDeleteInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CollectionDeleteInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"id\":\"gid://shopify/Collection/1009501285\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "collectiondelete", "title": "Delete a collection that doesn't exist", "description": "If a collection with the specified ID doesn't exist, then the mutation returns an error.\n", "query_string": "mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "id": "gid://shopify/Collection/-1" } }, "response": { "data": { "collectionDelete": { "deletedCollectionId": null, "shop": { "id": "gid://shopify/Shop/26371970", "name": "Snowdevil" }, "userErrors": [ { "field": [ "id" ], "message": "Collection does not exist" } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/mutations/collection_delete_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation collectionDelete($input: CollectionDeleteInput!) { collectionDelete(input: $input) { deletedCollectionId shop { id name } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/-1\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Collection/-1\"\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Collection/-1\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/-1\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Collection/-1\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The collection to delete.", "type": { "kind": "INPUT_OBJECT", "name": "CollectionDeleteInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CollectionDeleteInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"id\":\"gid://shopify/Collection/-1\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "collectiondelete", "title": "Delete collection fails if call to CollectionsAccess returns false", "description": "Restrict ability to delete a collection if the Shop is on Starter Plan.\n", "query_string": "mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "id": "gid://shopify/Collection/1009501285" } }, "response": { "errors": [ { "message": "Access denied for collectionDelete field. Required access: `write_products` access scope. Also: The store must not be on the Starter or Retail plans and user must have a permission to delete collection.", "locations": [ { "line": 2, "column": 3 } ], "path": [ "collectionDelete" ], "extensions": { "code": "ACCESS_DENIED", "documentation": "https://shopify.dev/api/usage/access-scopes", "requiredAccess": "`write_products` access scope. Also: The store must not be on the Starter or Retail plans and user must have a permission to delete collection." } } ], "data": { "collectionDelete": null } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/mutations/collection_delete_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation collectionDelete($input: CollectionDeleteInput!) { collectionDelete(input: $input) { deletedCollectionId shop { id name } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Collection/1009501285\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation collectionDelete($input: CollectionDeleteInput!) {\n collectionDelete(input: $input) {\n deletedCollectionId\n shop {\n id\n name\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Collection/1009501285\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The collection to delete.", "type": { "kind": "INPUT_OBJECT", "name": "CollectionDeleteInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CollectionDeleteInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"id\":\"gid://shopify/Collection/1009501285\"}", "typeKind": "MUTATION" } ] } ]