Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) { productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) { userErrors { field message code } deletedOptionsIds product { id options { id name values position optionValues { id name hasVariants } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/1064576514\"\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/1064576514\"\n ]\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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\"gid://shopify/ProductOption/1064576514\"]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/20995642\",\n \"options\" => [\"gid://shopify/ProductOption/1064576514\"],\n];\n\n$response = $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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/1064576514\"\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/20995642", "options": [ "gid://shopify/ProductOption/1064576514" ] }
response: { "data": { "productOptionsDelete": { "userErrors": [], "deletedOptionsIds": [ "gid://shopify/ProductOption/1064576514" ], "product": { "id": "gid://shopify/Product/20995642", "options": [ { "id": "gid://shopify/ProductOption/328272167", "name": "Title", "values": [ "151cm", "155cm", "158cm" ], "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/141051426", "name": "151cm", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/258076414", "name": "155cm", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/129596849", "name": "158cm", "hasVariants": true } ] } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) { productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) { userErrors { field message code } deletedOptionsIds product { id options { id name values position optionValues { id name hasVariants } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ],\n \"strategy\": \"POSITION\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ],\n \"strategy\": \"POSITION\"\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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\"gid://shopify/ProductOption/328272167\"],\n \"strategy\": \"POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/20995642\",\n \"options\" => [\"gid://shopify/ProductOption/328272167\"],\n \"strategy\" => \"POSITION\",\n];\n\n$response = $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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ],\n \"strategy\": \"POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/20995642", "options": [ "gid://shopify/ProductOption/328272167" ], "strategy": "POSITION" }
response: { "data": { "productOptionsDelete": { "userErrors": [], "deletedOptionsIds": [ "gid://shopify/ProductOption/328272167" ], "product": { "id": "gid://shopify/Product/20995642", "options": [ { "id": "gid://shopify/ProductOption/1064576513", "name": "Title", "values": [ "Default Title" ], "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054672239", "name": "Default Title", "hasVariants": true } ] } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) { productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) { userErrors { field message code } deletedOptionsIds product { id options { id name values position optionValues { id name hasVariants } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ]\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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\"gid://shopify/ProductOption/328272167\"]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/20995642\",\n \"options\" => [\"gid://shopify/ProductOption/328272167\"],\n];\n\n$response = $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 deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/20995642\",\n \"options\": [\n \"gid://shopify/ProductOption/328272167\"\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation deleteOptions($productId: ID!, $options: [ID!]!, $strategy: ProductOptionDeleteStrategy) {\n productOptionsDelete(productId: $productId, options: $options, strategy: $strategy) {\n userErrors {\n field\n message\n code\n }\n deletedOptionsIds\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/20995642", "options": [ "gid://shopify/ProductOption/328272167" ] }
response: { "data": { "productOptionsDelete": { "userErrors": [ { "field": [ "options" ], "message": "Cannot delete an option with multiple values.", "code": "CANNOT_DELETE_OPTION_WITH_MULTIPLE_VALUES" } ], "deletedOptionsIds": [], "product": { "id": "gid://shopify/Product/20995642", "options": [ { "id": "gid://shopify/ProductOption/328272167", "name": "Title", "values": [ "151cm", "155cm", "158cm" ], "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/141051426", "name": "151cm", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/258076414", "name": "155cm", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/129596849", "name": "158cm", "hasVariants": true } ] } ] } } } }