> ## 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.

# Create Events

> Use `track`, `identify`, and `group` to send events to Trench.

<Info>This endpoint requires your [public API key](/api-reference/overview#authentication).</Info>
Trench is fully compatible with the [Segment Spec](https://segment.com/docs/spec/) schema.

You can use the `track`, `identify`, and `group` methods to send events to Trench via the `/events` endpoint.


## OpenAPI

````yaml post /events
openapi: 3.0.0
info:
  title: trench API
  description: ''
  version: '1.0'
  contact: {}
servers: []
security: []
tags: []
paths:
  /events:
    post:
      tags:
        - events
      summary: Create one or more events. Requires public API key in Bearer token.
      operationId: EventsController_createEvents
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventsDTO'
      responses:
        '201':
          description: The events have been successfully created.
      security:
        - bearer: []
components:
  schemas:
    EventsDTO:
      type: object
      properties:
        events:
          description: The events to insert.
          type: array
          items:
            $ref: '#/components/schemas/EventDTO'
      required:
        - events
    EventDTO:
      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
        event:
          type: string
          description: 'The event name. Used only with `type: "track"`.'
          example: UserSignedUp
        timestamp:
          type: string
          description: The timestamp of the event. Autogenerated if not provided.
          example: '2021-01-01T00:00:00Z'
        type:
          type: string
          description: >-
            The type of the event. Possible values: `page`, `track`, `identify`,
            `group`.
          example: track
        userId:
          type: string
          description: The ID of the user.
          example: user-1234567890
        groupId:
          type: string
          description: The ID of the group.
          example: group-1234567890
        properties:
          type: object
          description: 'The properties of the event. Only used with `type: "track"`.'
          example:
            page: /home
            referrer: https://www.google.com
        traits:
          type: object
          description: The traits of the user or group.
          example:
            email: john.doe@example.com
            name: John Doe
        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

````