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

# Send a chat message (REST fallback)

> Persists a chat message to the database and broadcasts it to the job room
via Socket.IO. Prefer the `chat:send` Socket.IO event for lower latency;
use this endpoint when WebSocket is unavailable.




## OpenAPI

````yaml /openapi.yaml post /jobs/{jobId}/comms/messages
openapi: 3.1.0
info:
  title: MechZie API
  version: 1.0.0-rc1
  description: On-demand roadside mechanic dispatch service API (MechZie)
  contact:
    name: MechZie Support
    email: support@mechzie.com
  license:
    name: MIT
    identifier: MIT
servers:
  - url: http://localhost:3000
    description: Local development
  - url: https://mechzie-api-399967621389.asia-south1.run.app/api/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: auth
    description: Authentication and token management
  - name: users
    description: User profile operations
  - name: vehicles
    description: Customer vehicle management
  - name: mechanics
    description: Mechanic profile and availability
  - name: jobs
    description: Job lifecycle and line items
  - name: tracking
    description: Real-time location tracking
  - name: payments
    description: Razorpay payment integration
  - name: wallet
    description: Mechanic wallet, UPI accounts, disputes, refunds, and settlements
  - name: ratings
    description: Customer and mechanic ratings
  - name: service-categories
    description: Service category management
  - name: notifications
    description: Push notifications and FCM tokens
  - name: uploads
    description: S3 presigned URL generation
  - name: admin
    description: Admin dashboard and management
  - name: super-admin
    description: Super-admin only operations (invite management, role assignment)
  - name: comms
    description: In-job audio calls (100ms) and persistent chat (Socket.IO + REST)
  - name: call
    description: >-
      Call signaling layer — initiate, accept, decline, cancel, end (ringing via
      FCM + Redis over 100ms rooms)
  - name: health
    description: Health check endpoints
paths:
  /jobs/{jobId}/comms/messages:
    post:
      tags:
        - comms
      summary: Send a chat message (REST fallback)
      description: >
        Persists a chat message to the database and broadcasts it to the job
        room

        via Socket.IO. Prefer the `chat:send` Socket.IO event for lower latency;

        use this endpoint when WebSocket is unavailable.
      parameters:
        - name: jobId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                  minLength: 1
                  maxLength: 2000
              required:
                - content
      responses:
        '201':
          description: Message saved and broadcast
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ChatMessage'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            Not a participant in this job, or job status does not allow
            communication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    ChatMessage:
      type: object
      description: A persistent chat or call-event message saved to the database
      properties:
        id:
          type: string
          format: uuid
        job_id:
          type: string
          format: uuid
        sender_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            User ID of the message sender; null for system-generated call events
            (call_missed, call_ended)
        content:
          type: string
          maxLength: 2000
        message_type:
          type: string
          enum:
            - chat
            - call_event
          default: chat
          description: chat for regular messages; call_event for signaling audit entries
        created_at:
          type: string
          format: date-time
      required:
        - id
        - job_id
        - content
        - message_type
        - created_at
    Error:
      type: object
      description: Standard error envelope returned by all error responses
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code (e.g. NOT_FOUND, UNAUTHORIZED)
              example: NOT_FOUND
            message:
              type: string
              description: Human-readable description of the error
              example: Resource not found
            errors:
              type: object
              description: Field-level validation errors (only present on 422)
              additionalProperties:
                type: array
                items:
                  type: string
          required:
            - code
            - message
      required:
        - success
        - error
  responses:
    Unauthorized:
      description: Missing or invalid authentication token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationError:
      description: Request validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT access token from /auth/verify-otp

````