> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stella-commerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Post Intent Find

> Natural-language product search → ranked candidates + reasoning.

v1 reuses Phase 3-B's tsvector engine. The `query` field is
treated as a `plainto_tsquery` argument (so multi-word queries
are AND'd against the indexed text). Match attribution
(`match_reasons`) is derived via simple substring detection
against the product's `name` / `description` / `tags` /
`vendor` / `product_type`.

Defaults are tuned for an LLM context: top 5 candidates so the
follow-up prompt stays compact. Caller can override up to 20.



## OpenAPI

````yaml /api-reference/openapi.json post /api/agent/intent/find
openapi: 3.1.0
info:
  title: Agentic Commerce API
  description: |2-

        Agentic Commerce API - E-commerce Backend

        ## APIs

        ### Dashboard API (`/api/dashboard`)
        Authenticated endpoints for merchant management:
        - Products, Variants, Options
        - Inventory management
        - Orders and fulfillment
        - Customers
        - Collections

        ### Storefront API (`/api/storefront`)
        Public endpoints for client websites:
        - Product catalog
        - Collections
        - Cart management
        - Checkout

        ### Sync API (`/api/sync`)
        Integration endpoints for zunkiree-search:
        - Product sync
        - Availability checks
        - Order creation from AI widget
        
  version: 1.0.0
servers: []
security: []
paths:
  /api/agent/intent/find:
    post:
      tags:
        - Agent
        - Agent Intent
      summary: Post Intent Find
      description: |-
        Natural-language product search → ranked candidates + reasoning.

        v1 reuses Phase 3-B's tsvector engine. The `query` field is
        treated as a `plainto_tsquery` argument (so multi-word queries
        are AND'd against the indexed text). Match attribution
        (`match_reasons`) is derived via simple substring detection
        against the product's `name` / `description` / `tags` /
        `vendor` / `product_type`.

        Defaults are tuned for an LLM context: top 5 candidates so the
        follow-up prompt stays compact. Caller can override up to 20.
      operationId: post_intent_find_api_agent_intent_find_post
      parameters:
        - name: X-Site-ID
          in: header
          required: true
          schema:
            type: string
            title: X-Site-Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentIntentFindBody'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentIntentFindResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AgentIntentFindBody:
      properties:
        query:
          type: string
          maxLength: 512
          minLength: 1
          title: Query
        max_results:
          type: integer
          maximum: 20
          minimum: 1
          title: Max Results
          description: >-
            Maximum candidates to return. Default 5 keeps the LLM context window
            small; max 20 because more than that is rarely useful for an intent
            flow.
          default: 5
      type: object
      required:
        - query
      title: AgentIntentFindBody
      description: |-
        Agent → Stella: natural-language product search.

        `query` is a free-form natural-language request like "warm hat
        for hiking under NPR 2000". Phase 6-C1 reuses the keyword +
        trigram engine from Phase 3-B; semantic search lands later.
    AgentIntentFindResponse:
      properties:
        query:
          type: string
          title: Query
        candidates:
          items:
            $ref: '#/components/schemas/AgentIntentCandidate'
          type: array
          title: Candidates
        reasoning:
          type: string
          title: Reasoning
          description: >-
            Overall search-strategy summary (e.g. 'Matched against tsvector with
            cover-density rank; 5 candidates above noise floor'). Lets the agent
            surface trust signals to the customer without parsing per-candidate
            match_reasons.
      type: object
      required:
        - query
        - candidates
        - reasoning
      title: AgentIntentFindResponse
      description: Response shape for `POST /api/agent/intent/find`.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentIntentCandidate:
      properties:
        product:
          $ref: '#/components/schemas/AgentCatalogProduct'
        rank_score:
          type: number
          title: Rank Score
          description: >-
            Normalised relevance in [0, 1] from the underlying tsvector rank.
            Higher is better. v1 derives from `ts_rank_cd`.
        match_reasons:
          items:
            type: string
          type: array
          title: Match Reasons
          description: >-
            Per-candidate attribution — which query terms matched which product
            field. v1 uses simple substring detection; later phases may swap to
            LLM-generated explanations.
      type: object
      required:
        - product
        - rank_score
        - match_reasons
      title: AgentIntentCandidate
      description: One LLM-friendly candidate with attribution.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AgentCatalogProduct:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        slug:
          anyOf:
            - type: string
            - type: 'null'
          title: Slug
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        vendor:
          anyOf:
            - type: string
            - type: 'null'
          title: Vendor
        product_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Product Type
        tags:
          items:
            type: string
          type: array
          title: Tags
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
        price_min_cents:
          type: integer
          title: Price Min Cents
        price_max_cents:
          type: integer
          title: Price Max Cents
        currency:
          type: string
          title: Currency
        in_stock:
          type: boolean
          title: In Stock
        total_inventory:
          type: integer
          title: Total Inventory
        variant_count:
          type: integer
          title: Variant Count
        variants:
          items:
            $ref: '#/components/schemas/AgentCatalogVariant'
          type: array
          title: Variants
        summary_for_llm:
          type: string
          title: Summary For Llm
      type: object
      required:
        - id
        - name
        - slug
        - description
        - vendor
        - product_type
        - tags
        - image_url
        - price_min_cents
        - price_max_cents
        - currency
        - in_stock
        - total_inventory
        - variant_count
        - variants
        - summary_for_llm
      title: AgentCatalogProduct
      description: |-
        LLM-shape product.

        `summary_for_llm` is the single-paragraph natural-language summary
        an LLM can read to decide if this matches a user's intent. The
        structured fields below it are for follow-up calls (cart adds,
        detail renders) and reasoning attribution. Keep this shape FLAT —
        LLMs handle nesting poorly.
    AgentCatalogVariant:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        title:
          type: string
          title: Title
        sku:
          anyOf:
            - type: string
            - type: 'null'
          title: Sku
        price_cents:
          type: integer
          title: Price Cents
        options:
          additionalProperties: true
          type: object
          title: Options
        inventory_quantity:
          type: integer
          title: Inventory Quantity
        in_stock:
          type: boolean
          title: In Stock
      type: object
      required:
        - id
        - title
        - price_cents
        - options
        - inventory_quantity
        - in_stock
      title: AgentCatalogVariant
      description: |-
        LLM-shape product variant. Inventory snapshot included so the
        LLM doesn't hand the customer a candidate that's out of stock.

````