# appSubscriptionCreate - admin-graphql - MUTATION
Version: 2025-01

## Description
Allows an app to charge a store for features or services on a recurring basis.

### Access Scopes



## Arguments
* [lineItems](/docs/api/admin-graphql/2025-01/input-objects/AppSubscriptionLineItemInput): AppSubscriptionLineItemInput! - Attaches one or more pricing plans to an app subscription. Only one pricing plan can be defined for each available type.
* [name](/docs/api/admin-graphql/2025-01/scalars/String): String! - A descriptive name for the app subscription.
* [replacementBehavior](/docs/api/admin-graphql/2025-01/enums/AppSubscriptionReplacementBehavior): AppSubscriptionReplacementBehavior - The replacement behavior when creating an app subscription for a merchant with an already existing app subscription.
* [returnUrl](/docs/api/admin-graphql/2025-01/scalars/URL): URL! - The URL pointing to the page where the merchant is redirected after approving the app subscription.
* [test](/docs/api/admin-graphql/2025-01/scalars/Boolean): Boolean - Whether the app subscription is a test transaction.
* [trialDays](/docs/api/admin-graphql/2025-01/scalars/Int): Int - The number of days of the free trial period, beginning on the day that the merchant approves the app charges.


## Returns
* [appSubscription](/docs/api/admin-graphql/2025-01/objects/AppSubscription): AppSubscription The newly-created app subscription.
* [confirmationUrl](/docs/api/admin-graphql/2025-01/scalars/URL): URL The URL pointing to the page where the merchant approves or declines the charges for an app subscription.
* [userErrors](/docs/api/admin-graphql/2025-01/objects/UserError): UserError! The list of errors that occurred from executing the mutation.


## Examples
### Create a subscription for an app on a recurring pricing plan only.
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" 
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}"
#### Graphql 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"
        }
      }
    }
  ]
}
#### Graphql 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"
    }
  }
}

### Create a subscription for an app on a usage pricing plan only.
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" 
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}"
#### Graphql 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"
          }
        }
      }
    }
  ]
}
#### Graphql 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"
    }
  }
}

### Create a subscription for an app on an annual recurring pricing plan.
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" 
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}"
#### Graphql Input
{
  "name": "Super Duper Recurring Plan",
  "returnUrl": "http://super-duper.shopifyapps.com/",
  "lineItems": [
    {
      "plan": {
        "appRecurringPricingDetails": {
          "price": {
            "amount": 10.0,
            "currencyCode": "USD"
          },
          "interval": "ANNUAL"
        }
      }
    }
  ]
}
#### Graphql 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"
    }
  }
}

### Create a subscription for an app on both a recurring pricing plan and usage pricing plan.
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" 
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}"
#### Graphql 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"
          }
        }
      }
    }
  ]
}
#### Graphql 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"
    }
  }
}

### Create a subscription with a fixed amount discount
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" 
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}"
#### Graphql 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"
        }
      }
    }
  ]
}
#### Graphql 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"
      }
    }
  }
}

### Create a subscription with a free trial.
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" 
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}"
#### Graphql 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"
          }
        }
      }
    }
  ]
}
#### Graphql 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"
    }
  }
}

### Create a subscription with a percentage value discount
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" 
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}"
#### Graphql 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"
        }
      }
    }
  ]
}
#### Graphql 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"
      }
    }
  }
}

### Create a subscription with add-on modules
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" 
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}"
#### Graphql 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"
          }
        }
      }
    }
  ]
}
#### Graphql 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"
      }
    }
  }
}

### Creates a recurring application charge
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" 
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}"
#### Graphql 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"
        }
      }
    }
  ]
}
#### Graphql 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"
      }
    }
  }
}