# commentDelete - admin - MUTATION Version: unstable ## Description Deletes a comment. ### Access Scopes Any of `write_content`, `write_online_store_pages` access scopes. ## Arguments * [id](/docs/api/admin/unstable/scalars/ID): ID! - The ID of the comment to be deleted. ## Returns * [deletedCommentId](/docs/api/admin/unstable/scalars/ID): ID The ID of the comment that was deleted. * [userErrors](/docs/api/admin/unstable/objects/CommentDeleteUserError): CommentDeleteUserError! The list of errors that occurred from executing the mutation. ## Examples ### Attempting to delete a non-existent comment Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation DeleteComment($id: ID!) { commentDelete(id: $id) { deletedCommentId userErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Comment/9001\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Comment/9001\"\n },\n },\n});\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 DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Comment/9001\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Comment/9001\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Comment/9001" } #### Graphql Response { "data": { "commentDelete": { "deletedCommentId": null, "userErrors": [ { "field": [ "id" ], "message": "Comment does not exist" } ] } } } ### Deleting a comment with proper permissions Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation DeleteComment($id: ID!) { commentDelete(id: $id) { deletedCommentId userErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n});\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 DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Comment/757536350\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Comment/757536350" } #### Graphql Response { "data": { "commentDelete": { "deletedCommentId": "gid://shopify/Comment/757536350", "userErrors": [] } } } ### Failing to delete a comment due to missing access scopes Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation DeleteComment($id: ID!) { commentDelete(id: $id) { deletedCommentId userErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n});\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 DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Comment/757536350\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation DeleteComment($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Comment/757536350" } #### Graphql Response { "errors": [ { "message": "Access denied for commentDelete field. Required access: Any of `write_content`, `write_online_store_pages` access scopes.", "locations": [ { "line": 2, "column": 3 } ], "path": [ "commentDelete" ], "extensions": { "code": "ACCESS_DENIED", "documentation": "https://shopify.dev/api/usage/access-scopes", "requiredAccess": "Any of `write_content`, `write_online_store_pages` access scopes." } } ], "data": { "commentDelete": null } } ### Removes a comment Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CommentDelete($id: ID!) { commentDelete(id: $id) { deletedCommentId userErrors { code field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CommentDelete($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n});\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 CommentDelete($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Comment/757536350\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CommentDelete($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Comment/757536350\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CommentDelete($id: ID!) {\n commentDelete(id: $id) {\n deletedCommentId\n userErrors {\n code\n field\n message\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Comment/757536350" } #### Graphql Response { "data": { "commentDelete": { "deletedCommentId": "gid://shopify/Comment/757536350", "userErrors": [] } } }