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 M($id: ID!, $freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) { automaticDiscountNode { automaticDiscount { ... on DiscountAutomaticFreeShipping { title } } } userErrors { message field code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371302\",\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"A new title\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation M($id: ID!, $freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371302\",\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"A new title\"\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 M($id: ID!, $freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371302\",\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"A new title\"\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 = <<\"gid://shopify/DiscountAutomaticNode/1057371302\",\n \"freeShippingAutomaticDiscount\" => [\n \"title\" => \"A new title\",\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 M($id: ID!, $freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371302\",\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"A new title\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation M($id: ID!, $freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n userErrors {\n message\n field\n code\n }\n }\n}"
input: { "id": "gid://shopify/DiscountAutomaticNode/1057371302", "freeShippingAutomaticDiscount": { "title": "A new title" } }
response: { "data": { "discountAutomaticFreeShippingUpdate": { "automaticDiscountNode": { "automaticDiscount": { "title": "A new title" } }, "userErrors": [] } } }
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 discountAutomaticFreeShippingUpdate($id: ID!, $automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticFreeShipping { title startsAt endsAt minimumRequirement { ... on DiscountMinimumQuantity { greaterThanOrEqualToQuantity } } destinationSelection { ... on DiscountCountryAll { allCountries } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371315\",\n \"automaticFreeShippingDiscount\": {\n \"title\": \"Updated Title\",\n \"startsAt\": \"2024-10-01T00:00:00Z\",\n \"endsAt\": \"2024-12-31T23:59:59Z\",\n \"minimumRequirement\": {\n \"quantity\": {\n \"greaterThanOrEqualToQuantity\": \"50\"\n }\n },\n \"destination\": {\n \"all\": true\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountAutomaticFreeShippingUpdate($id: ID!, $automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371315\",\n \"automaticFreeShippingDiscount\": {\n \"title\": \"Updated Title\",\n \"startsAt\": \"2024-10-01T00:00:00Z\",\n \"endsAt\": \"2024-12-31T23:59:59Z\",\n \"minimumRequirement\": {\n \"quantity\": {\n \"greaterThanOrEqualToQuantity\": \"50\"\n }\n },\n \"destination\": {\n \"all\": true\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 discountAutomaticFreeShippingUpdate($id: ID!, $automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371315\",\n \"automaticFreeShippingDiscount\": {\n \"title\": \"Updated Title\",\n \"startsAt\": \"2024-10-01T00:00:00Z\",\n \"endsAt\": \"2024-12-31T23:59:59Z\",\n \"minimumRequirement\": {\n \"quantity\": {\n \"greaterThanOrEqualToQuantity\": \"50\"\n }\n },\n \"destination\": {\n \"all\": true\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 = <<\"gid://shopify/DiscountAutomaticNode/1057371315\",\n \"automaticFreeShippingDiscount\" => [\n \"title\" => \"Updated Title\",\n \"startsAt\" => \"2024-10-01T00:00:00Z\",\n \"endsAt\" => \"2024-12-31T23:59:59Z\",\n \"minimumRequirement\" => [\n \"quantity\" => [\n \"greaterThanOrEqualToQuantity\" => \"50\",\n ],\n ],\n \"destination\" => [\n \"all\" => true,\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 discountAutomaticFreeShippingUpdate($id: ID!, $automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountAutomaticNode/1057371315\",\n \"automaticFreeShippingDiscount\": {\n \"title\": \"Updated Title\",\n \"startsAt\": \"2024-10-01T00:00:00Z\",\n \"endsAt\": \"2024-12-31T23:59:59Z\",\n \"minimumRequirement\": {\n \"quantity\": {\n \"greaterThanOrEqualToQuantity\": \"50\"\n }\n },\n \"destination\": {\n \"all\": true\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation discountAutomaticFreeShippingUpdate($id: ID!, $automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingUpdate(id: $id, freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "id": "gid://shopify/DiscountAutomaticNode/1057371315", "automaticFreeShippingDiscount": { "title": "Updated Title", "startsAt": "2024-10-01T00:00:00Z", "endsAt": "2024-12-31T23:59:59Z", "minimumRequirement": { "quantity": { "greaterThanOrEqualToQuantity": "50" } }, "destination": { "all": true } } }
response: { "data": { "discountAutomaticFreeShippingUpdate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371315", "automaticDiscount": { "title": "Updated Title", "startsAt": "2024-10-01T00:00:00Z", "endsAt": "2024-12-31T23:59:59Z", "minimumRequirement": { "greaterThanOrEqualToQuantity": "50" }, "destinationSelection": { "allCountries": true } } }, "userErrors": [] } } }