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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } appSubscription { id } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"EVERY_30_DAYS\"}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Recurring Plan\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"EVERY_30_DAYS\"}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n}"
input: { "name": "Super Duper Recurring Plan", "returnUrl": "http://super-duper.shopifyapps.com/", "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 10.0, "currencyCode": "USD" }, "interval": "EVERY_30_DAYS" } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "appSubscription": { "id": "gid://shopify/AppSubscription/1029266964" }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266964/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBReWT06EmF1dG9fYWN0aXZhdGVU--40f1bb287931224ca72323613fc6255d8a38a2c8" } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } appSubscription { id lineItems { id plan { pricingDetails __typename } } } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"Super Duper Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails\n __typename\n }\n }\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails\n __typename\n }\n }\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails\n __typename\n }\n }\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Usage Plan\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"lineItems\" => [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails\n __typename\n }\n }\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails\n __typename\n }\n }\n }\n confirmationUrl\n }\n}"
input: { "name": "Super Duper Usage Plan", "returnUrl": "http://super-duper.shopifyapps.com/", "lineItems": [ { "plan": { "appUsagePricingDetails": { "terms": "$1 for 100 emails", "cappedAmount": { "amount": 20.0, "currencyCode": "USD" } } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "appSubscription": { "id": "gid://shopify/AppSubscription/1029266960", "lineItems": [ { "id": "gid://shopify/AppSubscriptionLineItem/1029266960?v=1&index=0", "plan": { "pricingDetails": {}, "__typename": "AppPlanV2" } } ] }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266960/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBBeWT06EmF1dG9fYWN0aXZhdGVU--6a3125051f687d95ba16132e5fb9a0419e0e4d18" } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } appSubscription { id } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"ANNUAL\"\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"ANNUAL\"\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"ANNUAL\"}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Recurring Plan\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"ANNUAL\"}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"ANNUAL\"\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n}"
input: { "name": "Super Duper Recurring Plan", "returnUrl": "http://super-duper.shopifyapps.com/", "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 10.0, "currencyCode": "USD" }, "interval": "ANNUAL" } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "appSubscription": { "id": "gid://shopify/AppSubscription/1029266967" }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266967/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBdeWT06EmF1dG9fYWN0aXZhdGVU--fe672a2422bba8ab370938f6f5f1df9aaf5ddd8d" } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } appSubscription { id lineItems { id plan { pricingDetails { __typename } } } } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"Super Duper Recurring and Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Recurring and Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Recurring and Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}, {\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Recurring and Usage Plan\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"lineItems\" => [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}, {\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Recurring and Usage Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n lineItems {\n id\n plan {\n pricingDetails {\n __typename\n }\n }\n }\n }\n confirmationUrl\n }\n}"
input: { "name": "Super Duper Recurring and Usage Plan", "returnUrl": "http://super-duper.shopifyapps.com/", "lineItems": [ { "plan": { "appUsagePricingDetails": { "terms": "$1 for 100 emails", "cappedAmount": { "amount": 20.0, "currencyCode": "USD" } } } }, { "plan": { "appRecurringPricingDetails": { "price": { "amount": 10.0, "currencyCode": "USD" } } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "appSubscription": { "id": "gid://shopify/AppSubscription/1029266961", "lineItems": [ { "id": "gid://shopify/AppSubscriptionLineItem/1029266961?v=1&index=0", "plan": { "pricingDetails": { "__typename": "AppRecurringPricing" } } }, { "id": "gid://shopify/AppSubscriptionLineItem/1029266961?v=1&index=1", "plan": { "pricingDetails": { "__typename": "AppUsagePricing" } } } ] }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266961/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBFeWT06EmF1dG9fYWN0aXZhdGVU--6385f33920ae03746bbd6dd9dd1c41bb13879f5f" } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } confirmationUrl appSubscription { id } } }\",\n \"variables\": {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"amount\": 5.0\n },\n \"durationLimitInIntervals\": 2\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n \"variables\": {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"amount\": 5.0\n },\n \"durationLimitInIntervals\": 2\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>40.0, \"currencyCode\"=>\"USD\"}, \"discount\"=>{\"value\"=>{\"amount\"=>5.0}, \"durationLimitInIntervals\"=>2}, \"interval\"=>\"EVERY_30_DAYS\"}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"30 Day Recurring Plan\",\n \"returnUrl\" => \"https://review-app.shopifyapps.com\",\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>40.0, \"currencyCode\"=>\"USD\"}, \"discount\"=>{\"value\"=>{\"amount\"=>5.0}, \"durationLimitInIntervals\"=>2}, \"interval\"=>\"EVERY_30_DAYS\"}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n {\n variables: {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"amount\": 5.0\n },\n \"durationLimitInIntervals\": 2\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n}"
input: { "name": "30 Day Recurring Plan", "returnUrl": "https://review-app.shopifyapps.com", "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 40.0, "currencyCode": "USD" }, "discount": { "value": { "amount": 5.0 }, "durationLimitInIntervals": 2 }, "interval": "EVERY_30_DAYS" } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266959/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBA9eWT06EmF1dG9fYWN0aXZhdGVU--f374cbfa230bebd8e270af37a779d920de2dfe69", "appSubscription": { "id": "gid://shopify/AppSubscription/1029266959" } } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) { userErrors { field message } appSubscription { id } confirmationUrl } }\",\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan with a Trial\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"trialDays\": 7,\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan with a Trial\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"trialDays\": 7,\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Recurring Plan with a Trial\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"trialDays\": 7,\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Recurring Plan with a Trial\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com/\",\n \"trialDays\" => 7,\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Recurring Plan with a Trial\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com/\",\n \"trialDays\": 7,\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $trialDays: Int) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, trialDays: $trialDays) {\n userErrors {\n field\n message\n }\n appSubscription {\n id\n }\n confirmationUrl\n }\n}"
input: { "name": "Super Duper Recurring Plan with a Trial", "returnUrl": "http://super-duper.shopifyapps.com/", "trialDays": 7, "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 10.0, "currencyCode": "USD" } } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "appSubscription": { "id": "gid://shopify/AppSubscription/1029266965" }, "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266965/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBVeWT06EmF1dG9fYWN0aXZhdGVU--f3e64505cf5f399b7e631756ff1d6c95f80af98c" } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } confirmationUrl appSubscription { id } } }\",\n \"variables\": {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"percentage\": 0.2\n },\n \"durationLimitInIntervals\": 10\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n \"variables\": {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"percentage\": 0.2\n },\n \"durationLimitInIntervals\": 10\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>40.0, \"currencyCode\"=>\"USD\"}, \"discount\"=>{\"value\"=>{\"percentage\"=>0.2}, \"durationLimitInIntervals\"=>10}, \"interval\"=>\"EVERY_30_DAYS\"}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"30 Day Recurring Plan\",\n \"returnUrl\" => \"https://review-app.shopifyapps.com\",\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>40.0, \"currencyCode\"=>\"USD\"}, \"discount\"=>{\"value\"=>{\"percentage\"=>0.2}, \"durationLimitInIntervals\"=>10}, \"interval\"=>\"EVERY_30_DAYS\"}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n {\n variables: {\n \"name\": \"30 Day Recurring Plan\",\n \"returnUrl\": \"https://review-app.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 40.0,\n \"currencyCode\": \"USD\"\n },\n \"discount\": {\n \"value\": {\n \"percentage\": 0.2\n },\n \"durationLimitInIntervals\": 10\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n}"
input: { "name": "30 Day Recurring Plan", "returnUrl": "https://review-app.shopifyapps.com", "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 40.0, "currencyCode": "USD" }, "discount": { "value": { "percentage": 0.2 }, "durationLimitInIntervals": 10 }, "interval": "EVERY_30_DAYS" } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266963/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBNeWT06EmF1dG9fYWN0aXZhdGVU--175a4c86f29fd8f88234ec365eec27ab2dc7d8e3", "appSubscription": { "id": "gid://shopify/AppSubscription/1029266963" } } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } confirmationUrl appSubscription { id } } }\",\n \"variables\": {\n \"name\": \"Subscription for Module A and Module B\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails for Module B\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 35.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n \"variables\": {\n \"name\": \"Subscription for Module A and Module B\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails for Module B\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 35.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Subscription for Module A and Module B\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails for Module B\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}, {\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>35.0, \"currencyCode\"=>\"USD\"}}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Subscription for Module A and Module B\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com\",\n \"lineItems\" => [{\"plan\"=>{\"appUsagePricingDetails\"=>{\"terms\"=>\"$1 for 100 emails for Module B\", \"cappedAmount\"=>{\"amount\"=>20.0, \"currencyCode\"=>\"USD\"}}}}, {\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>35.0, \"currencyCode\"=>\"USD\"}}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n {\n variables: {\n \"name\": \"Subscription for Module A and Module B\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appUsagePricingDetails\": {\n \"terms\": \"$1 for 100 emails for Module B\",\n \"cappedAmount\": {\n \"amount\": 20.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n },\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 35.0,\n \"currencyCode\": \"USD\"\n }\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n}"
input: { "name": "Subscription for Module A and Module B", "returnUrl": "http://super-duper.shopifyapps.com", "lineItems": [ { "plan": { "appUsagePricingDetails": { "terms": "$1 for 100 emails for Module B", "cappedAmount": { "amount": 20.0, "currencyCode": "USD" } } } }, { "plan": { "appRecurringPricingDetails": { "price": { "amount": 35.0, "currencyCode": "USD" } } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266966/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBZeWT06EmF1dG9fYWN0aXZhdGVU--f80e7f189ca7afad7364c4182577a8b8c801254f", "appSubscription": { "id": "gid://shopify/AppSubscription/1029266966" } } } }
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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) { appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) { userErrors { field message } confirmationUrl appSubscription { id } } }\",\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n \"variables\": {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"EVERY_30_DAYS\"}}}]\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"name\" => \"Super Duper Recurring Plan\",\n \"returnUrl\" => \"http://super-duper.shopifyapps.com\",\n \"lineItems\" => [{\"plan\"=>{\"appRecurringPricingDetails\"=>{\"price\"=>{\"amount\"=>10.0, \"currencyCode\"=>\"USD\"}, \"interval\"=>\"EVERY_30_DAYS\"}}}],\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 AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n }`,\n {\n variables: {\n \"name\": \"Super Duper Recurring Plan\",\n \"returnUrl\": \"http://super-duper.shopifyapps.com\",\n \"lineItems\": [\n {\n \"plan\": {\n \"appRecurringPricingDetails\": {\n \"price\": {\n \"amount\": 10.0,\n \"currencyCode\": \"USD\"\n },\n \"interval\": \"EVERY_30_DAYS\"\n }\n }\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {\n appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems) {\n userErrors {\n field\n message\n }\n confirmationUrl\n appSubscription {\n id\n }\n }\n}"
input: { "name": "Super Duper Recurring Plan", "returnUrl": "http://super-duper.shopifyapps.com", "lineItems": [ { "plan": { "appRecurringPricingDetails": { "price": { "amount": 10.0, "currencyCode": "USD" }, "interval": "EVERY_30_DAYS" } } } ] }
response: { "data": { "appSubscriptionCreate": { "userErrors": [], "confirmationUrl": "https://billingshop.myshopify.com/admin/charges/166357/1029266962/RecurringApplicationCharge/confirm_recurring_application_charge?signature=BAh7BzoHaWRpBBJeWT06EmF1dG9fYWN0aXZhdGVU--c94d382d1fe3012e03e22dcb2253e14d14933433", "appSubscription": { "id": "gid://shopify/AppSubscription/1029266962" } } } }