Version: 2024-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"name\": \"Delivered every week and billed every three weeks\",\n \"merchantCode\": \"prepaid-weekly\",\n \"options\": [\n \"1 week\"\n ],\n \"sellingPlansToCreate\": [\n {\n \"name\": \"Delivered every week\",\n \"options\": \"1 Week(s)\",\n \"category\": \"SUBSCRIPTION\",\n \"billingPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 3,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n },\n \"pricingPolicies\": [\n {\n \"fixed\": {\n \"adjustmentType\": \"PERCENTAGE\",\n \"adjustmentValue\": {\n \"percentage\": 25.0\n }\n }\n }\n ],\n \"deliveryPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 1,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n }\n }\n ]\n },\n \"resources\": {\n \"productIds\": [\n \"gid://shopify/Product/121709582\"\n ],\n \"productVariantIds\": []\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {\n sellingPlanGroupCreate(input: $input, resources: $resources) {\n sellingPlanGroup {\n id\n sellingPlans(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"name\": \"Delivered every week and billed every three weeks\",\n \"merchantCode\": \"prepaid-weekly\",\n \"options\": [\n \"1 week\"\n ],\n \"sellingPlansToCreate\": [\n {\n \"name\": \"Delivered every week\",\n \"options\": \"1 Week(s)\",\n \"category\": \"SUBSCRIPTION\",\n \"billingPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 3,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n },\n \"pricingPolicies\": [\n {\n \"fixed\": {\n \"adjustmentType\": \"PERCENTAGE\",\n \"adjustmentValue\": {\n \"percentage\": 25.0\n }\n }\n }\n ],\n \"deliveryPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 1,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n }\n }\n ]\n },\n \"resources\": {\n \"productIds\": [\n \"gid://shopify/Product/121709582\"\n ],\n \"productVariantIds\": []\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 createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {\n sellingPlanGroupCreate(input: $input, resources: $resources) {\n sellingPlanGroup {\n id\n sellingPlans(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"name\": \"Delivered every week and billed every three weeks\",\n \"merchantCode\": \"prepaid-weekly\",\n \"options\": [\"1 week\"],\n \"sellingPlansToCreate\": [{\"name\"=>\"Delivered every week\", \"options\"=>\"1 Week(s)\", \"category\"=>\"SUBSCRIPTION\", \"billingPolicy\"=>{\"recurring\"=>{\"interval\"=>\"WEEK\", \"intervalCount\"=>3, \"anchors\"=>[{\"cutoffDay\"=>2, \"day\"=>4, \"type\"=>\"WEEKDAY\"}]}}, \"pricingPolicies\"=>[{\"fixed\"=>{\"adjustmentType\"=>\"PERCENTAGE\", \"adjustmentValue\"=>{\"percentage\"=>25.0}}}], \"deliveryPolicy\"=>{\"recurring\"=>{\"interval\"=>\"WEEK\", \"intervalCount\"=>1, \"anchors\"=>[{\"cutoffDay\"=>2, \"day\"=>4, \"type\"=>\"WEEKDAY\"}]}}}]\n },\n \"resources\": {\n \"productIds\": [\"gid://shopify/Product/121709582\"],\n \"productVariantIds\": []\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 createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {\n sellingPlanGroupCreate(input: $input, resources: $resources) {\n sellingPlanGroup {\n id\n sellingPlans(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"name\" => \"Delivered every week and billed every three weeks\",\n \"merchantCode\" => \"prepaid-weekly\",\n \"options\" => [\"1 week\"],\n \"sellingPlansToCreate\" => [{\"name\"=>\"Delivered every week\", \"options\"=>\"1 Week(s)\", \"category\"=>\"SUBSCRIPTION\", \"billingPolicy\"=>{\"recurring\"=>{\"interval\"=>\"WEEK\", \"intervalCount\"=>3, \"anchors\"=>[{\"cutoffDay\"=>2, \"day\"=>4, \"type\"=>\"WEEKDAY\"}]}}, \"pricingPolicies\"=>[{\"fixed\"=>{\"adjustmentType\"=>\"PERCENTAGE\", \"adjustmentValue\"=>{\"percentage\"=>25.0}}}], \"deliveryPolicy\"=>{\"recurring\"=>{\"interval\"=>\"WEEK\", \"intervalCount\"=>1, \"anchors\"=>[{\"cutoffDay\"=>2, \"day\"=>4, \"type\"=>\"WEEKDAY\"}]}}}],\n ],\n \"resources\" => [\n \"productIds\" => [\"gid://shopify/Product/121709582\"],\n \"productVariantIds\" => [],\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 createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {\n sellingPlanGroupCreate(input: $input, resources: $resources) {\n sellingPlanGroup {\n id\n sellingPlans(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"name\": \"Delivered every week and billed every three weeks\",\n \"merchantCode\": \"prepaid-weekly\",\n \"options\": [\n \"1 week\"\n ],\n \"sellingPlansToCreate\": [\n {\n \"name\": \"Delivered every week\",\n \"options\": \"1 Week(s)\",\n \"category\": \"SUBSCRIPTION\",\n \"billingPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 3,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n },\n \"pricingPolicies\": [\n {\n \"fixed\": {\n \"adjustmentType\": \"PERCENTAGE\",\n \"adjustmentValue\": {\n \"percentage\": 25.0\n }\n }\n }\n ],\n \"deliveryPolicy\": {\n \"recurring\": {\n \"interval\": \"WEEK\",\n \"intervalCount\": 1,\n \"anchors\": [\n {\n \"cutoffDay\": 2,\n \"day\": 4,\n \"type\": \"WEEKDAY\"\n }\n ]\n }\n }\n }\n ]\n },\n \"resources\": {\n \"productIds\": [\n \"gid://shopify/Product/121709582\"\n ],\n \"productVariantIds\": []\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {\n sellingPlanGroupCreate(input: $input, resources: $resources) {\n sellingPlanGroup {\n id\n sellingPlans(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "name": "Delivered every week and billed every three weeks", "merchantCode": "prepaid-weekly", "options": [ "1 week" ], "sellingPlansToCreate": [ { "name": "Delivered every week", "options": "1 Week(s)", "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 3, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25.0 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }
response: { "data": { "sellingPlanGroupCreate": { "sellingPlanGroup": { "id": "gid://shopify/SellingPlanGroup/1039518901", "sellingPlans": { "edges": [ { "node": { "id": "gid://shopify/SellingPlan/1070277392" } } ] } }, "userErrors": [] } } }