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

# Create Trip Event

> Records an event.



## OpenAPI

````yaml /api-reference/ops/openapi.json post /api/v1/ops/trips/{tripId}/events
openapi: 3.0.0
info:
  title: OABUS OPS API
  description: OABUS API
  version: '1.0'
  contact: {}
servers: []
security: []
tags: []
paths:
  /api/v1/ops/trips/{tripId}/events:
    post:
      tags:
        - Trip
      summary: Create Trip Event
      description: Records an event.
      operationId: createTripEvent
      parameters:
        - name: tripId
          required: true
          in: path
          schema:
            type: string
            format: uuid
            description: Trip identifier
            example: 0195e7a1-8b5c-7d3e-9f4a-2c6b8d0e1f3a
        - name: fields
          required: false
          in: query
          description: >-
            Comma-separated list of fields to include in the response. Supports
            dot notation for nested projection (e.g.
            `id,name,user.email,trips.route.id`). Unknown fields are silently
            dropped.
          schema:
            type: string
      requestBody:
        $ref: '#/components/requestBodies/CreateTripEventRequestBody'
      responses:
        '201':
          $ref: '#/components/responses/CreateTripEvent201Response'
        '400':
          $ref: '#/components/responses/CreateTripEvent400Response'
        '401':
          $ref: '#/components/responses/CreateTripEvent401Response'
        '403':
          $ref: '#/components/responses/CreateTripEvent403Response'
        '500':
          $ref: '#/components/responses/CreateTripEvent500Response'
      security:
        - bearer: []
        - bearer: []
components:
  requestBodies:
    CreateTripEventRequestBody:
      required: true
      content:
        application/json:
          schema:
            allOf:
              - oneOf:
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - DRIVER_CHANGED
                      metadata:
                        type: object
                        properties:
                          previousDriverId:
                            type: string
                            format: uuid
                            description: Previous driver identifier
                          previousDriverName:
                            type: string
                            description: Previous driver name
                            example: Carlos Silva
                          previousDriverLicenseNumber:
                            type: string
                            description: Previous driver license number
                            example: '12345678900'
                          newDriverId:
                            type: string
                            format: uuid
                            description: New driver identifier
                          newDriverName:
                            type: string
                            description: New driver name
                            example: João Santos
                          newDriverLicenseNumber:
                            type: string
                            description: New driver license number
                            example: '09876543211'
                        required:
                          - previousDriverId
                          - previousDriverName
                          - previousDriverLicenseNumber
                          - newDriverId
                          - newDriverName
                          - newDriverLicenseNumber
                    required:
                      - type
                      - metadata
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - VEHICLE_CHANGED
                      metadata:
                        type: object
                        properties:
                          previousVehicleId:
                            type: string
                            format: uuid
                            description: Previous vehicle identifier
                          previousVehicleLicensePlate:
                            type: string
                            description: Previous vehicle license plate
                            example: ABC-1234
                          previousVehicleModel:
                            type: string
                            description: Previous vehicle model
                            example: Paradiso G7 1200
                          newVehicleId:
                            type: string
                            format: uuid
                            description: New vehicle identifier
                          newVehicleLicensePlate:
                            type: string
                            description: New vehicle license plate
                            example: XYZ-5678
                          newVehicleModel:
                            type: string
                            description: New vehicle model
                            example: Paradiso G8 1350
                        required:
                          - previousVehicleId
                          - previousVehicleLicensePlate
                          - previousVehicleModel
                          - newVehicleId
                          - newVehicleLicensePlate
                          - newVehicleModel
                    required:
                      - type
                      - metadata
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - DEPARTURE_DELAYED
                      metadata:
                        type: object
                        properties:
                          delayMinutes:
                            type: integer
                            description: Delay in minutes
                            example: 15
                          newEstimatedTime:
                            description: New estimated time (ISO 8601)
                            example: '2026-04-15T08:15:00.000Z'
                            nullable: true
                            type: string
                          reason:
                            description: Delay reason
                            example: Traffic congestion
                            nullable: true
                            type: string
                        required:
                          - delayMinutes
                    required:
                      - type
                      - metadata
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - ARRIVAL_DELAYED
                      metadata:
                        type: object
                        properties:
                          delayMinutes:
                            type: integer
                            description: Delay in minutes
                            example: 15
                          newEstimatedTime:
                            description: New estimated time (ISO 8601)
                            example: '2026-04-15T08:15:00.000Z'
                            nullable: true
                            type: string
                          reason:
                            description: Delay reason
                            example: Traffic congestion
                            nullable: true
                            type: string
                        required:
                          - delayMinutes
                    required:
                      - type
                      - metadata
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - BOARDING_STARTED
                      metadata:
                        nullable: true
                        type: object
                        properties:
                          expectedPassengers:
                            description: Expected number of passengers
                            example: 32
                            nullable: true
                            type: integer
                          stopName:
                            description: Stop name where boarding started
                            example: Terminal Rodoviário Tietê
                            nullable: true
                            type: string
                    required:
                      - type
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - BOARDING_COMPLETED
                      metadata:
                        type: object
                        properties:
                          totalPassengers:
                            type: integer
                            description: Total boarded passengers
                            example: 28
                          noShowCount:
                            description: Passengers that did not board
                            example: 4
                            nullable: true
                            type: integer
                          stopName:
                            description: Stop name where boarding completed
                            example: Terminal Rodoviário Tietê
                            nullable: true
                            type: string
                        required:
                          - totalPassengers
                    required:
                      - type
                      - metadata
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - INCIDENT
                      metadata:
                        type: object
                        properties:
                          severity:
                            type: string
                            enum:
                              - LOW
                              - MEDIUM
                              - HIGH
                              - CRITICAL
                            description: Incident severity
                            example: MEDIUM
                          category:
                            type: string
                            enum:
                              - MECHANICAL
                              - ACCIDENT
                              - WEATHER
                              - PASSENGER
                              - ROAD_BLOCK
                              - OTHER
                            description: Incident category
                            example: MECHANICAL
                          affectedPassengers:
                            description: Number of affected passengers
                            example: 28
                            nullable: true
                            type: integer
                          requiresReplacement:
                            description: Whether a replacement vehicle is needed
                            example: false
                            nullable: true
                            type: boolean
                        required:
                          - severity
                          - category
                    required:
                      - type
                      - metadata
                description: Trip event type-metadata union
              - type: object
                properties:
                  description:
                    description: Event description
                    example: Departure delayed by 15 minutes due to traffic
                    nullable: true
                    type: string
                  tripStopId:
                    description: Trip stop identifier
                    example: 0195e7a1-8b5c-7d3e-9f4a-2c6b8d0e1f3c
                    nullable: true
                    type: string
                    format: uuid
            description: Create trip event payload
  responses:
    CreateTripEvent201Response:
      content:
        application/json:
          schema:
            type: object
            properties:
              tripEventId:
                type: string
                format: uuid
                description: Trip event identifier
                example: 0195e7a1-8b5c-7d3e-9f4a-2c6b8d0e1f3a
              tripId:
                type: string
                format: uuid
                description: Trip identifier
                example: 0195e7a1-8b5c-7d3e-9f4a-2c6b8d0e1f3b
              tripStopId:
                description: Trip stop identifier
                example: 0195e7a1-8b5c-7d3e-9f4a-2c6b8d0e1f3c
                nullable: true
                type: string
                format: uuid
              type:
                type: string
                enum:
                  - DRIVER_CHANGED
                  - VEHICLE_CHANGED
                  - DEPARTURE_DELAYED
                  - ARRIVAL_DELAYED
                  - BOARDING_STARTED
                  - BOARDING_COMPLETED
                  - INCIDENT
                description: Trip event type
                example: DEPARTURE_DELAYED
              description:
                description: Event description
                example: Departure delayed by 15 minutes due to traffic
                nullable: true
                type: string
              metadata:
                description: Event metadata
                nullable: true
                type: object
                additionalProperties: {}
              createdBy:
                description: Created by
                example: null
                nullable: true
                type: string
                format: uuid
              updatedBy:
                description: Updated by
                example: null
                nullable: true
                type: string
                format: uuid
              createdAt:
                type: string
                format: date-time
                description: Created at
                example: '2026-01-01T00:00:00.000Z'
              updatedAt:
                type: string
                format: date-time
                description: Updated at
                example: '2026-01-01T00:00:00.000Z'
            required:
              - tripEventId
              - tripId
              - type
              - createdAt
              - updatedAt
            additionalProperties: false
      description: Created
    CreateTripEvent400Response:
      content:
        application/json:
          example:
            errors:
              - message: required
                path: name
            message: Bad Request Error
            statusCode: 400
          schema:
            properties:
              message:
                type: string
              statusCode:
                enum:
                  - 400
                type: number
              errors:
                items:
                  properties:
                    message:
                      type: string
                    path:
                      type: string
                  required:
                    - message
                    - path
                  type: object
                type: array
            required:
              - message
              - statusCode
            type: object
      description: Bad Request Error
    CreateTripEvent401Response:
      content:
        application/json:
          example:
            message: Missing or invalid access token
            statusCode: 401
          schema:
            properties:
              message:
                type: string
              statusCode:
                enum:
                  - 401
                type: number
            required:
              - message
              - statusCode
            type: object
      description: Unauthorized
    CreateTripEvent403Response:
      content:
        application/json:
          example:
            message: Insufficient permissions
            statusCode: 403
          schema:
            properties:
              message:
                type: string
              statusCode:
                enum:
                  - 403
                type: number
            required:
              - message
              - statusCode
            type: object
      description: Forbidden
    CreateTripEvent500Response:
      content:
        application/json:
          example:
            message: Internal Server Error
            statusCode: 500
          schema:
            properties:
              message:
                type: string
              statusCode:
                enum:
                  - 500
                type: number
            required:
              - message
              - statusCode
            type: object
      description: Internal Server Error
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````