***

title: tap
slug: /reference/typescript/agents/function-result/tap
description: Stream call audio to an external endpoint via WebSocket or RTP.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

Start a media tap that streams call audio to an external endpoint. Supports
WebSocket (`wss://`, `ws://`) and RTP (`rtp://`) destinations.

## **Parameters**

<ParamField path="opts" type="object" required={true} toc={true}>
  Tap configuration object.
</ParamField>

<Indent>
  <ParamField path="opts.uri" type="string" required={true} toc={true}>
    Destination URI for the media stream. Supported formats:

    * `"rtp://IP:port"` — RTP stream
    * `"ws://example.com"` — WebSocket stream
    * `"wss://example.com"` — Secure WebSocket stream
  </ParamField>

  <ParamField path="opts.controlId" type="string" toc={true}>
    Identifier for this tap. Pass the same ID to `stopTap()` to end this
    specific tap. If omitted, a default ID is generated.
  </ParamField>

  <ParamField path="opts.direction" type={'"speak" | "hear" | "both"'} toc={true}>
    Audio direction to tap.

    * `"speak"` -- what the party says
    * `"hear"` -- what the party hears
    * `"both"` -- both directions
  </ParamField>

  <ParamField path="opts.codec" type={'"PCMU" | "PCMA"'} toc={true}>
    Audio codec for the stream.

    * `"PCMU"` -- G.711 mu-law
    * `"PCMA"` -- G.711 A-law
  </ParamField>

  <ParamField path="opts.rtpPtime" type="number" toc={true}>
    Packetization time in milliseconds for RTP streams.
  </ParamField>

  <ParamField path="opts.statusUrl" type="string" toc={true}>
    URL to receive tap status change webhooks.
  </ParamField>
</Indent>

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Example**

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult()
  .tap({ uri: 'wss://example.com/tap', direction: 'both' });
```