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

# Send Hit Event

> Send a hit event to register a user view or interaction.



## OpenAPI

````yaml post /event/hit
openapi: 3.0.3
info:
  title: Medama Analytics API
  version: 0.5.0
  description: |
    This is the Medama Analytics OpenAPI 3.0 specification.
  contact:
    email: hello@ayuhito.com
    name: Medama Analytics
    url: https://medama.io/contact
  license:
    url: https://github.com/medama-io/medama/blob/main/core/LICENSE
    name: Apache License 2.0
servers:
  - url: http://localhost:8080
    description: Local Server
security: []
tags:
  - name: Authentication
    description: Authentication
  - name: Event
    description: Page Events
  - name: User
    description: User Management
  - name: Website
    description: Website Management
  - name: Stats
    description: Statistics
paths:
  /event/hit:
    post:
      tags:
        - Event
      summary: Send Hit Event
      description: Send a hit event to register a user view or interaction.
      operationId: post-event-hit
      parameters:
        - name: User-Agent
          in: header
          schema:
            type: string
          description: Used to infer user browser, OS and device.
        - name: Accept-Language
          in: header
          description: Used to infer user language.
          schema:
            type: string
      requestBody:
        description: Hit event metadata.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventHit'
        required: true
      responses:
        '204':
          description: OK.
        '400':
          $ref: '#/components/responses/BadRequestError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    EventHit:
      title: EventHit
      description: Website hit event.
      oneOf:
        - $ref: '#/components/schemas/EventLoad'
        - $ref: '#/components/schemas/EventUnload'
        - $ref: '#/components/schemas/EventCustom'
      discriminator:
        propertyName: e
        mapping:
          load: '#/components/schemas/EventLoad'
          unload: '#/components/schemas/EventUnload'
          custom: '#/components/schemas/EventCustom'
    EventLoad:
      title: EventLoad
      description: Page view load event.
      type: object
      properties:
        b:
          type: string
          description: >-
            Beacon ID generated for each user to link multiple events on the
            same page together.
        u:
          type: string
          description: Page URL including query parameters.
          format: uri
        r:
          type: string
          description: Referrer URL.
        p:
          type: boolean
          description: If the user is a unique user or not.
        q:
          type: boolean
          description: If the user has visited this page before or not.
        t:
          type: string
          description: Timezone of the user.
        d:
          type: object
          description: Custom event properties.
          additionalProperties:
            oneOf:
              - type: string
              - type: integer
              - type: boolean
      required:
        - b
        - u
        - p
        - q
    EventUnload:
      title: EventUnload
      description: Page view unload event.
      type: object
      properties:
        b:
          type: string
          description: >-
            Beacon ID generated for each user to link multiple events on the
            same page together.
        m:
          type: integer
          description: Time spent on page in milliseconds.
          minimum: 0
          exclusiveMinimum: true
      required:
        - b
        - m
    EventCustom:
      title: EventCustom
      description: Event with custom properties.
      type: object
      properties:
        b:
          type: string
          description: >-
            Optional Beacon ID generated for each user to link multiple events
            on the same page together.
        g:
          type: string
          description: Group name of events. Currently, only the hostname is supported.
        d:
          type: object
          description: Custom event properties.
          additionalProperties:
            oneOf:
              - type: string
              - type: integer
              - type: boolean
      required:
        - g
        - d
  responses:
    BadRequestError:
      description: 400 Bad Request.
      headers:
        X-Api-Commit:
          $ref: '#/components/headers/X-Api-Commit'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                additionalProperties: false
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 400
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - error
    NotFoundError:
      description: 404 Not Found.
      headers:
        X-Api-Commit:
          $ref: '#/components/headers/X-Api-Commit'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                additionalProperties: false
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 404
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - error
    InternalServerError:
      description: 500 Unexpected Internal Server Error.
      headers:
        X-Api-Commit:
          $ref: '#/components/headers/X-Api-Commit'
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                additionalProperties: false
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 500
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - error
  headers:
    X-Api-Commit:
      description: >-
        A custom header used to identify the commit of the API. This can be used
        to force reload the client if the API has been updated.
      schema:
        type: string
        example: 97dd2ae

````