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

# Send Search Events

> Ingest storefront / personalization events (standard Shopify pixel events and custom `glood:search:*` attribution events). Shop is taken from `x-shop`. Auth: `Authorization: Bearer <gl_sf_...>` + `x-shop`.

<ResponseExample>
  ```json 200 theme={null}
  {
    "ok": true
  }
  ```

  ```json 400 - missing identity theme={null}
  {
    "ok": false,
    "error": "At least one of visitor_id or client_id is required"
  }
  ```

  ```json 400 - validation theme={null}
  {
    "ok": false,
    "error": [
      {
        "message": "\"channel\" must be one of [HYDROGEN, HEADLESS, MOBILE]",
        "path": ["channel"],
        "type": "any.only",
        "context": { "label": "channel", "key": "channel" }
      }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /api/storefront/v1/headless/events
openapi: 3.0.1
info:
  title: Glood.AI API Reference
  description: Glood.AI API Reference
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://storefront.glood.ai
security:
  - bearerAuth: []
paths:
  /api/storefront/v1/headless/events:
    servers:
      - url: https://search.glood.ai
    post:
      description: >-
        Ingest storefront / personalization events (standard Shopify pixel
        events and custom `glood:search:*` attribution events). Shop is taken
        from `x-shop`. Auth: `Authorization: Bearer <gl_sf_...>` + `x-shop`.
      parameters:
        - name: x-shop
          in: header
          description: >-
            Shopify store URL. Resolves the shop for the request (headless does
            not accept `?shop=`).
          required: true
          schema:
            type: string
            example: shop.myshopify.com
      requestBody:
        description: Request body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HeadlessSearchEventsRequest'
      responses:
        '200':
          description: Event accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HeadlessSearchEventsResponse'
        '400':
          description: Validation or shop error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    HeadlessSearchEventsRequest:
      type: object
      description: >-
        Storefront / personalization event ingestion. Shop is taken from the
        x-shop header (not the body). Requires `channel` and at least one of
        `visitor_id` / `client_id`.
      required:
        - channel
        - event
      properties:
        channel:
          type: string
          description: Originating storefront channel.
          enum:
            - HYDROGEN
            - HEADLESS
            - MOBILE
        event:
          type: object
          description: The event envelope.
          required:
            - id
            - name
            - type
            - timestamp
            - context
          properties:
            id:
              type: string
              description: Unique event id.
            client_id:
              type: string
              description: Client id carried on the event.
            name:
              type: string
              description: Event name.
              enum:
                - glood:customer_preference
                - cart_viewed
                - checkout_completed
                - checkout_started
                - checkout_shipping_info_submitted
                - checkout_contact_info_submitted
                - checkout_address_info_submitted
                - payment_info_submitted
                - collection_viewed
                - page_viewed
                - product_added_to_cart
                - product_removed_from_cart
                - product_viewed
                - search_submitted
                - ui_extension_errored
                - glood:section:add_to_cart
                - glood:section:click
                - glood:section:render
                - glood:section:view
                - alert_displayed
                - glood:init
                - glood:instant_search_triggered
                - glood:instant_search_rendered
                - glood:search_result_rendered
                - glood:search_result_clicked
                - glood:search_filter_appeared
                - glood:search_filter_updated
                - glood:image_search_triggered
                - glood:image_search_results_rendered
                - glood:bundle:add_to_cart
                - glood:bundle:render
                - glood:bundle:view
                - glood:bundle:click
                - glood:checkout:add_to_cart
                - glood:checkout:render
                - glood:checkout:offer_accept
                - glood:checkout:offer_reject
                - glood:checkout:click
                - glood:post_purchase:render
                - glood:search:add_to_cart
            type:
              type: string
              description: Standard Shopify pixel event or a custom Glood event.
              enum:
                - standard
                - custom
            timestamp:
              type: string
              description: ISO 8601 event time. Must be within +/- 2 days of now.
              format: date-time
            data:
              type: object
              description: Standard event payload (when `type=standard`).
            custom_data:
              type: object
              description: Custom event payload (when `type=custom`).
              properties:
                track:
                  type: object
                  description: >-
                    Search attribution payload (custom events). Carried under
                    `event.custom_data.track`.
                  properties:
                    source:
                      type: string
                      description: >-
                        Where the interaction originated (e.g. `instant`,
                        `search_page`).
                    page_type:
                      type: string
                      description: Page type of the interaction.
                    pages:
                      type: array
                      description: Pages involved.
                      items:
                        type: object
                        description: A page ref.
                        required:
                          - page_id
                        properties:
                          page_id:
                            type: string
                            description: Page id.
                    products:
                      type: array
                      description: Products involved.
                      items:
                        type: object
                        description: A tracked product.
                        required:
                          - product_id
                        properties:
                          product_id:
                            type: string
                            description: Product id.
                          variant_id:
                            type: string
                            nullable: true
                            description: Variant id.
                          quantity:
                            type: number
                            description: Quantity.
                    request_id:
                      type: string
                      description: >-
                        `request_id` from the search response, tying the event
                        to a serve.
                    filters:
                      type: array
                      description: Applied filters at interaction time.
                      items:
                        type: object
                        description: A filter selection.
                        required:
                          - key
                          - value
                        properties:
                          key:
                            type: string
                            description: Filter key.
                          value:
                            type: array
                            nullable: true
                            items:
                              oneOf:
                                - type: string
                                - type: number
                                - type: boolean
                            description: Selected value(s).
                    search_term:
                      type: string
                      description: The search term.
                    search_type:
                      type: string
                      description: Search type.
                      enum:
                        - text
                        - image
                    checkout_token:
                      type: string
                      description: Checkout token, for conversion attribution.
                    campaign:
                      type: string
                      description: Campaign identifier.
            context:
              type: object
              description: Browser context.
              required:
                - navigator
              properties:
                document:
                  type: object
                  description: Document context (referrer, title, location, ...).
                navigator:
                  type: object
                  description: Navigator context.
                  required:
                    - user_agent
                  properties:
                    user_agent:
                      type: string
                      description: Client user-agent string (required).
                window:
                  type: object
                  description: Window context (screen, ...).
        session_id:
          type: string
          description: >-
            Browsing-session id (the unit of funnel + attribution analytics).
            Optional; the server generates a uuid when absent, but send a stable
            one per visit for accurate analytics.
        visitor_id:
          type: string
          description: >-
            Anonymous persistent visitor UID. At least one of `visitor_id` /
            `client_id` is required.
        client_id:
          type: string
          description: >-
            Client/device id (persists across sessions). At least one of
            `visitor_id` / `client_id` is required.
        customer_id:
          type: string
          description: Shopify customer id when logged in.
        page_type:
          type: string
          description: Page type the event fired from.
        page_url:
          type: string
          description: URL the event fired from.
        cart_identifier:
          type: string
          description: Cart token/key identifier.
        cart:
          type: object
          description: Cart state at event time.
        customer:
          type: object
          description: Customer info at event time.
        customer_privacy:
          type: object
          description: Customer consent flags.
          properties:
            analytics_processing_allowed:
              type: boolean
              description: Analytics consent.
            marketing_allowed:
              type: boolean
              description: Marketing consent.
            preferences_processing_allowed:
              type: boolean
              description: Preferences consent.
            sale_of_data_allowed:
              type: boolean
              description: Sale-of-data consent.
    HeadlessSearchEventsResponse:
      type: object
      description: Event ingestion acknowledgement.
      properties:
        ok:
          type: boolean
          enum:
            - true
          description: Indicates the event was accepted.
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````