---
title: Build a Pre-order and Try Before You Buy (TBYB) solution
description: >-
  Learn how to manage Pre-order and Try Before You Buy (TBYB) options using the
  GraphQL Admin API.
source_url:
  html: >-
    https://shopify.dev/docs/apps/build/purchase-options/deferred/build-deferment-solution
  md: >-
    https://shopify.dev/docs/apps/build/purchase-options/deferred/build-deferment-solution.md
---

# Build a Pre-order and Try Before You Buy (TBYB) solution

You can create pre-order and TBYB options using the GraphQL Admin API's [`sellingPlanGroupCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/sellingplangroupcreate) mutation. This guide describes the requirements for creating pre-order or TBYB options and shows you how to manage them using the GraphQL Admin API.

***

## Requirements

* Your app can make [authenticated requests](https://shopify.dev/docs/api/admin-graphql#authentication) to the GraphQL Admin API.

* Your app has the following [access scopes](https://shopify.dev/docs/api/usage/access-scopes):

  * `write_products`

  * `read_all_orders`

  * `read_customer_payment_methods`

  * `read_purchase_options`

  * `write_purchase_options`

  * `read_payment_mandate`

  * `write_payment_mandate`

    Learn how to [configure your access scopes using Shopify CLI](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration).

* You've familiarized yourself with [selling plans](https://shopify.dev/docs/apps/build/purchase-options) and [pre-orders and TBYB](https://shopify.dev/docs/apps/build/purchase-options/deferred).

* You've created [products](https://shopify.dev/docs/api/admin-graphql/latest/products-and-collections/productcreate) and [product variants](https://shopify.dev/docs/api/admin-graphql/latest/products-and-collections/productvariantcreate) in your dev store.

* The merchant that you're developing for meets the [qualifying criteria](https://help.shopify.com/en/manual/products/subscriptions/setup#eligibility-requirements).

  **Note:**

  * Most subscriptions, pre-order and try before you buy apps need to request API access through the [Partner Dashboard](https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/authorization-code-grant#ask-for-permission). We give API access to apps that are designed according to our \[principles for subscriptions, pre-order and TBYB apps] (/docs/apps/selling-strategies/purchase-options#shopifys-principles).
  * Public apps that use subscriptions, pre-order or TBYB need to meet [specific requirements](https://shopify.dev/docs/apps/launch/app-requirements-checklist#purchase-option-apps) to be published on the Shopify App Store.
  * Custom apps [created in the Shopify admin](https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/generate-app-access-tokens-admin) can't use subscriptions, pre-order or TBYB because these apps can't use extensions or request access to protected scopes. If you're building a solution for a single store, then build your custom app in the Partner Dashboard.

***

## Step 1: Create pre-order and TBYB options

**Caution:**

Subscriptions, pre-orders, TBYB, and associated records, including `SellingPlanGroup`, `SellingPlan`, policies, and associations to products and variants, are deleted 48 hours after a user uninstalls a subscriptions, pre-orders, or TBYB app. Products and product variants aren't deleted. We recommend backing up Subscriptions, pre-orders, and TBYB records in case you need to restore them later.

Create pre-order and TBYB options using the [`sellingPlanGroupCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/sellingplangroupcreate) mutation. The [`SellingPlanGroup`](https://shopify.dev/docs/api/admin-graphql/latest/objects/sellingplangroup) object includes one or more [`SellingPlan`](https://shopify.dev/docs/api/admin-graphql/latest/objects/sellingplan) objects. The `SellingPlan` object specifies how a product can be sold.

Learn more about [GraphQL Admin API objects for selling plans](https://shopify.dev/docs/apps/build/purchase-options#graphql-admin-api-objects-for-purchase-options). For more information on input fields and values, refer to the following resources:

* [`SellingPlanGroupInput`](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/sellingplangroupinput)
* [`SellingPlanInput`](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/sellingplaninput)
* [How pre-orders and TBYB work](https://shopify.dev/docs/apps/build/purchase-options/deferred#how-it-works)

**Note:**

`SellingPlan` objects are grouped together in Liquid when they are created by the same app, and when they have the same `selling_plan_group.name` and `selling_plan_group.options` values. For more information, refer to the [`selling_plan_group` object](https://shopify.dev/docs/api/liquid/objects/selling_plan_group).

#### Pre-order

Create a pre-order with a selling plan (`SellingPlan`) that contains the following policies:

* **Billing** (`billingPolicy.fixed`): The 20% of the total amount will be charged as a deposit at checkout. The remaining amount will be charged on 2022-07-24.

* **Delivery** (`deliveryPolicy.fixed`): The fulfillment timeline is unknown.

* **Pricing** (`pricingPolicies.fixed`): A 15% product reduction is applied to the variant.

* **Inventory** (`inventoryPolicy.reserve`): The inventory will be updated when the order is fulfilled.

  The `category` field should be set to `PRE_ORDER`.

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation {
  sellingPlanGroupCreate(
    input: {
      name: "Pre-order"
      merchantCode: "pre-order"
      options: [
        "Pre-order"
      ]
      sellingPlansToCreate: [
        {
          name: "July 2022 release"
          category: PRE_ORDER
          options: [
            "20% deposit. Balance due on July 24th 2022"
          ]
          billingPolicy: {
            fixed: {
              checkoutCharge: {type: PERCENTAGE, value: {percentage: 20.0}}
              remainingBalanceChargeTrigger: EXACT_TIME
              remainingBalanceChargeExactTime: "2022-07-24"
            }
          }
          pricingPolicies: [
            {
              fixed: {
                adjustmentType: PERCENTAGE
                adjustmentValue: { percentage: 15.0 }
              }
            }
          ]
          deliveryPolicy: {fixed: {fulfillmentTrigger: UNKNOWN}}
          inventoryPolicy: {reserve: ON_FULFILLMENT}
        }
      ]
    }
    resources: {productVariantIds: [], productIds: []}
  ) {
    sellingPlanGroup {
      id
      sellingPlans(first: 1) {
        edges {
          node {
            id
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "sellingPlanGroupCreate": {
      "sellingPlanGroup": {
        "id": "gid://shopify/SellingPlanGroup/71434296",
        "sellingPlans": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/SellingPlan/422674488",
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 62,
      "actualQueryCost": 17
    }
  }
}
```

#### Try before you buy

Create a try before you buy with a selling plan (`SellingPlan`) that contains the following policies:

* **Billing** (`billingPolicy.fixed`): There's no deposit. The full amount will be charged 14 days after checkout. The `remainingBalanceChargeTimeAfterCheckout` value must be in ISO 8601 duration format (`P14D`).

* **Delivery** (`deliveryPolicy.fixed`): The product will be fulfilled as soon as possible.

* **Inventory** (`inventoryPolicy.reserve`): The inventory will be updated when the order is created.

  The `category` field should be set to `TRY_BEFORE_YOU_BUY`.

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation {
  sellingPlanGroupCreate(
    input: {
      name: "Try before you buy"
      merchantCode: "try-before-you-buy"
      options: [
        "Try before you buy"
      ]
      position: 1
      sellingPlansToCreate: [
        {
          name: "14-day free trial"
          category: TRY_BEFORE_YOU_BUY
          options: [
            "Try free for 14 days"
          ]
          billingPolicy: {
            fixed: {
              checkoutCharge: {type: PRICE, value: {fixedValue: 0}}
              remainingBalanceChargeTrigger: TIME_AFTER_CHECKOUT
              remainingBalanceChargeTimeAfterCheckout: "P14D"
            }
          }
          deliveryPolicy: {fixed: {fulfillmentTrigger: ASAP}}
          inventoryPolicy: {reserve: ON_SALE}
        }
      ]
    }
    resources: { productIds: [], productVariantIds: [] }
  ) {
    sellingPlanGroup {
      id
      sellingPlans(first: 1) {
        edges {
          node {
            id
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "sellingPlanGroupCreate": {
      "sellingPlanGroup": {
        "id": "gid://shopify/SellingPlanGroup/71434296",
        "sellingPlans": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/SellingPlan/422674488",
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 62,
      "actualQueryCost": 17
    }
  }
}
```

***

## Step 2 (Optional): Manage pre-order and TBYB options

### Associate a pre-order or TBYB option to a product or product variant

You can use the [`sellingPlanGroupAddProducts`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/sellingplangroupaddproducts) mutation or the [`sellingPlanGroupAddProductVariants`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/sellingPlanGroupAddProductVariants) mutation to make a separate request to associate a pre-order or TBYB option with a product or product variant, without having to delete and recreate the pre-order or TBYB option.

### Associate multiple pre-order or TBYB options to a product or product variant

You can use the [`productJoinSellingPlanGroups`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productjoinsellingplangroups) mutation or the [`productVariantJoinSellingPlanGroups`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productvariantjoinsellingplangroups) mutation to associate multiple pre-orders or TBYB to a product or product variant.

### Edit pre-order and TBYB options

You can use the [`sellingPlanGroupUpdate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/sellingplangroupupdate) mutation to edit the attributes associated with a pre-order or TBYB option. For example, you can change the pre-order or TBYB options `name`.

***

## Next steps

* Learn about [shipping and delivery for pre-orders and TBYB](https://shopify.dev/docs/apps/build/purchase-options/deferred/delivery-and-deferment).

***
