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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) { automaticDiscountNode { id } userErrors { field message } } }\",\n \"variables\": {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": 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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": 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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": 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 = <<<QUERY\n mutation M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"freeShippingAutomaticDiscount\" => [\n \"title\" => \"New Auto Free Shipping Discount\",\n \"startsAt\" => \"2022-05-11T22:30:47Z\",\n \"destination\" => [\n \"all\" => true,\n ],\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => \"1\",\n ],\n ],\n \"combinesWith\" => [\n \"orderDiscounts\" => true,\n \"productDiscounts\" => 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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "freeShippingAutomaticDiscount": { "title": "New Auto Free Shipping Discount", "startsAt": "2022-05-11T22:30:47Z", "destination": { "all": true }, "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": "1" } }, "combinesWith": { "orderDiscounts": true, "productDiscounts": true } } }
response: { "data": { "discountAutomaticFreeShippingCreate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371269" }, "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 discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticFreeShipping { title startsAt endsAt minimumRequirement { ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount currencyCode } } } destinationSelection { ... on DiscountCountryAll { allCountries } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"automaticFreeShippingDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"endsAt\": \"2022-06-11T22:30:47Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"10.00\"\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 discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\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 \"automaticFreeShippingDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"endsAt\": \"2022-06-11T22:30:47Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"10.00\"\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 discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\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 \"automaticFreeShippingDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"endsAt\": \"2022-06-11T22:30:47Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"10.00\"\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 = <<<QUERY\n mutation discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\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\n$variables = [\n \"automaticFreeShippingDiscount\" => [\n \"title\" => \"New Auto Free Shipping Discount\",\n \"startsAt\" => \"2022-05-11T22:30:47Z\",\n \"endsAt\" => \"2022-06-11T22:30:47Z\",\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => \"10.00\",\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 discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\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 \"automaticFreeShippingDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"endsAt\": \"2022-06-11T22:30:47Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"10.00\"\n }\n },\n \"destination\": {\n \"all\": true\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation discountAutomaticFreeShippingCreate($automaticFreeShippingDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $automaticFreeShippingDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "automaticFreeShippingDiscount": { "title": "New Auto Free Shipping Discount", "startsAt": "2022-05-11T22:30:47Z", "endsAt": "2022-06-11T22:30:47Z", "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": "10.00" } }, "destination": { "all": true } } }
response: { "data": { "discountAutomaticFreeShippingCreate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371275", "automaticDiscount": { "title": "New Auto Free Shipping Discount", "startsAt": "2022-05-11T22:30:47Z", "endsAt": "2022-06-11T22:30:47Z", "minimumRequirement": { "greaterThanOrEqualToSubtotal": { "amount": "10.0", "currencyCode": "USD" } }, "destinationSelection": { "allCountries": true } } }, "userErrors": [] } } }