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

# Get Events

> Get events based on a query

<Info>This endpoint requires your [private API key](/api-reference/overview#authentication).</Info>


## OpenAPI

````yaml get /events
openapi: 3.0.0
info:
  title: trench API
  description: ''
  version: '1.0'
  contact: {}
servers: []
security: []
tags: []
paths:
  /events:
    get:
      tags:
        - events
      summary: Get events based on a query. Requires private API key in Bearer token.
      operationId: EventsController_getEvents
      parameters:
        - name: event
          required: false
          in: query
          description: The event name to filter by.
          schema:
            example: Created Account
            type: string
        - name: uuid
          required: false
          in: query
          description: The UUID to filter by.
          schema:
            example: 123e4567-e89b-12d3-a456-426614174000
            type: string
        - name: userId
          required: false
          in: query
          description: The user ID to filter by.
          schema:
            example: user-123
            type: string
        - name: groupId
          required: false
          in: query
          description: The group ID to filter by.
          schema:
            example: group-456
            type: string
        - name: anonymousId
          required: false
          in: query
          description: The anonymous ID to filter by.
          schema:
            example: anon-789
            type: string
        - name: instanceId
          required: false
          in: query
          description: The instance ID to filter by.
          schema:
            example: instance-101112
            type: string
        - name: startDate
          required: false
          in: query
          description: The start date to filter by.
          schema:
            example: '2022-01-01T00:00:00Z'
            type: string
        - name: endDate
          required: false
          in: query
          description: The end date to filter by.
          schema:
            example: '2022-12-31T23:59:59Z'
            type: string
        - name: limit
          required: false
          in: query
          description: The limit of records to return.
          schema:
            example: 100
            type: number
        - name: offset
          required: false
          in: query
          description: The offset of records to return.
          schema:
            example: 0
            type: number
        - name: orderByField
          required: false
          in: query
          description: The field to order by.
          schema:
            example: timestamp
            type: string
        - name: orderByDirection
          required: false
          in: query
          description: The direction to order by.
          schema:
            example: ASC
            enum:
              - ASC
              - DESC
            type: string
      responses:
        '200':
          description: The events have been successfully retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEventResponse'
      security:
        - bearer: []
components:
  schemas:
    PaginatedEventResponse:
      type: object
      properties:
        limit:
          type: number
          description: The limit of the pagination.
          nullable: true
        offset:
          type: number
          description: The offset of the pagination.
          nullable: true
        total:
          type: number
          description: The total number of results. If `null`, the total is unknown.
          nullable: true
        results:
          description: The events found based on the query.
          example:
            - uuid: '123'
              type: track
              event: user_signed_up
              userId: user-123
              groupId: group-456
              anonymousId: anon-789
              instanceId: instance-101112
              properties:
                key: value
          type: array
          items:
            $ref: '#/components/schemas/Event'
      required:
        - limit
        - offset
        - total
        - results
    Event:
      type: object
      properties:
        anonymousId:
          type: string
          description: >-
            The anonymous ID of the user. See
            [anonymousId](https://segment.com/docs/connections/spec/common/#anonymousid).
          example: guest-1234567890
        uuid:
          type: string
          description: The UUID of the event.
          example: 123e4567-e89b-12d3-a456-426614174000
        type:
          type: string
          description: The type of the event.
          example: track
        event:
          type: string
          description: The event name.
          example: User SignedUp
        userId:
          type: string
          description: The user ID.
          example: user-123
        groupId:
          type: string
          description: The group ID.
          example: group-456
        properties:
          type: object
          description: 'The properties of the event. Only used with `type: "track"`.'
          example:
            page: /home
            referrer: https://www.google.com
        timestamp:
          format: date-time
          type: string
          description: The timestamp of the event.
          example: '2021-01-01T00:00:00Z'
        instanceId:
          type: string
          description: >-
            Optional instance ID. Instance IDs are used to partition events by
            source. It is typically used for isolating data for the same
            customer. For instance, if you have a SaaS product, you may want to
            segment events by customer. In this case, you can set the instance
            ID to the customer's organizaiton ID.
          example: customer-1234567890
      required:
        - uuid
        - type
        - timestamp

````