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

# Mute LiveKit participant

> Mutes or unmutes a participant's published track.
Access is authorized via `metadata.auth_id` check.

# Arguments
* `state` - Shared application state containing LiveKit configuration
* `auth` - Authentication context from middleware
* `request` - Request with room name, participant identity, track_sid, and muted state

# Returns
* `Response` - JSON response with mute status or error

# Authorization
- When `auth.id` is present: Requires `room.metadata.auth_id == auth.id`
- When `auth.id` is absent: Access is allowed (backward-compatible mode)

# Errors
* 400 Bad Request - Empty fields in request
* 404 Not Found - Room/participant not found or access denied (masked)
* 500 Internal Server Error - LiveKit not configured or mute operation failed

Mutes or unmutes a participant's published track. Access is authorized via `metadata.auth_id` check.

## Authorization

| Mode                               | Behavior                                      |
| ---------------------------------- | --------------------------------------------- |
| Authenticated (`auth.id` present)  | Requires `room.metadata.auth_id == auth.id`.  |
| Unauthenticated (`auth.id` absent) | Access is allowed (backward-compatible mode). |

<Note>
  Room names are used exactly as provided. No prefixing or modification is applied.
</Note>

## Request

Requires:

* `room_name` - The LiveKit room where the participant is connected
* `participant_identity` - The identity of the participant whose track to mute
* `track_sid` - The session ID of the track to mute/unmute
* `muted` - `true` to mute, `false` to unmute

## Error responses

| Status                      | Condition                                                          |
| --------------------------- | ------------------------------------------------------------------ |
| `400 Bad Request`           | Empty required fields in request.                                  |
| `404 Not Found`             | Room/participant not found or access denied (masked for security). |
| `500 Internal Server Error` | LiveKit not configured or mute operation failed.                   |


## OpenAPI

````yaml POST /livekit/participant/mute
openapi: 3.1.0
info:
  title: Sayna API
  description: >-
    Real-time voice processing server with Speech-to-Text (STT) and
    Text-to-Speech (TTS) services
  contact:
    name: Sayna
    url: https://api.sayna.ai
  license:
    name: Apache-2.0
    identifier: Apache-2.0
  version: 0.1.0
servers:
  - url: https://api.sayna.ai
    description: Production API
  - url: http://localhost:3001
    description: Local development
security: []
tags:
  - name: health
    description: Health check endpoints
  - name: voices
    description: TTS voice management
  - name: tts
    description: Text-to-speech synthesis
  - name: livekit
    description: LiveKit room and token management
  - name: recordings
    description: Recording download operations
  - name: sip
    description: SIP webhook configuration management
  - name: websocket
    description: WebSocket API for real-time communication
paths:
  /livekit/participant/mute:
    post:
      tags:
        - livekit
      summary: Handler for POST /livekit/participant/mute endpoint
      description: >-
        Mutes or unmutes a participant's published track.

        Access is authorized via `metadata.auth_id` check.


        # Arguments

        * `state` - Shared application state containing LiveKit configuration

        * `auth` - Authentication context from middleware

        * `request` - Request with room name, participant identity, track_sid,
        and muted state


        # Returns

        * `Response` - JSON response with mute status or error


        # Authorization

        - When `auth.id` is present: Requires `room.metadata.auth_id == auth.id`

        - When `auth.id` is absent: Access is allowed (backward-compatible mode)


        # Errors

        * 400 Bad Request - Empty fields in request

        * 404 Not Found - Room/participant not found or access denied (masked)

        * 500 Internal Server Error - LiveKit not configured or mute operation
        failed
      operationId: mute_participant
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MuteParticipantRequest'
        required: true
      responses:
        '200':
          description: Track muted/unmuted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MuteParticipantResponse'
        '400':
          description: Invalid request (empty fields)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RemoveParticipantErrorResponse'
        '404':
          description: Room or participant not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RemoveParticipantErrorResponse'
        '500':
          description: LiveKit not configured or mute failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RemoveParticipantErrorResponse'
      security:
        - auth: []
components:
  schemas:
    MuteParticipantRequest:
      type: object
      description: |-
        Request body for muting/unmuting a participant's track

        # Example
        ```json
        {
          "room_name": "conversation-room-123",
          "participant_identity": "user-alice-456",
          "track_sid": "TR_abc123",
          "muted": true
        }
        ```
      required:
        - room_name
        - participant_identity
        - track_sid
        - muted
      properties:
        muted:
          type: boolean
          description: True to mute, false to unmute
          example: true
        participant_identity:
          type: string
          description: The identity of the participant whose track to mute
          example: user-alice-456
        room_name:
          type: string
          description: The LiveKit room name where the participant is connected
          example: conversation-room-123
        track_sid:
          type: string
          description: The session ID of the track to mute/unmute
          example: TR_abc123
    MuteParticipantResponse:
      type: object
      description: |-
        Response for a successful mute/unmute operation

        # Example
        ```json
        {
          "room_name": "conversation-room-123",
          "participant_identity": "user-alice-456",
          "track_sid": "TR_abc123",
          "muted": true
        }
        ```
      required:
        - room_name
        - participant_identity
        - track_sid
        - muted
      properties:
        muted:
          type: boolean
          description: Current muted state
          example: true
        participant_identity:
          type: string
          description: The identity of the participant
          example: user-alice-456
        room_name:
          type: string
          description: The room name
          example: conversation-room-123
        track_sid:
          type: string
          description: The session ID of the track
          example: TR_abc123
    RemoveParticipantErrorResponse:
      type: object
      description: |-
        Error response for participant removal failures

        # Example
        ```json
        {
          "error": "Participant 'user-123' not found in room",
          "code": "PARTICIPANT_NOT_FOUND"
        }
        ```
      required:
        - error
        - code
      properties:
        code:
          type: string
          description: Machine-readable error code
          example: PARTICIPANT_NOT_FOUND
        error:
          type: string
          description: Human-readable error message
          example: Participant not found in room
  securitySchemes:
    auth:
      type: http
      scheme: bearer
      bearerFormat: Token
      description: >-
        Authentication token for protected endpoints. Can be provided as
        `Authorization: Bearer <token>` or `?api_key=<token>`. Required when
        AUTH_REQUIRED is enabled.

````