Create a TBYB selling plan group
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }
Variables
{ "input": { "name": "TBYB", "merchantCode": "tbyb", "options": [ "Try before you buy" ], "sellingPlansToCreate": [ { "name": "TBYB", "options": "Try free for 14 days", "category": "TRY_BEFORE_YOU_BUY", "billingPolicy": { "fixed": { "checkoutCharge": { "type": "PRICE", "value": { "fixedValue": 0 } }, "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout": "P14D" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "deliveryPolicy": { "fixed": { "fulfillmentTrigger": "ASAP" } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }", "variables": { "input": { "name": "TBYB", "merchantCode": "tbyb", "options": [ "Try before you buy" ], "sellingPlansToCreate": [ { "name": "TBYB", "options": "Try free for 14 days", "category": "TRY_BEFORE_YOU_BUY", "billingPolicy": { "fixed": { "checkoutCharge": { "type": "PRICE", "value": { "fixedValue": 0 } }, "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout": "P14D" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "deliveryPolicy": { "fixed": { "fulfillmentTrigger": "ASAP" } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } } }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, { variables: { "input": { "name": "TBYB", "merchantCode": "tbyb", "options": [ "Try before you buy" ], "sellingPlansToCreate": [ { "name": "TBYB", "options": "Try free for 14 days", "category": "TRY_BEFORE_YOU_BUY", "billingPolicy": { "fixed": { "checkoutCharge": { "type": "PRICE", "value": { "fixedValue": 0 } }, "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout": "P14D" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "deliveryPolicy": { "fixed": { "fulfillmentTrigger": "ASAP" } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }, }, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } } QUERY variables = { "input": { "name": "TBYB", "merchantCode": "tbyb", "options": [ "Try before you buy" ], "sellingPlansToCreate": [ { "name": "TBYB", "options": "Try free for 14 days", "category": "TRY_BEFORE_YOU_BUY", "billingPolicy": { "fixed": { "checkoutCharge": { "type": "PRICE", "value": { "fixedValue": 0 } }, "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout": "P14D" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "deliveryPolicy": { "fixed": { "fulfillmentTrigger": "ASAP" } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } } response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, "variables": { "input": { "name": "TBYB", "merchantCode": "tbyb", "options": [ "Try before you buy" ], "sellingPlansToCreate": [ { "name": "TBYB", "options": "Try free for 14 days", "category": "TRY_BEFORE_YOU_BUY", "billingPolicy": { "fixed": { "checkoutCharge": { "type": "PRICE", "value": { "fixedValue": 0 } }, "remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT", "remainingBalanceChargeTimeAfterCheckout": "P14D" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "deliveryPolicy": { "fixed": { "fulfillmentTrigger": "ASAP" } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }, }, });
Response
{ "sellingPlanGroupCreate": { "sellingPlanGroup": { "id": "gid://shopify/SellingPlanGroup/1039518935", "sellingPlans": { "edges": [ { "node": { "id": "gid://shopify/SellingPlan/1070277430" } } ] } }, "userErrors": [] } }
Create a prepaid selling plan group with anchor dates
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }
Variables
{ "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 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }", "variables": { "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 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } } }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, { variables: { "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 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }, }, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } } QUERY variables = { "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 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } } response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id } } } } userErrors { field message } } }`, "variables": { "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 } } } ], "deliveryPolicy": { "recurring": { "interval": "WEEK", "intervalCount": 1, "anchors": [ { "cutoffDay": 2, "day": 4, "type": "WEEKDAY" } ] } } } ] }, "resources": { "productIds": [ "gid://shopify/Product/121709582" ], "productVariantIds": [] } }, }, });
Response
{ "sellingPlanGroupCreate": { "sellingPlanGroup": { "id": "gid://shopify/SellingPlanGroup/1039518936", "sellingPlans": { "edges": [ { "node": { "id": "gid://shopify/SellingPlan/1070277431" } } ] } }, "userErrors": [] } }
Create a selling plan group with metafields
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } }
Variables
{ "input": { "name": "Subscribe and save", "merchantCode": "subscribe-and-save", "appId": "groovy", "options": [ "Delivery every", "Delivery interval", "Fun every" ], "position": 1, "description": "Subscribe and save group", "sellingPlansToCreate": [ { "name": "Pay every month deliver every month", "options": [ "1", "month", "day" ], "metafields": [ { "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield", "type": "single_line_text_field" } ], "position": 1, "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ] } }, "deliveryPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ], "cutoff": 5, "intent": "FULFILLMENT_BEGIN", "preAnchorBehavior": "ASAP" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } }, { "recurring": { "afterCycle": 3, "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 26 } } } ] } ] }, "resources": {} }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } }", "variables": { "input": { "name": "Subscribe and save", "merchantCode": "subscribe-and-save", "appId": "groovy", "options": [ "Delivery every", "Delivery interval", "Fun every" ], "position": 1, "description": "Subscribe and save group", "sellingPlansToCreate": [ { "name": "Pay every month deliver every month", "options": [ "1", "month", "day" ], "metafields": [ { "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield", "type": "single_line_text_field" } ], "position": 1, "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ] } }, "deliveryPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ], "cutoff": 5, "intent": "FULFILLMENT_BEGIN", "preAnchorBehavior": "ASAP" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } }, { "recurring": { "afterCycle": 3, "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 26 } } } ] } ] }, "resources": {} } }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } }`, { variables: { "input": { "name": "Subscribe and save", "merchantCode": "subscribe-and-save", "appId": "groovy", "options": [ "Delivery every", "Delivery interval", "Fun every" ], "position": 1, "description": "Subscribe and save group", "sellingPlansToCreate": [ { "name": "Pay every month deliver every month", "options": [ "1", "month", "day" ], "metafields": [ { "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield", "type": "single_line_text_field" } ], "position": 1, "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ] } }, "deliveryPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ], "cutoff": 5, "intent": "FULFILLMENT_BEGIN", "preAnchorBehavior": "ASAP" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } }, { "recurring": { "afterCycle": 3, "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 26 } } } ] } ] }, "resources": {} }, }, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } } QUERY variables = { "input": { "name": "Subscribe and save", "merchantCode": "subscribe-and-save", "appId": "groovy", "options": [ "Delivery every", "Delivery interval", "Fun every" ], "position": 1, "description": "Subscribe and save group", "sellingPlansToCreate": [ { "name": "Pay every month deliver every month", "options": [ "1", "month", "day" ], "metafields": [ { "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield", "type": "single_line_text_field" } ], "position": 1, "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ] } }, "deliveryPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ], "cutoff": 5, "intent": "FULFILLMENT_BEGIN", "preAnchorBehavior": "ASAP" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } }, { "recurring": { "afterCycle": 3, "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 26 } } } ] } ] }, "resources": {} } response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) { sellingPlanGroupCreate(input: $input, resources: $resources) { sellingPlanGroup { id sellingPlans(first: 1) { edges { node { id metafields(first: 1) { edges { node { id namespace key value } } } } } } } userErrors { field message } } }`, "variables": { "input": { "name": "Subscribe and save", "merchantCode": "subscribe-and-save", "appId": "groovy", "options": [ "Delivery every", "Delivery interval", "Fun every" ], "position": 1, "description": "Subscribe and save group", "sellingPlansToCreate": [ { "name": "Pay every month deliver every month", "options": [ "1", "month", "day" ], "metafields": [ { "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield", "type": "single_line_text_field" } ], "position": 1, "category": "SUBSCRIPTION", "billingPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ] } }, "deliveryPolicy": { "recurring": { "interval": "MONTH", "intervalCount": 1, "anchors": [ { "type": "MONTHDAY", "day": 26 } ], "cutoff": 5, "intent": "FULFILLMENT_BEGIN", "preAnchorBehavior": "ASAP" } }, "inventoryPolicy": { "reserve": "ON_SALE" }, "pricingPolicies": [ { "fixed": { "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 25 } } }, { "recurring": { "afterCycle": 3, "adjustmentType": "PERCENTAGE", "adjustmentValue": { "percentage": 26 } } } ] } ] }, "resources": {} }, }, });
Response
{ "sellingPlanGroupCreate": { "sellingPlanGroup": { "id": "gid://shopify/SellingPlanGroup/1039518934", "sellingPlans": { "edges": [ { "node": { "id": "gid://shopify/SellingPlan/1070277429", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069228936", "namespace": "for_testing", "key": "my_key", "value": "selling plan metafield" } } ] } } } ] } }, "userErrors": [] } }