Create a TBYB selling plan group
Description
Create a try before you buy (TBYB) selling plan group where the customer pays nothing at checkout and the remaining balance is charged 14 days after checkout. The plan reserves inventory at the time of sale and fulfills the order as soon as possible. Use this pattern when a TBYB app lets customers try a product before they pay for it. Learn more about [building selling plan groups](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans/build-a-selling-plan).
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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/2026-07/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 name merchantCode options productsCount { count } sellingPlans(first: 1) { edges { node { id name category options billingPolicy { ... on SellingPlanFixedBillingPolicy { checkoutCharge { type value { ... on MoneyV2 { amount currencyCode } } } remainingBalanceChargeTrigger remainingBalanceChargeTimeAfterCheckout } } deliveryPolicy { ... on SellingPlanFixedDeliveryPolicy { fulfillmentTrigger } } inventoryPolicy { reserve } } } } } 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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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": []
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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": []
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-07/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanFixedBillingPolicy {
checkoutCharge {
type
value {
... on MoneyV2 {
amount
currencyCode
}
}
}
remainingBalanceChargeTrigger
remainingBalanceChargeTimeAfterCheckout
}
}
deliveryPolicy {
... on SellingPlanFixedDeliveryPolicy {
fulfillmentTrigger
}
}
inventoryPolicy {
reserve
}
}
}
}
}
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 { data } = await response.json();
console.log(data);
Response
{
"sellingPlanGroupCreate": {
"sellingPlanGroup": {
"id": "gid://shopify/SellingPlanGroup/1039518935",
"name": "TBYB",
"merchantCode": "tbyb",
"options": [
"Try before you buy"
],
"productsCount": {
"count": 1
},
"sellingPlans": {
"edges": [
{
"node": {
"id": "gid://shopify/SellingPlan/1070277430",
"name": "TBYB",
"category": "TRY_BEFORE_YOU_BUY",
"options": [
"Try free for 14 days"
],
"billingPolicy": {
"checkoutCharge": {
"type": "PRICE",
"value": {
"amount": "0.0",
"currencyCode": "USD"
}
},
"remainingBalanceChargeTrigger": "TIME_AFTER_CHECKOUT",
"remainingBalanceChargeTimeAfterCheckout": "P14D"
},
"deliveryPolicy": {
"fulfillmentTrigger": "ASAP"
},
"inventoryPolicy": {
"reserve": "ON_SALE"
}
}
}
]
}
},
"userErrors": []
}
}
Create a prepaid selling plan group with anchor dates
Description
Create a prepaid subscription where the customer is billed every three weeks and receives a delivery every week, and attach it to a product. The billing and delivery anchors use the `WEEKDAY` type with `day: 4` (Thursday) and `cutoffDay: 2` (Tuesday), where 1 is Monday. The fixed pricing policy takes 25% off the product price. Use this pattern when a subscription app sells a prepaid plan that ships on a fixed day of the week. The `productIds` field of the `resources` argument adds the product to the group in the same request.
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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/2026-07/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 name merchantCode options productsCount { count } sellingPlans(first: 1) { edges { node { id name category options billingPolicy { ... on SellingPlanRecurringBillingPolicy { interval intervalCount anchors { type day cutoffDay } } } deliveryPolicy { ... on SellingPlanRecurringDeliveryPolicy { interval intervalCount anchors { type day cutoffDay } } } pricingPolicies { ... on SellingPlanFixedPricingPolicy { adjustmentType adjustmentValue { ... on SellingPlanPricingPolicyPercentageValue { percentage } } } } } } } } 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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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": []
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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": []
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-07/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation createSellingPlanGroup($input: SellingPlanGroupInput!, $resources: SellingPlanGroupResourceInput) {
sellingPlanGroupCreate(input: $input, resources: $resources) {
sellingPlanGroup {
id
name
merchantCode
options
productsCount {
count
}
sellingPlans(first: 1) {
edges {
node {
id
name
category
options
billingPolicy {
... on SellingPlanRecurringBillingPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
deliveryPolicy {
... on SellingPlanRecurringDeliveryPolicy {
interval
intervalCount
anchors {
type
day
cutoffDay
}
}
}
pricingPolicies {
... on SellingPlanFixedPricingPolicy {
adjustmentType
adjustmentValue {
... on SellingPlanPricingPolicyPercentageValue {
percentage
}
}
}
}
}
}
}
}
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 { data } = await response.json();
console.log(data);
Response
{
"sellingPlanGroupCreate": {
"sellingPlanGroup": {
"id": "gid://shopify/SellingPlanGroup/1039518936",
"name": "Delivered every week and billed every three weeks",
"merchantCode": "prepaid-weekly",
"options": [
"1 week"
],
"productsCount": {
"count": 1
},
"sellingPlans": {
"edges": [
{
"node": {
"id": "gid://shopify/SellingPlan/1070277431",
"name": "Delivered every week",
"category": "SUBSCRIPTION",
"options": [
"1 Week(s)"
],
"billingPolicy": {
"interval": "WEEK",
"intervalCount": 3,
"anchors": [
{
"type": "WEEKDAY",
"day": 4,
"cutoffDay": 2
}
]
},
"deliveryPolicy": {
"interval": "WEEK",
"intervalCount": 1,
"anchors": [
{
"type": "WEEKDAY",
"day": 4,
"cutoffDay": 2
}
]
},
"pricingPolicies": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 25
}
}
]
}
}
]
}
},
"userErrors": []
}
}
Create a selling plan group with metafields
Description
Store app data on a selling plan as a metafield when you create the selling plan group, and read it back from the plan's `metafields` connection in the same response. The `$app` namespace stores the metafield in the app's reserved namespace, which the response returns as `app--` followed by the app's ID. Use this pattern when a subscription app keeps its own data for each plan, such as a delivery note, alongside the selling plan.
Query
mutation createSellingPlanGroup($input: SellingPlanGroupInput!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createSellingPlanGroup($input: SellingPlanGroupInput!) { sellingPlanGroupCreate(input: $input) { sellingPlanGroup { id name options sellingPlans(first: 1) { edges { node { id name options metafields(first: 1) { edges { node { id namespace key type value } } } } } } } userErrors { field message } } }",
"variables": {
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
}
}'
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!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
},
},
);
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!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
}
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!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation createSellingPlanGroup($input: SellingPlanGroupInput!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}' \
--variables \
'{
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-07/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation createSellingPlanGroup($input: SellingPlanGroupInput!) {
sellingPlanGroupCreate(input: $input) {
sellingPlanGroup {
id
name
options
sellingPlans(first: 1) {
edges {
node {
id
name
options
metafields(first: 1) {
edges {
node {
id
namespace
key
type
value
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
`,
variables: {
"input": {
"name": "Subscribe and save",
"merchantCode": "subscribe-and-save-monthly",
"options": [
"Delivery every"
],
"sellingPlansToCreate": [
{
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"category": "SUBSCRIPTION",
"metafields": [
{
"namespace": "$app",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
],
"billingPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"deliveryPolicy": {
"recurring": {
"interval": "MONTH",
"intervalCount": 1,
"anchors": [
{
"type": "MONTHDAY",
"day": 26
}
]
}
},
"pricingPolicies": [
{
"fixed": {
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
}
}
}
]
}
]
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"sellingPlanGroupCreate": {
"sellingPlanGroup": {
"id": "gid://shopify/SellingPlanGroup/1039518937",
"name": "Subscribe and save",
"options": [
"Delivery every"
],
"sellingPlans": {
"edges": [
{
"node": {
"id": "gid://shopify/SellingPlan/1070277432",
"name": "Delivered monthly, save 10%",
"options": [
"1 month"
],
"metafields": {
"edges": [
{
"node": {
"id": "gid://shopify/Metafield/1069228935",
"namespace": "app--388314853",
"key": "delivery_note",
"type": "single_line_text_field",
"value": "Ships on the 26th of each month"
}
}
]
}
}
}
]
}
},
"userErrors": []
}
}