---
title: "Update product sorting in the smart collection"
description: >
  Update the sorting method for a specified smart collection to adjust the display order of products within the collection.
doc_type: openapi
doc_category: openapi
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/admin-rest-api/product/collection/update-product-sorting-in-smart-collections'
  md: 'https://developer.shopline.com/docs/admin-rest-api/product/collection/update-product-sorting-in-smart-collections.md'
---
# Update product sorting in the smart collection

Update the sorting method for a specified smart collection to adjust the display order of products within the collection.

- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **Required Scopes:** `write_products`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
PUT /products/smart_collections/:collection_id/order.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` .

## Required Permissions

* `write_products`

## Request

### Path Parameters

* `collection_id`

  string (required)

  The unique identifier for the collection. <br/>
  Maximum length：64 

### Request Headers

* `Content-Type`

  string (required)

  The field must be set to the fixed value `application/json; charset=utf-8`.

* `Authorization`

  string (required)

   The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. 

### Request Body

* `product_ids`

  array<string>

  The product IDs to be sorted in a specified order. This field is only valid when `sort_order` is `manual`, and is used to overwrite and update the pinned products. Passing an empty list will unpin all currently pinned products in the collection.<br/>
  Maximum size: 5000

* `sort_order`

  string

  Specify the sorting method of products in the smart collection.
  
  
  - `alpha-asc`: Sort by product name from A to Z
  - `alpha-desc`: Sort by product name from Z to A
  - `updated-desc`: Sort by update time from newest to oldest
  - `updated-asc`: Sort by update time from oldest to newest
  - `manual`: Sort by custom order
  - `created-desc`: Sort by creation time from newest to oldest
  - `created-asc`: Sort by creation time from oldest to newest
  - `price-asc`: Sort by the lowest selling price of product variants in ascending order
  - `price-desc`: Sort by the lowest selling price of product variants in descending order
  - `best-selling-last3days`: Sort by sales volume in the last 3 days in descending order
  - `best-selling-last7days`: Sort by sales volume in the last 7 days in descending order
  - `best-selling-last15days`: Sort by sales volume in the last 15 days in descending order
  - `best-selling-last30days`: Sort by sales volume in the last 30 days in descending order
  - `best-selling-last60days`: Sort by sales volume in the last 60 days in descending order
  - `best-selling`: Sort by sales volume in the last 90 days in descending order
  - `additional-purchase-rate-last3days`: Sort by add-to-cart rate in the last 3 days in descending order
  - `additional-purchase-rate-last7days`: Sort by add-to-cart rate in the last 7 days in descending order
  - `additional-purchase-rate-last15days`: Sort by add-to-cart rate in the last 15 days in descending order
  - `additional-purchase-rate-last30days`: Sort by add-to-cart rate in the last 30 days in descending order
  - `additional-purchase-rate-last60days`: Sort by add-to-cart rate in the last 60 days in descending order
  - `additional-purchase-rate-last90days`: Sort by add-to-cart rate in the last 90 days in descending order
  - `conversion-rate-last3days`: Sort by conversion rate in the last 3 days in descending order
  - `conversion-rate-last7days`: Sort by conversion rate in the last 7 days in descending order
  - `conversion-rate-last15days`: Sort by conversion rate in the last 15 days in descending order
  - `conversion-rate-desc`: Sort by conversion rate in the last 30 days in descending order
  - `conversion-rate-last60days`: Sort by conversion rate in the last 60 days in descending order
  - `conversion-rate-last90days`: Sort by conversion rate in the last 90 days in descending order
  - `additional-purchases-num-last3days`: Sort by add-to-cart quantity in the last 3 days in descending order
  - `additional-purchases-num-last7days`: Sort by add-to-cart quantity in the last 7 days in descending order
  - `additional-purchases-num-last15days`: Sort by add-to-cart quantity in the last 15 days in descending order
  - `additional-purchases-num-last30days`: Sort by add-to-cart quantity in the last 30 days in descending order
  - `additional-purchases-num-last60days`: Sort by add-to-cart quantity in the last 60 days in descending order
  - `add-to-cart-desc`: Sort by add-to-cart quantity in the last 90 days in descending order
  - `views-pv-last3days`: Sort by page views in the last 3 days in descending order
  - `views-pv-last7days`: Sort by page views in the last 7 days in descending order
  - `views-pv-last15days`: Sort by page views in the last 15 days in descending order
  - `views-pv-last30days`: Sort by page views in the last 30 days in descending order
  - `views-pv-last60days`: Sort by page views in the last 60 days in descending order
  - `view-desc`: Sort by page views in the last 90 days in descending order

## Response

### Status Codes

* `200`

  For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise.

### Response Body

#### 200

_No response body_

#### 401

* `errors`

  string

  Error message. 


#### 429

* `errors`

  string

  Error message. 


## OpenAPI Definition

```json
{
  "tags": [
    "Update product sorting in the smart collection"
  ],
  "description": "Update the sorting method for a specified smart collection to adjust the display order of products within the collection.",
  "externalDocs": {
    "description": "Permission point used by the interface is `write_products` , For more information about the use of permission points, see",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=en",
    "errorTableDescription": ""
  },
  "operationId": "lpg4ibYj",
  "parameters": [
    {
      "name": "collection_id",
      "in": "path",
      "description": "The unique identifier for the collection. <br/>\nMaximum length：64 ",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "collection_id",
        "description": "The unique identifier for the collection. <br/>\nMaximum length：64 ",
        "type": "string",
        "example": "12257170618007271602093384"
      },
      "example": "12257170618007271602093384",
      "examples": {
        "Update product sorting in the smart collection": {
          "value": "12260895961380206730473144"
        }
      }
    },
    {
      "name": "Content-Type",
      "in": "header",
      "description": "The field must be set to the fixed value `application/json; charset=utf-8`.",
      "required": true,
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "name": "body",
          "description": "Body location parameters",
          "type": "object",
          "properties": {
            "product_ids": {
              "name": "product_ids",
              "description": "The product IDs to be sorted in a specified order. This field is only valid when `sort_order` is `manual`, and is used to overwrite and update the pinned products. Passing an empty list will unpin all currently pinned products in the collection.<br/>\nMaximum size: 5000",
              "type": "array",
              "items": {
                "type": "string",
                "example": "16064649853088531841170520"
              },
              "example": [
                "16064649853088531841170520"
              ]
            },
            "sort_order": {
              "name": "sort_order",
              "description": "Specify the sorting method of products in the smart collection.\n\n\n- `alpha-asc`: Sort by product name from A to Z\n- `alpha-desc`: Sort by product name from Z to A\n- `updated-desc`: Sort by update time from newest to oldest\n- `updated-asc`: Sort by update time from oldest to newest\n- `manual`: Sort by custom order\n- `created-desc`: Sort by creation time from newest to oldest\n- `created-asc`: Sort by creation time from oldest to newest\n- `price-asc`: Sort by the lowest selling price of product variants in ascending order\n- `price-desc`: Sort by the lowest selling price of product variants in descending order\n- `best-selling-last3days`: Sort by sales volume in the last 3 days in descending order\n- `best-selling-last7days`: Sort by sales volume in the last 7 days in descending order\n- `best-selling-last15days`: Sort by sales volume in the last 15 days in descending order\n- `best-selling-last30days`: Sort by sales volume in the last 30 days in descending order\n- `best-selling-last60days`: Sort by sales volume in the last 60 days in descending order\n- `best-selling`: Sort by sales volume in the last 90 days in descending order\n- `additional-purchase-rate-last3days`: Sort by add-to-cart rate in the last 3 days in descending order\n- `additional-purchase-rate-last7days`: Sort by add-to-cart rate in the last 7 days in descending order\n- `additional-purchase-rate-last15days`: Sort by add-to-cart rate in the last 15 days in descending order\n- `additional-purchase-rate-last30days`: Sort by add-to-cart rate in the last 30 days in descending order\n- `additional-purchase-rate-last60days`: Sort by add-to-cart rate in the last 60 days in descending order\n- `additional-purchase-rate-last90days`: Sort by add-to-cart rate in the last 90 days in descending order\n- `conversion-rate-last3days`: Sort by conversion rate in the last 3 days in descending order\n- `conversion-rate-last7days`: Sort by conversion rate in the last 7 days in descending order\n- `conversion-rate-last15days`: Sort by conversion rate in the last 15 days in descending order\n- `conversion-rate-desc`: Sort by conversion rate in the last 30 days in descending order\n- `conversion-rate-last60days`: Sort by conversion rate in the last 60 days in descending order\n- `conversion-rate-last90days`: Sort by conversion rate in the last 90 days in descending order\n- `additional-purchases-num-last3days`: Sort by add-to-cart quantity in the last 3 days in descending order\n- `additional-purchases-num-last7days`: Sort by add-to-cart quantity in the last 7 days in descending order\n- `additional-purchases-num-last15days`: Sort by add-to-cart quantity in the last 15 days in descending order\n- `additional-purchases-num-last30days`: Sort by add-to-cart quantity in the last 30 days in descending order\n- `additional-purchases-num-last60days`: Sort by add-to-cart quantity in the last 60 days in descending order\n- `add-to-cart-desc`: Sort by add-to-cart quantity in the last 90 days in descending order\n- `views-pv-last3days`: Sort by page views in the last 3 days in descending order\n- `views-pv-last7days`: Sort by page views in the last 7 days in descending order\n- `views-pv-last15days`: Sort by page views in the last 15 days in descending order\n- `views-pv-last30days`: Sort by page views in the last 30 days in descending order\n- `views-pv-last60days`: Sort by page views in the last 60 days in descending order\n- `view-desc`: Sort by page views in the last 90 days in descending order",
              "type": "string"
            }
          },
          "example": {
            "product_ids": [
              "16064649853088531841170520"
            ],
            "sort_order": null
          }
        },
        "examples": {
          "Update product sorting in the smart collection": {
            "description": "Update product sorting in the smart collection.",
            "value": {
              "product_ids": [
                "16064649853088531841170520"
              ],
              "sort_order": "created-asc"
            }
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).",
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "put",
  "path": "/products/smart_collections/:collection_id/order.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` ."
        }
      }
    }
  ],
  "info": {
    "title": "Update product sorting in the smart collection",
    "version": "v20270301"
  },
  "authIndexes": [
    "write_products"
  ]
}
```