Shopify API - How to create a smart collection using Postman

Shopify API 2024 – How to create a smart collection using Postman

A smart collection is a grouping of products defined by merchant-specified rules. Shopify automatically changes the contents of a smart collection based on the rules. Like other collections, smart collections organize the product catalog into categories and make it easier to navigate the store.

Unlike manual collections, smart collections cannot remove a specific product unless the collection condition is changed or the product details are edited, so the product no longer matches the condition.

By default, a store can have up to 5000 smart collections.

A smart collection is so useful for each business; it helps their customers have better experience shopping. With that benefit, today Beehexa will show you how to create a smart collection using Postman with many conditions that you can choose to suit your business.ย 

Now, letโ€™s explore this subject step by step.

Step 1: Generate API Credentials From Shopify Admin

If this is the first time you make a call in the Postman, you must generate API credentials from the Shopify admin.ย 

Follow the process of How to build a custom app for Shopify in 2022? to know how to access Shopify API.ย 

    ย 

    • After creating an app, remember the Admin API access token and the API key to create a smart collection in Postman.ย 

    Shopify Connector and Profile arrow Wave
    Shopify Wave Integration
    Shopify Connector and Profile arrow BigCommerce
    Shopify Bigcommerce Integration
    Shopify Connector and Profile arrow Insightly
    Shopify Insightly Integration

    Step 2: Create A Smart Collection Using Postman

    Now, we are ready to create a smart collection using Postman.

      ย 

        • Log in to your Postman and create a new workspace

        • Then, create a new POST with this URL:

      https://{API_key}:{admin_API_access_token}@{shop}.myshopify.com/admin/api/{api-version}/{resource}

        ย 

          1. {API_key} โ€“ The API key that you generated.

          1. {admin_API_access_token} โ€“ The admin API access token that you generated.

          1. {shop} โ€“ The name of your development store.

          1. {api-version} โ€“ The supported API version that you want to use.

          1. {resource} โ€“ A resource endpoint from the REST Admin API.

        Or you can copy this example, remember to change {resource} to {smart_collections}:

        https://ed86d512a2c95387ffa25f67074a222b:[email protected]/admin/api/2021-10/smart_collections.json

        create a smart collection

        In the body section, enter the code. You can change the conditions of the smart collection to suit your purpose.

        In this example, I’ll create a smart collection with the title Test, with the rules as columns: variant price, relationship: less than, condition: 100. This Means Collection Test is a group of products with product prices under $100.

        Payload:

        {
            "smart_collection": {
                "title": "Test",
                "rules": [{
                    "column": "variant_price",
                    "relation": "less_than",
                    "condition": "100"
                }]
            }
        }

        body_create a smart collection

        Then clicks on send

        Parameters:

        Smart_collection.title: The name of the smart collection. Maximum length: 255 characters.

        column: The property of a product being used to populate the smart collection.

        Valid values for text relations:

          ย 

            • title: The product title.

            • type: The product type.

            • vendor: The name of the product vendor.

            • variant_title: The title of a product variant.

          Valid values for number relations:

            ย 

              • variant_compare_at_price: The compare price.

              • variant_weight: The weight of the product.

              • variant_inventory: The inventory stock. Note: not_equals does not work with this property.

              • variant_price: product price.

              • Valid values for an equals relation:

              • tag: A tag associated with the product.

            relation: The relationship between the column choice and the condition.

            Valid values for number relations:

              ย 

                • greater_than The column value is greater than the condition.

                • less_than The column value is less than the condition.

                • equals The column value is equal to the condition.

                • not_equals The column value is not equal to the condition.

              Valid values for text relations:

                ย 

                  • equals: Checks if the column value is equal to the condition value.

                  • not_equals: Checks if the column value is not equal to the condition value.

                  • starts_with: Checks if the column value starts with the condition value.

                  • ends_with: Checks if the column value ends with the condition value.

                  • contains: Checks if the column value contains the condition value.

                  • not_contains: Checks if the column value does not contain the condition value.

                condition: Select products for a smart collection using a condition. Values are either strings or numbers, depending on the relation value.

                Response: The API will return the data like this.ย 

                {
                    "smart_collection": {
                        "id": 263325450303,
                        "handle": "test",
                        "title": "Test",
                        "updated_at": "2022-03-24T18:47:56+09:00",
                        "body_html": null,
                        "published_at": "2022-03-24T18:47:56+09:00",
                        "sort_order": "best-selling",
                        "template_suffix": null,
                        "disjunctive": false,
                        "rules": [
                            {
                                "column": "variant_price",
                                "relation": "less_than",
                                "condition": "100"
                            }
                        ],
                        "published_scope": "web",
                        "admin_graphql_api_id": "gid://shopify/Collection/263325450303"
                    }
                }

                response_create a smart collection

                Step 3: Verify The Result

                Now, letโ€™s check the result in the Admin Dashboard.

                  ย 

                    • Go to the Shopify admin

                    • Then, click on the products

                    • Finally, select collections

                  after creating a smart collection in Shopify Admin

                  As you can see, the test collection has been created successfully.ย 

                  Then click on the test collection.

                  After that, choose view; you can see the test collection in the Shopify Store.

                  After creating a smart collection in Shopify store

                  The above are all steps to create a smart collection using Postman with Shopify API. If you have any questions, please leave a comment below or refer to our blog: What is an API?. Besides, you can see more Shopify API documentation in the developer docs.

                  If you still do not understand the tutorialโ€™s content, you can watch the video below for a more overview.

                  https://www.youtube.com/watch?v=-QpVOEwOd5E
                  Shopify API – How to create a smart collection using Postman

                  Hopefully, you can do it!