---
updatedAt: 2026-05-28T22:55:55.000Z
agentTools:
  projectIndex: https://docs.constructor.com/llms.txt
---

# Create a sort option

**🔐 This endpoint requires [HTTP authentication](https://docs.constructor.com/reference/main-authentication) (either [Basic](https://docs.constructor.com/reference/main-authentication#basic-authentication) or [Bearer](https://docs.constructor.com/reference/main-authentication#bearer-authentication)).**
For authenticating with Bearer token, required scopes are: `sort_options(w)`.

Create a new sort option. Note that total number of sort options is limited, and every combination of `sort_by` and `sort_order` fields among the sort options must be unique.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "contact": {
      "email": "support@constructor.io"
    },
    "title": "Configuration",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://ac.cnstrc.com"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "Sort options"
    }
  ],
  "paths": {
    "/v1/sort_option": {
      "post": {
        "tags": [
          "Sort options"
        ],
        "operationId": "v1-sort-options-create-sort-option",
        "summary": "Create a sort option",
        "description": "**🔐 This endpoint requires [HTTP authentication](https://docs.constructor.com/reference/main-authentication) (either [Basic](https://docs.constructor.com/reference/main-authentication#basic-authentication) or [Bearer](https://docs.constructor.com/reference/main-authentication#bearer-authentication)).**\nFor authenticating with Bearer token, required scopes are: `sort_options(w)`.\n\nCreate a new sort option. Note that total number of sort options is limited, and every combination of `sort_by` and `sort_order` fields among the sort options must be unique.",
        "parameters": [
          {
            "name": "key",
            "in": "query",
            "schema": {
              "title": "Key",
              "description": "The key of the index to use.",
              "maxLength": 100,
              "minLength": 1,
              "examples": [
                "key_K2pX7vBnU0bgA5xp"
              ],
              "type": "string"
            },
            "required": true
          },
          {
            "name": "section",
            "in": "query",
            "schema": {
              "title": "Section",
              "description": "The section of the index to use. Defaults to `Products`.",
              "maxLength": 100,
              "minLength": 1,
              "examples": [
                "Products",
                "Search Suggestions"
              ],
              "type": "string"
            },
            "required": false
          },
          {
            "name": "c",
            "in": "query",
            "schema": {
              "title": "C",
              "description": "The ID of the client and version that the request is coming from, such as `cio-js-2.90`.",
              "maxLength": 100,
              "minLength": 1,
              "examples": [
                "cio-js-2.90",
                "cio-ios-1.0"
              ],
              "type": "string"
            },
            "required": false
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SortOptionPostBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SortOptionPostResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation Error"
          },
          "401": {
            "description": "Credentials are not passed or action is forbidden."
          },
          "403": {
            "description": "The supplied token does not have the required permissions."
          },
          "409": {
            "description": "Conflict"
          },
          "429": {
            "description": "Rate limit breached"
          }
        },
        "security": [
          {
            "http_basic_auth": []
          },
          {
            "http_bearer_auth": [
              "sort_options(w)"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "SortOrderType": {
        "title": "SortOrderType",
        "enum": [
          "ascending",
          "descending"
        ],
        "type": "string"
      },
      "SortOptionPostBody": {
        "title": "SortOptionPostBody",
        "type": "object",
        "properties": {
          "display_name": {
            "title": "Display Name",
            "description": "The name of the sort option as it is displayed to end users.",
            "examples": [
              "Price: Low to High",
              "Best Rating"
            ],
            "minLength": 1,
            "maxLength": 200,
            "type": "string"
          },
          "path_in_metadata": {
            "title": "Path In Metadata",
            "description": "The path in the item's metadata to the field that results will be sorted according to.",
            "examples": [
              "data.price",
              "data.rating"
            ],
            "maxLength": 200,
            "type": "string"
          },
          "position": {
            "title": "Position",
            "description": "The position of the sort option, used to provide sort options in a specific order.",
            "examples": [
              1,
              5
            ],
            "type": "integer"
          },
          "hidden": {
            "title": "Hidden",
            "description": "Indicates if a sort option is hidden. This can be marked at `sort_by` level. A hidden sort option will be ignored in response by default.",
            "default": false,
            "examples": [
              false,
              true
            ],
            "type": "boolean"
          },
          "sort_by": {
            "title": "Sort By",
            "description": "The name of the sort option.",
            "examples": [
              "price",
              "relevance",
              "rating"
            ],
            "minLength": 1,
            "maxLength": 200,
            "type": "string"
          },
          "sort_order": {
            "description": "The order the results will be sorted in",
            "examples": [
              "ascending",
              "descending"
            ],
            "allOf": [
              {
                "$ref": "#/components/schemas/SortOrderType"
              }
            ]
          }
        },
        "required": [
          "path_in_metadata",
          "sort_by",
          "sort_order"
        ],
        "additionalProperties": false
      },
      "SortOptionPostResponse": {
        "title": "SortOptionPostResponse",
        "type": "object",
        "properties": {
          "display_name": {
            "title": "Display Name",
            "description": "The name of the sort option as it is displayed to end users.",
            "examples": [
              "Price: Low to High",
              "Best Rating"
            ],
            "minLength": 1,
            "maxLength": 200,
            "type": "string"
          },
          "path_in_metadata": {
            "title": "Path In Metadata",
            "description": "The path in the item's metadata to the field that results will be sorted according to.",
            "examples": [
              "data.price",
              "data.rating"
            ],
            "maxLength": 200,
            "type": "string"
          },
          "position": {
            "title": "Position",
            "description": "The position of the sort option, used to provide sort options in a specific order.",
            "examples": [
              1,
              5
            ],
            "type": "integer"
          },
          "hidden": {
            "title": "Hidden",
            "description": "Indicates if a sort option is hidden. This can be marked at `sort_by` level. A hidden sort option will be ignored in response by default.",
            "default": false,
            "examples": [
              false,
              true
            ],
            "type": "boolean"
          },
          "sort_by": {
            "title": "Sort By",
            "description": "The name of the sort option.",
            "examples": [
              "price",
              "relevance",
              "rating"
            ],
            "minLength": 1,
            "maxLength": 200,
            "type": "string"
          },
          "sort_order": {
            "description": "The order the results will be sorted in",
            "examples": [
              "ascending",
              "descending"
            ],
            "allOf": [
              {
                "$ref": "#/components/schemas/SortOrderType"
              }
            ]
          }
        },
        "required": [
          "display_name",
          "path_in_metadata",
          "sort_by",
          "sort_order"
        ]
      }
    },
    "securitySchemes": {
      "http_basic_auth": {
        "type": "http",
        "scheme": "basic"
      },
      "http_bearer_auth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": false
  }
}
```