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

# Call streaming

> Bidirectional WebSocket channel for call audio streaming. Wavix opens the connection when a stream starts and closes it when the call ends.




## AsyncAPI

````yaml https://wavix.github.io/wavix-openapi/wavix-asyncapi.yaml callStreaming
id: callStreaming
title: Call streaming
description: >
  Bidirectional WebSocket channel for call audio streaming. Wavix opens the
  connection when a stream starts and closes it when the call ends.
servers:
  - id: externalService
    protocol: wss
    host: '{serviceHost}'
    bindings: []
    variables:
      - id: serviceHost
        description: Hostname of the external WebSocket service.
        allowedValues: []
        examples: []
      - id: servicePath
        description: Path of the external WebSocket service.
        allowedValues: []
        examples: []
address: '{servicePath}'
parameters: []
bindings: []
operations:
  - &ref_6
    id: sendConnected
    title: Send connected
    description: Send a connection event.
    type: send
    messages:
      - &ref_14
        id: ConnectedEvent
        payload:
          - name: connected
            description: Connection established.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: event_time
                type: string
                description: ISO 8601 timestamp of the event.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - event_time
          properties:
            event:
              type: string
              const: connected
              description: Event type.
              x-parser-schema-id: <anonymous-schema-1>
            event_time: &ref_0
              type: string
              format: date-time
              description: ISO 8601 timestamp of the event.
              x-parser-schema-id: EventTime
          x-parser-schema-id: ConnectedEvent
        title: connected
        description: Connection established.
        example: |-
          {
            "event": "connected",
            "event_time": "2024-01-15T10:30:00Z"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ConnectedEvent
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: callStreaming
  - &ref_7
    id: sendStart
    title: Send start
    description: Send a start event.
    type: send
    messages:
      - &ref_15
        id: StartEvent
        payload:
          - name: start
            description: Stream started.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: event_time
                type: string
                description: ISO 8601 timestamp of the event.
                required: true
              - name: call_id
                type: string
                description: Unique identifier for the call.
                required: true
              - name: stream_id
                type: string
                description: Unique identifier for the stream.
                required: true
              - name: stream_type
                type: string
                description: >
                  Direction of audio flow. `oneway` means audio flows from the
                  call to the external service. `twoway` means audio flows in
                  both directions.
                enumValues:
                  - oneway
                  - twoway
                required: true
              - name: channel
                type: string
                description: Call leg from which Wavix captures audio.
                enumValues:
                  - inbound
                  - outbound
                  - both
                required: true
              - name: sequence_number
                type: integer
                description: Sequential event counter for the stream, starting at 1.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - event_time
            - call_id
            - stream_id
            - stream_type
            - channel
            - sequence_number
          properties:
            event:
              type: string
              const: start
              description: Event type.
              x-parser-schema-id: <anonymous-schema-2>
            event_time: *ref_0
            call_id:
              type: string
              description: Unique identifier for the call.
              x-parser-schema-id: <anonymous-schema-3>
            stream_id:
              type: string
              description: Unique identifier for the stream.
              x-parser-schema-id: <anonymous-schema-4>
            stream_type:
              type: string
              enum:
                - oneway
                - twoway
              description: >
                Direction of audio flow. `oneway` means audio flows from the
                call to the external service. `twoway` means audio flows in both
                directions.
              x-parser-schema-id: <anonymous-schema-5>
            channel:
              type: string
              enum:
                - inbound
                - outbound
                - both
              description: Call leg from which Wavix captures audio.
              x-parser-schema-id: <anonymous-schema-6>
            sequence_number:
              type: integer
              format: int64
              description: Sequential event counter for the stream, starting at 1.
              x-parser-schema-id: <anonymous-schema-7>
          example:
            event: start
            event_time: '2024-01-15T10:30:00Z'
            call_id: abc-123
            stream_id: str-456
            stream_type: twoway
            channel: both
            sequence_number: 1
          x-parser-schema-id: StartEvent
        title: start
        description: Stream started.
        example: |-
          {
            "event": "start",
            "event_time": "2024-01-15T10:30:00Z",
            "call_id": "abc-123",
            "stream_id": "str-456",
            "stream_type": "twoway",
            "channel": "both",
            "sequence_number": 1
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: StartEvent
    bindings: []
    extensions: *ref_1
  - &ref_8
    id: sendMedia
    title: Send media
    description: Send call audio.
    type: send
    messages:
      - &ref_16
        id: OutgoingMediaEvent
        payload:
          - name: media
            description: Audio chunk captured from the call.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: event_time
                type: string
                description: ISO 8601 timestamp of the event.
                required: true
              - name: call_id
                type: string
                description: Unique identifier for the call.
                required: true
              - name: stream_id
                type: string
                description: Unique identifier for the stream.
                required: true
              - name: sequence_number
                type: integer
                description: Sequential event counter for the stream, starting at 1.
                required: true
              - name: media
                type: object
                required: true
                properties:
                  - name: payload
                    type: string
                    description: Base64-encoded audio chunk.
                    required: true
                  - name: track
                    type: string
                    description: Call leg from which the audio was captured.
                    enumValues:
                      - inbound
                      - outbound
                    required: true
                  - name: timestamp
                    type: integer
                    description: RTP timestamp of the audio chunk.
                    required: true
                  - name: chunk
                    type: integer
                    description: Sequential chunk number within the stream, starting at 1.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - event_time
            - call_id
            - stream_id
            - sequence_number
            - media
          properties:
            event:
              type: string
              const: media
              description: Event type.
              x-parser-schema-id: <anonymous-schema-8>
            event_time: *ref_0
            call_id:
              type: string
              description: Unique identifier for the call.
              x-parser-schema-id: <anonymous-schema-9>
            stream_id:
              type: string
              description: Unique identifier for the stream.
              x-parser-schema-id: <anonymous-schema-10>
            sequence_number:
              type: integer
              format: int64
              description: Sequential event counter for the stream, starting at 1.
              x-parser-schema-id: <anonymous-schema-11>
            media:
              type: object
              required:
                - payload
                - track
                - timestamp
                - chunk
              properties:
                payload:
                  type: string
                  description: Base64-encoded audio chunk.
                  x-parser-schema-id: <anonymous-schema-12>
                track:
                  type: string
                  enum:
                    - inbound
                    - outbound
                  description: Call leg from which the audio was captured.
                  x-parser-schema-id: <anonymous-schema-13>
                timestamp:
                  type: integer
                  format: int64
                  description: RTP timestamp of the audio chunk.
                  x-parser-schema-id: <anonymous-schema-14>
                chunk:
                  type: integer
                  format: int64
                  description: Sequential chunk number within the stream, starting at 1.
                  x-parser-schema-id: <anonymous-schema-15>
              x-parser-schema-id: OutgoingMediaPayload
          example:
            event: media
            event_time: '2024-01-15T10:30:01Z'
            call_id: abc-123
            stream_id: str-456
            sequence_number: 2
            media:
              payload: AAEC/f7...
              track: inbound
              timestamp: 160
              chunk: 1
          x-parser-schema-id: OutgoingMediaEvent
        title: media
        description: Audio chunk captured from the call.
        example: |-
          {
            "event": "media",
            "event_time": "2024-01-15T10:30:01Z",
            "call_id": "abc-123",
            "stream_id": "str-456",
            "sequence_number": 2,
            "media": {
              "payload": "AAEC/f7...",
              "track": "inbound",
              "timestamp": 160,
              "chunk": 1
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: OutgoingMediaEvent
    bindings: []
    extensions: *ref_1
  - &ref_9
    id: sendMark
    title: Send mark
    description: Send a playback acknowledgment.
    type: send
    messages:
      - &ref_17
        id: OutgoingMarkEvent
        payload:
          - name: mark
            description: Playback acknowledgment for the preceding media message.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: event_time
                type: string
                description: ISO 8601 timestamp of the event.
                required: true
              - name: call_id
                type: string
                description: Unique identifier for the call.
                required: true
              - name: stream_id
                type: string
                description: Unique identifier for the stream.
                required: true
              - name: sequence_number
                type: integer
                description: Sequential event counter for the stream, starting at 1.
                required: true
              - name: mark
                type: object
                required: true
                properties:
                  - name: name
                    type: string
                    description: >
                      Echo of the marker name from the original outgoing `mark`
                      message. Wavix sends this message when playback is
                      complete.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - event_time
            - call_id
            - stream_id
            - sequence_number
            - mark
          properties:
            event:
              type: string
              const: mark
              description: Event type.
              x-parser-schema-id: <anonymous-schema-16>
            event_time: *ref_0
            call_id:
              type: string
              description: Unique identifier for the call.
              x-parser-schema-id: <anonymous-schema-17>
            stream_id:
              type: string
              description: Unique identifier for the stream.
              x-parser-schema-id: <anonymous-schema-18>
            sequence_number:
              type: integer
              format: int64
              description: Sequential event counter for the stream, starting at 1.
              x-parser-schema-id: <anonymous-schema-19>
            mark:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: >
                    Echo of the marker name from the original outgoing `mark`
                    message. Wavix sends this message when playback is complete.
                  x-parser-schema-id: <anonymous-schema-20>
              example:
                name: end-of-greeting
              x-parser-schema-id: OutgoingMarkPayload
          example:
            event: mark
            event_time: '2024-01-15T10:30:02Z'
            call_id: abc-123
            stream_id: str-456
            sequence_number: 10
            mark:
              name: end-of-greeting
          x-parser-schema-id: OutgoingMarkEvent
        title: mark
        description: Playback acknowledgment for the preceding media message.
        example: |-
          {
            "event": "mark",
            "event_time": "2024-01-15T10:30:02Z",
            "call_id": "abc-123",
            "stream_id": "str-456",
            "sequence_number": 10,
            "mark": {
              "name": "end-of-greeting"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: OutgoingMarkEvent
    bindings: []
    extensions: *ref_1
  - &ref_10
    id: sendStop
    title: Send stop
    description: Send a stop event.
    type: send
    messages:
      - &ref_18
        id: StopEvent
        payload:
          - name: stop
            description: Stream ended.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: event_time
                type: string
                description: ISO 8601 timestamp of the event.
                required: true
              - name: call_id
                type: string
                description: Unique identifier for the call.
                required: true
              - name: stream_id
                type: string
                description: Unique identifier for the stream.
                required: true
              - name: sequence_number
                type: integer
                description: Sequential event counter for the stream, starting at 1.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - event_time
            - call_id
            - stream_id
            - sequence_number
          properties:
            event:
              type: string
              const: stop
              description: Event type.
              x-parser-schema-id: <anonymous-schema-21>
            event_time: *ref_0
            call_id:
              type: string
              description: Unique identifier for the call.
              x-parser-schema-id: <anonymous-schema-22>
            stream_id:
              type: string
              description: Unique identifier for the stream.
              x-parser-schema-id: <anonymous-schema-23>
            sequence_number:
              type: integer
              format: int64
              description: Sequential event counter for the stream, starting at 1.
              x-parser-schema-id: <anonymous-schema-24>
          example:
            event: stop
            event_time: '2024-01-15T10:30:05Z'
            call_id: abc-123
            stream_id: str-456
            sequence_number: 100
          x-parser-schema-id: StopEvent
        title: stop
        description: Stream ended.
        example: |-
          {
            "event": "stop",
            "event_time": "2024-01-15T10:30:05Z",
            "call_id": "abc-123",
            "stream_id": "str-456",
            "sequence_number": 100
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: StopEvent
    bindings: []
    extensions: *ref_1
  - &ref_3
    id: receiveMedia
    title: Receive media
    description: Receive audio for playback.
    type: receive
    messages:
      - &ref_11
        id: IncomingMediaEvent
        payload:
          - name: media
            description: Audio chunk to play back into the call.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: stream_id
                type: string
                description: >
                  If omitted, the event applies to the stream associated with
                  the connection that initiated the WebSocket session. Include
                  `stream_id` to enable server-side validation. Events with a
                  mismatched `stream_id` are silently dropped.
                required: false
              - name: media
                type: object
                required: true
                properties:
                  - name: payload
                    type: string
                    description: Base64-encoded PCM16 audio to play into the call.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - media
          properties:
            event:
              type: string
              const: media
              description: Event type.
              x-parser-schema-id: <anonymous-schema-25>
            stream_id: &ref_2
              type: string
              description: >
                If omitted, the event applies to the stream associated with the
                connection that initiated the WebSocket session. Include
                `stream_id` to enable server-side validation. Events with a
                mismatched `stream_id` are silently dropped.
              x-parser-schema-id: IncomingStreamId
            media:
              type: object
              required:
                - payload
              properties:
                payload:
                  type: string
                  description: Base64-encoded PCM16 audio to play into the call.
                  x-parser-schema-id: <anonymous-schema-26>
              x-parser-schema-id: IncomingMediaPayload
          example:
            event: media
            stream_id: str-456
            media:
              payload: BBCD/e...
          x-parser-schema-id: IncomingMediaEvent
        title: media
        description: Audio chunk to play back into the call.
        example: |-
          {
            "event": "media",
            "stream_id": "str-456",
            "media": {
              "payload": "AAEC/f7..."
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: IncomingMediaEvent
    bindings: []
    extensions: *ref_1
  - &ref_4
    id: receiveMark
    title: Receive mark
    description: Receive a playback marker.
    type: receive
    messages:
      - &ref_12
        id: IncomingMarkEvent
        payload:
          - name: mark
            description: Marker used to track playback completion.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: stream_id
                type: string
                description: >
                  If omitted, the event applies to the stream associated with
                  the connection that initiated the WebSocket session. Include
                  `stream_id` to enable server-side validation. Events with a
                  mismatched `stream_id` are silently dropped.
                required: false
              - name: mark
                type: object
                required: true
                properties:
                  - name: name
                    type: string
                    description: Marker name used to track playback completion.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
            - mark
          properties:
            event:
              type: string
              const: mark
              description: Event type.
              x-parser-schema-id: <anonymous-schema-27>
            stream_id: *ref_2
            mark:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Marker name used to track playback completion.
                  x-parser-schema-id: <anonymous-schema-28>
              x-parser-schema-id: IncomingMarkPayload
          example:
            event: mark
            stream_id: str-456
            mark:
              name: end-of-greeting
          x-parser-schema-id: IncomingMarkEvent
        title: mark
        description: Marker used to track playback completion.
        example: |-
          {
            "event": "mark",
            "stream_id": "str-456",
            "mark": {
              "name": "mark-1"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: IncomingMarkEvent
    bindings: []
    extensions: *ref_1
  - &ref_5
    id: receiveClear
    title: Receive clear
    description: Receive a clear event.
    type: receive
    messages:
      - &ref_13
        id: ClearEvent
        payload:
          - name: clear
            description: Clear buffered audio.
            type: object
            properties:
              - name: event
                type: string
                description: Event type.
                required: true
              - name: stream_id
                type: string
                description: >
                  If omitted, the event applies to the stream associated with
                  the connection that initiated the WebSocket session. Include
                  `stream_id` to enable server-side validation. Events with a
                  mismatched `stream_id` are silently dropped.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - event
          properties:
            event:
              type: string
              const: clear
              description: Event type.
              x-parser-schema-id: <anonymous-schema-29>
            stream_id: *ref_2
          example:
            event: clear
            stream_id: str-456
          x-parser-schema-id: ClearEvent
        title: clear
        description: Clear buffered audio.
        example: |-
          {
            "event": "clear",
            "stream_id": "str-456"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ClearEvent
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_3
  - *ref_4
  - *ref_5
receiveOperations:
  - *ref_6
  - *ref_7
  - *ref_8
  - *ref_9
  - *ref_10
sendMessages:
  - *ref_11
  - *ref_12
  - *ref_13
receiveMessages:
  - *ref_14
  - *ref_15
  - *ref_16
  - *ref_17
  - *ref_18
extensions:
  - id: x-parser-unique-object-id
    value: callStreaming
securitySchemes: []

````