---
url: https://docs.app-in.io/operations/searchCollection.md
---

# Search content

`POST https://api.app-in.io/v1/search/{collection}`

AI-powered semantic search with natural language query parsing, automatic filters, sorting, suggestions, and clarifying questions.

**How it works:**

1. AI parses your query — extracts clean search terms, filters, and sort order
2. Finds the most relevant results using semantic matching
3. Falls back to broader language search if needed
4. Drops irrelevant results below quality threshold
5. Re-sorts by price or rating when detected in query
6. Suggests alternatives if no results found
7. Asks clarifying questions for ambiguous queries

## OpenAPI operation

```json
{
  "operationId": "searchCollection",
  "summary": "Search content",
  "description": "AI-powered semantic search with natural language query parsing, automatic filters, sorting, suggestions, and clarifying questions.\n\n**How it works:**\n1. AI parses your query — extracts clean search terms, filters, and sort order\n2. Finds the most relevant results using semantic matching\n3. Falls back to broader language search if needed\n4. Drops irrelevant results below quality threshold\n5. Re-sorts by price or rating when detected in query\n6. Suggests alternatives if no results found\n7. Asks clarifying questions for ambiguous queries",
  "tags": [
    "Search"
  ],
  "parameters": [
    {
      "name": "collection",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string",
        "enum": [
          "products",
          "pages",
          "docs"
        ]
      },
      "description": "Content collection to search"
    },
    {
      "name": "X-Platform",
      "in": "header",
      "required": false,
      "schema": {
        "type": "string",
        "enum": [
          "product",
          "page",
          "doc",
          "woocommerce",
          "shopify"
        ]
      },
      "description": "Platform type. Defaults automatically based on collection. Set to `woocommerce` when searching WooCommerce products. Set to `shopify` when searching Shopify products."
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/SearchRequest"
        },
        "examples": {
          "simple": {
            "summary": "Simple product search",
            "value": {
              "query": "red shoes",
              "limit": 10
            }
          },
          "filtered": {
            "summary": "Search with category filter",
            "value": {
              "query": "running shoes under $100",
              "limit": 10,
              "category_id": 42,
              "lang": "en"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Search results",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/SearchResponse"
          }
        }
      },
      "headers": {
        "X-Plan": {
          "schema": {
            "type": "string"
          },
          "description": "Plan the account is on."
        },
        "X-Rate-Limit": {
          "schema": {
            "type": "integer"
          },
          "description": "Requests allowed per minute for this site. Set on every 2xx; absent on 4xx, which are rejected before the usage middleware runs."
        },
        "X-Requests-Used": {
          "schema": {
            "type": "integer"
          },
          "description": "Requests used this month across every site on the account — requests are a shared allowance, not a per-site one."
        },
        "X-Requests-Limit": {
          "schema": {
            "type": "integer"
          },
          "description": "The account's monthly request allowance."
        },
        "X-Requests-Remaining": {
          "schema": {
            "type": "integer"
          }
        },
        "X-Records-Used": {
          "schema": {
            "type": "integer"
          },
          "description": "Total indexed records for this site. Set on every 2xx; absent on 4xx."
        },
        "X-Records-Limit": {
          "schema": {
            "type": "string"
          },
          "description": "Always 'unlimited' — there is no record cap. Set on every 2xx; absent on 4xx."
        },
        "X-Tokens-Used": {
          "schema": {
            "type": "integer"
          },
          "description": "Tokens used this month across every site on the account — tokens are a shared allowance, not a per-site one."
        },
        "X-Tokens-Limit": {
          "schema": {
            "type": "string"
          },
          "description": "The account's monthly token allowance: an integer, or 'unlimited' for BYOK"
        },
        "X-Tokens-Remaining": {
          "schema": {
            "type": "string"
          },
          "description": "Tokens remaining this month. Only set when a token limit applies (not for BYOK)."
        },
        "X-Quota-Reset": {
          "schema": {
            "type": "string",
            "format": "date-time"
          },
          "description": "When the monthly counters reset. NOT the 1st of the month — the window is one month long, anchored on the account, so every account has its own date. Read it rather than assuming a calendar month."
        },
        "X-Request-Id": {
          "schema": {
            "type": "string"
          },
          "description": "Identifies this request in our logs. Quote it in a support request."
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "description": "Collection not available for your site type, or the site is paused. A site is paused when it is beyond the number of sites your plan allows — for example after a downgrade, where the newest sites over the limit are parked and the oldest keep running. Nothing is deleted: raising the plan or removing another site unpauses it with its index intact. A trial ending does not pause anything; the account simply moves to Free. Also returned when the site has been deactivated, the account blocked, or — for a public key — the request Origin is not on the site's allow-list. Note that the usage headers listed on the 200 response are added by middleware that runs after authentication, so none of them are present on a 403.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "collection": {
                "type": "string"
              }
            }
          },
          "examples": {
            "collectionNotAllowed": {
              "summary": "Collection not available for this site type",
              "value": {
                "error": "Collection not available for your site type.",
                "collection": "products"
              }
            },
            "sitePaused": {
              "summary": "Free trial ended — the site is paused",
              "value": {
                "error": "Site is paused — the free trial has ended. Start a paid plan to resume indexing and search."
              }
            }
          }
        }
      }
    },
    "422": {
      "$ref": "#/components/responses/ValidationError"
    },
    "429": {
      "$ref": "#/components/responses/RateLimited"
    },
    "502": {
      "$ref": "#/components/responses/ServiceUnavailable"
    }
  }
}
```

## Referenced components

```json
{
  "#/components/schemas/SearchRequest": {
    "type": "object",
    "required": [
      "query"
    ],
    "properties": {
      "query": {
        "type": "string",
        "maxLength": 500,
        "description": "Search query in natural language"
      },
      "limit": {
        "type": "integer",
        "minimum": 1,
        "maximum": 100,
        "default": 10
      },
      "lang": {
        "type": "string",
        "maxLength": 5,
        "description": "The search language, as an ISO 639-1 code. It filters the results to documents in this language. When fewer than 3 documents match, the search runs again without the language filter. When the catalog has documents in this language, the AI query parsing also translates the query into it; otherwise it uses the catalog's most common language. Send the language of the page and its content, not only the interface language.",
        "example": "en"
      },
      "category_id": {
        "type": "integer",
        "minimum": 1,
        "description": "Filter by category ID"
      },
      "collection_id": {
        "type": "string",
        "pattern": "^\\d{1,20}$",
        "example": "450123456789",
        "description": "Shopify only (`X-Platform: shopify`): the numeric ID of a Shopify collection. Send it as a string, because a Shopify ID can be larger than the largest safe JavaScript integer. The search returns products from this collection first. When the collection gives fewer than 3 results, the search adds products from the whole store, up to `limit`."
      },
      "country": {
        "type": "string",
        "pattern": "^[A-Za-z]{2}$",
        "example": "CH",
        "description": "Shopify only (`X-Platform: shopify`): the shopper country, as an ISO 3166-1 alpha-2 code. Upper case and lower case are both accepted. The country is not a filter. When you send it, the response contains `market`. When `market.localized` is true, the results show the price, the currency and the stock of the store's market for this country. The search also removes each product that this market does not sell."
      }
    }
  },
  "#/components/schemas/SearchResponse": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "The original query, echoed back. Always present."
      },
      "collection": {
        "type": "string",
        "example": "products",
        "description": "The collection that was searched. Always present."
      },
      "results": {
        "type": "array",
        "items": {
          "oneOf": [
            {
              "$ref": "#/components/schemas/SearchResult"
            },
            {
              "$ref": "#/components/schemas/ProductResult"
            }
          ]
        }
      },
      "parsed_query": {
        "type": "string",
        "description": "Cleaned query after LLM parsing"
      },
      "parsed_filters": {
        "type": "object",
        "description": "Filters extracted from natural language"
      },
      "sort_by": {
        "type": "string",
        "nullable": true,
        "description": "Extracted sort (price_asc, price_desc, rating_desc)"
      },
      "low_confidence": {
        "type": "boolean",
        "description": "True when no result cleared the relevance threshold and `results` contains best-effort closest matches instead (relaxed score floor, filters still applied). Treat an absent field as false."
      },
      "corrected_query": {
        "type": "string",
        "nullable": true,
        "description": "Typo-corrected query that produced the results when the original found nothing and the corrected retry succeeded (e.g. \"hyration pak\" -> \"hydration pack\"). Null or absent when no correction fired."
      },
      "market": {
        "type": "object",
        "description": "Shopify only (`X-Platform: shopify`): the shopper market. Present only when the request sent `country`.",
        "required": [
          "country",
          "localized"
        ],
        "properties": {
          "country": {
            "type": "string",
            "example": "CH",
            "description": "The `country` from the request, in upper case."
          },
          "localized": {
            "type": "boolean",
            "description": "True when the API read the market prices. Each result then has the market values in `price`, `currency` and `in_stock`. A product that the market does not sell is not in `results`. The order of the other results does not change. False when the API could not read the market prices. The results then show the store's base prices, and no product is removed."
          }
        }
      },
      "suggestion": {
        "type": "object",
        "nullable": true,
        "description": "Did-you-mean suggestion, returned when a query yields no results but relaxed alternatives exist.",
        "properties": {
          "message": {
            "type": "string",
            "nullable": true,
            "description": "Written by the AI in the language of the query. Null when that call failed — the API does not substitute an English sentence, because it cannot know the visitor's language. Render your own message from `cheapest` in that case."
          },
          "cheapest": {
            "type": "object",
            "nullable": true,
            "description": "The lowest-priced alternative, sent only alongside a null `message` so you can phrase the suggestion yourself.",
            "properties": {
              "title": {
                "type": "string",
                "nullable": true
              },
              "price": {
                "nullable": true,
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string"
                  }
                ],
                "description": "Echoed from the indexed payload, so its type is whatever you indexed — stores that push prices as strings get a string back."
              },
              "currency": {
                "type": "string",
                "nullable": true,
                "description": "ISO 4217 code from the indexed payload, when present. Absent if the store does not index one."
              }
            }
          },
          "alternatives": {
            "type": "array",
            "description": "Suggested alternative results as raw hits. Each item carries the base result fields plus a nested `payload` object with any extra indexed fields — note this differs from the flattened `results[]` items.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "snippet": {
                  "type": "string"
                },
                "score": {
                  "type": "number"
                },
                "type": {
                  "type": "string"
                },
                "payload": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "clarifications": {
        "type": "object",
        "nullable": true,
        "description": "Clarifying question with facets, returned when the query is ambiguous. `question` and every facet `label` come back in the language of the query; `field` and `options` stay as indexed.",
        "properties": {
          "question": {
            "type": "string",
            "nullable": true,
            "description": "Null when the AI returned facets but no question. Supply your own prompt rather than expecting an English default."
          },
          "facets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "options": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "#/components/schemas/SearchResult": {
    "type": "object",
    "description": "Base search result for pages and docs.",
    "properties": {
      "id": {
        "type": "string"
      },
      "url": {
        "type": "string"
      },
      "title": {
        "type": "string"
      },
      "snippet": {
        "type": "string",
        "description": "Short text excerpt. Omitted when not available."
      },
      "type": {
        "type": "string",
        "description": "Content type. Omitted when not available."
      }
    }
  },
  "#/components/schemas/ProductResult": {
    "description": "Product search result. Extends the base result with product fields; each product field is omitted when not available.",
    "allOf": [
      {
        "$ref": "#/components/schemas/SearchResult"
      },
      {
        "type": "object",
        "properties": {
          "image_url": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "category": {
            "type": "string"
          },
          "in_stock": {
            "type": "boolean"
          },
          "sku": {
            "type": "string"
          },
          "on_sale": {
            "type": "boolean"
          },
          "product_type": {
            "type": "string"
          },
          "rating": {
            "type": "number"
          },
          "handle": {
            "type": "string",
            "example": "red-boot",
            "description": "Shopify only: the primary product handle (the URL slug in the store's main language). Present only for requests with `X-Platform: shopify`, and only when the index holds a handle for the product. A product indexed before the handle was stored gets it on the next full sync."
          }
        }
      }
    ]
  },
  "#/components/responses/Unauthorized": {
    "description": "Missing or invalid API key",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ErrorResponse"
        },
        "example": {
          "error": "Invalid API key."
        }
      }
    }
  },
  "#/components/schemas/ErrorResponse": {
    "type": "object",
    "description": "Error body for authentication (401), authorization (403), and service (502) errors.",
    "properties": {
      "error": {
        "type": "string",
        "description": "Human-readable error message"
      }
    }
  },
  "#/components/responses/ValidationError": {
    "description": "Validation error",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ValidationErrorResponse"
        },
        "example": {
          "message": "The query field is required.",
          "errors": {
            "query": [
              "The query field is required."
            ]
          }
        }
      }
    }
  },
  "#/components/schemas/ValidationErrorResponse": {
    "type": "object",
    "description": "Validation error body (422).",
    "properties": {
      "message": {
        "type": "string"
      },
      "errors": {
        "type": "object",
        "description": "Map of field name to an array of error messages"
      }
    }
  },
  "#/components/responses/RateLimited": {
    "description": "Rate limit exceeded",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "message": {
              "type": "string"
            }
          }
        },
        "example": {
          "message": "Too many requests. Please try again later."
        }
      }
    }
  },
  "#/components/responses/ServiceUnavailable": {
    "description": "Search service temporarily unavailable",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ErrorResponse"
        },
        "example": {
          "error": "Search service unavailable."
        }
      }
    }
  }
}
```

Full specification: https://docs.app-in.io/openapi.json
