Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) { discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) { codeDiscountNode { codeDiscount { ... on DiscountCodeBxgy { title codes(first: 10) { nodes { code } } endsAt } } } userErrors { field code message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/732991387\",\n \"bxgyCodeDiscount\": {\n \"endsAt\": \"2022-12-25T00:00:00Z\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/732991387\",\n \"bxgyCodeDiscount\": {\n \"endsAt\": \"2022-12-25T00:00:00Z\"\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountCodeNode/732991387\",\n \"bxgyCodeDiscount\": {\n \"endsAt\": \"2022-12-25T00:00:00Z\"\n }\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountCodeNode/732991387\",\n \"bxgyCodeDiscount\" => [\n \"endsAt\" => \"2022-12-25T00:00:00Z\",\n ],\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountCodeNode/732991387\",\n \"bxgyCodeDiscount\": {\n \"endsAt\": \"2022-12-25T00:00:00Z\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}"
input: { "id": "gid://shopify/DiscountCodeNode/732991387", "bxgyCodeDiscount": { "endsAt": "2022-12-25T00:00:00Z" } }
response: { "data": { "discountCodeBxgyUpdate": { "codeDiscountNode": { "codeDiscount": { "title": "simple_bogo", "codes": { "nodes": [ { "code": "BOGO" } ] }, "endsAt": "2022-12-25T00:00:00Z" } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) { discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) { codeDiscountNode { codeDiscount { ... on DiscountCodeBxgy { title codes(first: 10) { nodes { code } } customerBuys { value { ... on DiscountQuantity { quantity } } items { ... on DiscountProducts { productVariants(first: 5) { nodes { id } } } } } customerGets { value { ... on DiscountOnQuantity { effect { ... on DiscountPercentage { percentage } } } } items { ... on DiscountProducts { products(first: 5) { nodes { id } } } } } } } } userErrors { field code message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/101551934\",\n \"bxgyCodeDiscount\": {\n \"customerBuys\": {\n \"items\": {\n \"products\": {\n \"productVariantsToAdd\": [\n \"gid://shopify/ProductVariant/138327650\"\n ]\n }\n },\n \"value\": {\n \"quantity\": \"2\"\n }\n },\n \"customerGets\": {\n \"items\": {\n \"products\": {\n \"productsToAdd\": [\n \"gid://shopify/Product/121709582\"\n ]\n }\n },\n \"value\": {\n \"discountOnQuantity\": {\n \"effect\": {\n \"percentage\": 0.5\n }\n }\n }\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n }\n items {\n ... on DiscountProducts {\n productVariants(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n effect {\n ... on DiscountPercentage {\n percentage\n }\n }\n }\n }\n items {\n ... on DiscountProducts {\n products(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/101551934\",\n \"bxgyCodeDiscount\": {\n \"customerBuys\": {\n \"items\": {\n \"products\": {\n \"productVariantsToAdd\": [\n \"gid://shopify/ProductVariant/138327650\"\n ]\n }\n },\n \"value\": {\n \"quantity\": \"2\"\n }\n },\n \"customerGets\": {\n \"items\": {\n \"products\": {\n \"productsToAdd\": [\n \"gid://shopify/Product/121709582\"\n ]\n }\n },\n \"value\": {\n \"discountOnQuantity\": {\n \"effect\": {\n \"percentage\": 0.5\n }\n }\n }\n }\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n }\n items {\n ... on DiscountProducts {\n productVariants(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n effect {\n ... on DiscountPercentage {\n percentage\n }\n }\n }\n }\n items {\n ... on DiscountProducts {\n products(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountCodeNode/101551934\",\n \"bxgyCodeDiscount\": {\n \"customerBuys\": {\n \"items\": {\n \"products\": {\n \"productVariantsToAdd\": [\"gid://shopify/ProductVariant/138327650\"]\n }\n },\n \"value\": {\n \"quantity\": \"2\"\n }\n },\n \"customerGets\": {\n \"items\": {\n \"products\": {\n \"productsToAdd\": [\"gid://shopify/Product/121709582\"]\n }\n },\n \"value\": {\n \"discountOnQuantity\": {\n \"effect\": {\n \"percentage\": 0.5\n }\n }\n }\n }\n }\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n }\n items {\n ... on DiscountProducts {\n productVariants(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n effect {\n ... on DiscountPercentage {\n percentage\n }\n }\n }\n }\n items {\n ... on DiscountProducts {\n products(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountCodeNode/101551934\",\n \"bxgyCodeDiscount\" => [\n \"customerBuys\" => [\n \"items\" => [\n \"products\" => [\n \"productVariantsToAdd\" => [\"gid://shopify/ProductVariant/138327650\"],\n ],\n ],\n \"value\" => [\n \"quantity\" => \"2\",\n ],\n ],\n \"customerGets\" => [\n \"items\" => [\n \"products\" => [\n \"productsToAdd\" => [\"gid://shopify/Product/121709582\"],\n ],\n ],\n \"value\" => [\n \"discountOnQuantity\" => [\n \"effect\" => [\n \"percentage\" => 0.5,\n ],\n ],\n ],\n ],\n ],\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 discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n }\n items {\n ... on DiscountProducts {\n productVariants(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n effect {\n ... on DiscountPercentage {\n percentage\n }\n }\n }\n }\n items {\n ... on DiscountProducts {\n products(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountCodeNode/101551934\",\n \"bxgyCodeDiscount\": {\n \"customerBuys\": {\n \"items\": {\n \"products\": {\n \"productVariantsToAdd\": [\n \"gid://shopify/ProductVariant/138327650\"\n ]\n }\n },\n \"value\": {\n \"quantity\": \"2\"\n }\n },\n \"customerGets\": {\n \"items\": {\n \"products\": {\n \"productsToAdd\": [\n \"gid://shopify/Product/121709582\"\n ]\n }\n },\n \"value\": {\n \"discountOnQuantity\": {\n \"effect\": {\n \"percentage\": 0.5\n }\n }\n }\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation discountCodeBxgyUpdate($id: ID!, $bxgyCodeDiscount: DiscountCodeBxgyInput!) {\n discountCodeBxgyUpdate(id: $id, bxgyCodeDiscount: $bxgyCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n }\n items {\n ... on DiscountProducts {\n productVariants(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n effect {\n ... on DiscountPercentage {\n percentage\n }\n }\n }\n }\n items {\n ... on DiscountProducts {\n products(first: 5) {\n nodes {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}"
input: { "id": "gid://shopify/DiscountCodeNode/101551934", "bxgyCodeDiscount": { "customerBuys": { "items": { "products": { "productVariantsToAdd": [ "gid://shopify/ProductVariant/138327650" ] } }, "value": { "quantity": "2" } }, "customerGets": { "items": { "products": { "productsToAdd": [ "gid://shopify/Product/121709582" ] } }, "value": { "discountOnQuantity": { "effect": { "percentage": 0.5 } } } } } }
response: { "data": { "discountCodeBxgyUpdate": { "codeDiscountNode": { "codeDiscount": { "title": "simple_bxgy", "codes": { "nodes": [ { "code": "BXGY" } ] }, "customerBuys": { "value": { "quantity": "2" }, "items": { "productVariants": { "nodes": [ { "id": "gid://shopify/ProductVariant/30322695" }, { "id": "gid://shopify/ProductVariant/138327650" } ] } } }, "customerGets": { "value": { "effect": { "percentage": 0.5 } }, "items": { "products": { "nodes": [ { "id": "gid://shopify/Product/121709582" } ] } } } } }, "userErrors": [] } } }