REST ClientCalling

play

View as MarkdownOpen in Claude

Play audio or text-to-speech on an active call. Returns a control_id that can be used with play_pause(), play_resume(), play_stop(), and play_volume() to manage the playback.

Request

idstringRequiredformat: "uuid"
The unique identifying ID of a existing call.
paramsobjectRequired
An object of parameters that will be utilized by the active command.

Response

Call LegobjectRequired
Returned when the call is a standard PSTN, SIP, or WebRTC call.
OR
Fabric Subscriber Device LegobjectRequired

Examples

Play TTS

1from signalwire.rest import RestClient
2
3client = RestClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7)
8
9# Play TTS
10result = client.calling.play(
11 call_id="call-id-xxx",
12 play=[{"type": "tts", "text": "Hello from the REST API!"}]
13)
14control_id = result.get("control_id")

Play Audio File

1from signalwire.rest import RestClient
2
3client = RestClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7)
8
9client.calling.play(
10 call_id="call-id-xxx",
11 play=[{"type": "audio", "url": "https://example.com/greeting.mp3"}]
12)

Play Multiple Items

1from signalwire.rest import RestClient
2
3client = RestClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7)
8
9client.calling.play(
10 call_id="call-id-xxx",
11 play=[
12 {"type": "tts", "text": "Please hold while we connect you."},
13 {"type": "silence", "duration": 1},
14 {"type": "audio", "url": "https://example.com/hold-music.mp3"},
15 ]
16)