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

# Send User Event Data

> This route allows you to send user event data to the system.



## OpenAPI

````yaml put /api/analytics/events
openapi: 3.0.3
info:
  title: Trieve API
  description: >-
    Trieve OpenAPI Specification. This document describes all of the operations
    available through the Trieve API.
  contact:
    name: Trieve Team
    url: https://trieve.ai
    email: developers@trieve.ai
  license:
    name: BSL
    url: https://github.com/devflowinc/trieve/blob/main/LICENSE.txt
  version: 0.13.0
servers:
  - url: https://api.trieve.ai
    description: Production server
  - url: http://localhost:8090
    description: Local development server
security: []
tags:
  - name: Invitation
    description: Invitation endpoint. Exists to invite users to an organization.
  - name: Auth
    description: Authentication endpoint. Serves to register and authenticate users.
  - name: User
    description: User endpoint. Enables you to modify user roles and information.
  - name: Organization
    description: >-
      Organization endpoint. Enables you to modify organization roles and
      information.
  - name: Dataset
    description: >-
      Dataset endpoint. Datasets belong to organizations and hold configuration
      information for both client and server. Datasets contain chunks and chunk
      groups.
  - name: Chunk
    description: >-
      Chunk endpoint. Think of chunks as individual searchable units of
      information. The majority of your integration will likely be with the
      Chunk endpoint.
  - name: Chunk Group
    description: >-
      Chunk groups endpoint. Think of a chunk_group as a bookmark folder within
      the dataset.
  - name: Crawl
    description: Crawl endpoint. Used to create and manage crawls for datasets.
  - name: File
    description: >-
      File endpoint. When files are uploaded, they are stored in S3 and broken
      up into chunks with text extraction from Apache Tika. You can upload files
      of pretty much any type up to 1GB in size. See chunking algorithm details
      at `docs.trieve.ai` for more information on how chunking works. Improved
      default chunking is on our roadmap.
  - name: Events
    description: >-
      Notifications endpoint. Files are uploaded asynchronously and events are
      sent to the user when the upload is complete.
  - name: Topic
    description: >-
      Topic chat endpoint. Think of topics as the storage system for gen-ai chat
      memory. Gen AI messages belong to topics.
  - name: Message
    description: >-
      Message chat endpoint. Messages are units belonging to a topic in the
      context of a chat with a LLM. There are system, user, and assistant
      messages.
  - name: Stripe
    description: >-
      Stripe endpoint. Used for the managed SaaS version of this app. Eventually
      this will become a micro-service. Reach out to the team using contact info
      found at `docs.trieve.ai` for more information.
  - name: Health
    description: Health check endpoint. Used to check if the server is up and running.
  - name: Metrics
    description: Metrics endpoint. Used to get information for monitoring
  - name: Analytics
    description: Analytics endpoint. Used to get information for search and RAG analytics
  - name: Experiment
    description: Experiment endpoint. Used to create and manage experiments
paths:
  /api/analytics/events:
    put:
      tags:
        - Analytics
      summary: Send User Event Data
      description: This route allows you to send user event data to the system.
      operationId: send_event_data
      parameters:
        - name: TR-Dataset
          in: header
          description: >-
            The dataset id or tracking_id to use for the request. We assume you
            intend to use an id if the value is a valid uuid.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: JSON request payload to send event data
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventTypes'
        required: true
      responses:
        '204':
          description: The event data was successfully sent
        '400':
          description: Service error relating to sending event data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      security:
        - ApiKey:
            - admin
components:
  schemas:
    EventTypes:
      oneOf:
        - type: object
          title: View
          required:
            - event_name
            - items
            - event_type
          properties:
            event_name:
              type: string
              description: The name of the event
            event_type:
              type: string
              enum:
                - view
            items:
              type: array
              items:
                type: string
              description: The items that were viewed
            location:
              type: string
              description: The location of the event
              nullable: true
            metadata:
              description: Any other metadata associated with the event
              nullable: true
            request:
              allOf:
                - $ref: '#/components/schemas/RequestInfo'
              nullable: true
            user_id:
              type: string
              description: The user id of the user who viewed the items
              nullable: true
        - type: object
          title: AddToCart
          required:
            - event_name
            - items
            - event_type
          properties:
            event_name:
              type: string
              description: The name of the event
            event_type:
              type: string
              enum:
                - add_to_cart
            is_conversion:
              type: boolean
              description: Whether the event is a conversion event
              nullable: true
            items:
              type: array
              items:
                type: string
              description: The items that were added to the cart
            location:
              type: string
              description: The location of the event
              nullable: true
            metadata:
              description: Any other metadata associated with the event
              nullable: true
            request:
              allOf:
                - $ref: '#/components/schemas/RequestInfo'
              nullable: true
            user_id:
              type: string
              description: The user id of the user who added the items to the cart
              nullable: true
        - type: object
          title: Click
          required:
            - event_name
            - event_type
          properties:
            clicked_items:
              allOf:
                - $ref: '#/components/schemas/ChunkWithPosition'
              nullable: true
            event_name:
              type: string
              description: The name of the event
            event_type:
              type: string
              enum:
                - click
            is_conversion:
              type: boolean
              description: Whether the event is a conversion event
              nullable: true
            location:
              type: string
              description: The location of the event
              nullable: true
            metadata:
              description: Metadata to include with click event
              nullable: true
            request:
              allOf:
                - $ref: '#/components/schemas/RequestInfo'
              nullable: true
            user_id:
              type: string
              description: The user id of the user who clicked the items
              nullable: true
        - type: object
          title: Purchase
          required:
            - event_name
            - items
            - event_type
          properties:
            event_name:
              type: string
              description: The name of the event
            event_type:
              type: string
              enum:
                - purchase
            is_conversion:
              type: boolean
              description: Whether the event is a conversion event
              nullable: true
            items:
              type: array
              items:
                $ref: '#/components/schemas/PurchaseItem'
              description: The items that were purchased
            location:
              type: string
              description: The location of the event
              nullable: true
            metadata:
              description: Any other metadata associated with the event
              nullable: true
            request:
              allOf:
                - $ref: '#/components/schemas/RequestInfo'
              nullable: true
            user_id:
              type: string
              description: The user id of the user who purchased the items
              nullable: true
        - type: object
          title: FilterClicked
          required:
            - event_name
            - items
            - event_type
          properties:
            event_name:
              type: string
              description: The name of the event
            event_type:
              type: string
              enum:
                - filter_clicked
            is_conversion:
              type: boolean
              description: Whether the event is a conversion event
              nullable: true
            items:
              type: object
              description: >-
                The filter items that were clicked in a hashmap ie.
                {filter_name: filter_value} where filter_name is
                filter_type::field_name
              additionalProperties:
                type: string
            location:
              type: string
              description: The location of the event
              nullable: true
            request:
              allOf:
                - $ref: '#/components/schemas/RequestInfo'
              nullable: true
            user_id:
              type: string
              description: The user id of the user who clicked the items
              nullable: true
        - type: object
          title: Search
          required:
            - query
            - tokens
            - event_type
          properties:
            event_type:
              type: string
              enum:
                - search
            latency:
              type: number
              format: float
              description: Latency of the search
              nullable: true
            metadata:
              description: Metadata to provide with each request
              nullable: true
            query:
              type: string
              description: The search query
            query_rating:
              allOf:
                - $ref: '#/components/schemas/SearchQueryRating'
              nullable: true
            request_params:
              description: The request params of the search
              nullable: true
            results:
              type: array
              items: {}
              description: The results of the search
              nullable: true
            search_type:
              allOf:
                - $ref: '#/components/schemas/ClickhouseSearchTypes'
              nullable: true
            tokens:
              type: integer
              format: int64
              description: Number of tokens used in the search
              minimum: 0
            top_score:
              type: number
              format: float
              description: The top score of the search
              nullable: true
            user_id:
              type: string
              description: The user id of the user who made the search
              nullable: true
        - type: object
          title: RAG
          required:
            - user_message
            - tokens
            - event_type
          properties:
            detected_hallucinations:
              type: array
              items:
                type: string
              description: The detected hallucinations of the RAG event
              nullable: true
            event_type:
              type: string
              enum:
                - rag
            hallucination_score:
              type: number
              format: double
              description: The hallucination score of the RAG event
              nullable: true
            llm_response:
              type: string
              description: The response from the LLM
              nullable: true
            metadata:
              description: Metadata to provide with each request
              nullable: true
            query_rating:
              allOf:
                - $ref: '#/components/schemas/SearchQueryRating'
              nullable: true
            rag_type:
              allOf:
                - $ref: '#/components/schemas/ClickhouseRagTypes'
              nullable: true
            results:
              type: array
              items: {}
              description: The results of the RAG event
              nullable: true
            search_id:
              type: string
              format: uuid
              description: The search id to associate the RAG event with a search
              nullable: true
            tokens:
              type: integer
              format: int64
              description: The number of tokens used for this chat
              minimum: 0
            topic_id:
              type: string
              format: uuid
              description: The topic id to associate the RAG event with a topic
              nullable: true
            user_id:
              type: string
              description: The user id of the user who made the RAG event
              nullable: true
            user_message:
              type: string
              description: The user message
        - type: object
          title: Recommendation
          required:
            - event_type
          properties:
            event_type:
              type: string
              enum:
                - recommendation
            metadata:
              description: Metadata to provide with each request
              nullable: true
            negative_ids:
              type: array
              items:
                type: string
                format: uuid
              description: Negative ids used for the recommendation
              nullable: true
            negative_tracking_ids:
              type: array
              items:
                type: string
              description: Negative tracking ids used for the recommendation
              nullable: true
            positive_ids:
              type: array
              items:
                type: string
                format: uuid
              description: Positive ids used for the recommendation
              nullable: true
            positive_tracking_ids:
              type: array
              items:
                type: string
              description: Positive tracking ids used for the recommendation
              nullable: true
            recommendation_type:
              allOf:
                - $ref: '#/components/schemas/ClickhouseRecommendationTypes'
              nullable: true
            request_params:
              description: The request params of the recommendation
              nullable: true
            results:
              type: array
              items: {}
              description: The results of the Recommendation event
              nullable: true
            top_score:
              type: number
              format: float
              description: Top score of the recommendation
              nullable: true
            user_id:
              type: string
              description: The user id of the user who made the recommendation
              nullable: true
      discriminator:
        propertyName: event_type
    ErrorResponseBody:
      type: object
      required:
        - message
      properties:
        message:
          type: string
      example:
        message: Bad Request
    RequestInfo:
      type: object
      required:
        - request_type
        - request_id
      properties:
        request_id:
          type: string
          format: uuid
        request_type:
          $ref: '#/components/schemas/CTRType'
    ChunkWithPosition:
      type: object
      required:
        - chunk_id
        - position
      properties:
        chunk_id:
          type: string
          format: uuid
        position:
          type: integer
          format: int32
    PurchaseItem:
      type: object
      required:
        - tracking_id
        - revenue
      properties:
        revenue:
          type: number
          format: double
        tracking_id:
          type: string
    SearchQueryRating:
      type: object
      required:
        - rating
      properties:
        metadata:
          nullable: true
        note:
          type: string
          nullable: true
        rating:
          type: integer
          format: int32
    ClickhouseSearchTypes:
      type: string
      enum:
        - search
        - search_over_groups
        - autocomplete
        - rag
    ClickhouseRagTypes:
      type: string
      enum:
        - chosen_chunks
        - all_chunks
    ClickhouseRecommendationTypes:
      type: string
      enum:
        - Chunk
        - Group
    CTRType:
      type: string
      enum:
        - search
        - rag
        - recommendation
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````