***
id: a2e8f940-0d17-4421-a9bc-ff989163b3f2
title: tap
slug: /reference/tap
description: >-
Start background call tap. Media is streamed over Websocket or RTP to customer
controlled URI.
max-toc-depth: 3
----------------
[statuscallbacks]: #statuscallbacks
Start background call tap. Media is streamed over Websocket or RTP to customer controlled URI.
## **Properties**
An object that accepts the following properties.
Destination of the tap media stream: `rtp://IP:port`, `ws://example.com`, or `wss://example.com`
Identifier for this tap to use with `stop_tap`
speak\`\`
Direction of the audio to tap: `speak` for what party says, `listen` for what party hears, `both` for what party hears and says
PCMU\`\`
`PCMU` or `PCMA`
If using a `rtp://` URI, this optional parameter can set the packetization time of the media in milliseconds. Optional. Default 20 ms.
HTTP or HTTPS URL to deliver tap status events. Learn more about [status callbacks][statuscallbacks].
## **Variables**
Set by the method:
* **tap\_uri:** (out) The destination URI of the newly started tap.
* **tap\_result:** (out) `success` | `failed`.
* **tap\_control\_id:** (out) Control ID of this tap.
* **tap\_rtp\_src\_addr:** (out) If RTP, source address of the tap stream.
* **tap\_rtp\_src\_port:** (out) If RTP, source port of the tap stream.
* **tap\_ptime:** (out) Packetization time of the tap stream.
* **tap\_codec:** (out) Codec in the tap stream.
* **tap\_rate:** (out) Sample rate in the tap stream.
## **StatusCallbacks**
A POST request will be sent to `status_url` with a JSON payload like the following:
The type of event. Always `calling.call.tap` for this method.
The channel for the event, includes the SWML session ID.
Unix timestamp (float) when the event was generated.
The project ID associated with the call.
The Space ID associated with the call.
An object containing tap-specific parameters.
The call ID.
The node handling the call.
The segment ID for the call leg. Present when available.
The tag associated with the call. Present when set.
The control ID for this tap operation.
The current tap state. **Valid values:** `tapping`, `finished`.
Details about the tap media stream.
The type of media being tapped (e.g., `audio`).
The direction of audio being tapped.
Details about the destination device receiving the tap stream.
The type of device (e.g., `rtp`, `ws`).
The destination address for the tap stream.
The destination port for the tap stream.
The audio codec used for the tap stream (e.g., `PCMU`, `PCMA`).
The packetization time in milliseconds. Present for RTP taps only.
The WebSocket destination URI. Present for WebSocket taps only.
### Raw JSON example
```json
{
"event_type": "calling.call.tap",
"event_channel": "swml:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"timestamp": 1640000000.123,
"project_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"space_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"params": {
"call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"segment_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"state": "tapping",
"tap": {
"type": "audio",
"params": {
"direction": "both"
}
},
"device": {
"type": "rtp",
"params": {
"addr": "192.168.1.100",
"port": 12345,
"codec": "PCMU",
"ptime": 20
}
}
}
}
```
***
## **Examples**
### Start WSS tap
```yaml
version: 1.0.0
sections:
main:
- tap:
uri: wss://example.com/tap
```
```json
{
"version": "1.0.0",
"sections": {
"main": [
{
"tap": {
"uri": "wss://example.com/tap"
}
}
]
}
}
```