Skip to main content
POST
Text Search: Prepare Search
This endpoint asynchronously prepares expensive personalization for a given query, returning a ULID search_id that can be used with the Search API to execute the search.
  • Use with: Search API via the search_id body parameter

Authorization

string
required
Token-based authentication header in the form of <YOUR_LAYERS_TOKEN>. Same requirements as the Search API.

Headers

string
default:"application/json"
required
string
default:"application/json"
required

Path parameters

string
required
The url-encoded search query to prepare.

Body

string[]
Optional hint for which product attributes you intend to include in the eventual Search response. Available attributes include: id, title, handle, body_html, vendor, product_type, tags, images, available, created_at, updated_at, published_at, price_range, options, original_options, metafields, named_tags, calculated, category, featured_media, is_gift_card, has_variants_that_require_components, combined_listing_parent_product_id, combined_listing_role, and first_or_matched_variant. See the Product Schemafor detailed descriptions.
object
Refer to our dedicated Filter Expressions guide to learn more about filter expressions.
Pagination Object
string[]
Facets to be included. Accepts both exact facet codes (e.g., "vendor", "options.Size") and wildcard patterns (e.g., "options.*", "metafields.product.*").Wildcard patterns expand to all matching attribute codes. For example, "options.*" expands to all option facets like "options.Size" and "options.Color". Wildcards must match at least one attribute code to be valid.Examples:
boolean
If the count of each facet value should be calculated
boolean
If you want a min/max range for numeric facets such as price.
object
User identity information for tracking and personalization. Automatically managed by the Storefront Pixel; required for headless integrations.
object
Contextual information about the customer’s session, behavior, and environment. Automatically collected by the Storefront Pixel; must be manually provided for headless integrations. See Contextual Information for implementation guidance.

Behavior

  • Returns HTTP 202 (Accepted) immediately with a search_id
  • Generates a ULID search_id that identifies the prepared search
  • Starts additional search preparation asynchronously
  • Pre-computes query understanding and personalization inputs
  • Prepared data is cached for up to 15 minutes; after TTL, Search falls back to normal processing

Response

202 Accepted

string
ULID identifier for the prepared search. Valid for 15 minutes.

Response headers

Error conditions

  • 401 Unauthorized: Missing/invalid X-Storefront-Access-Token
  • 422 Unprocessable Entity: Invalid body or parameters

Next steps

Use the returned search_id with the Search API in the search_id body parameter to execute an optimized search.