REST ClientCalling

play

View as MarkdownOpen in Claude

Play audio or text-to-speech on an active call. Pass a control_id to name the operation so you can manage it later with play_pause(), play_resume(), play_stop(), and play_volume(). The response never carries control_id back — omit it and you have no way to control this playback afterward.

Request

idstringRequiredformat: "uuid"
The unique identifying ID of an 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

Returned when the call is a Fabric subscriber device leg. The status field is always null for this type.

Examples

Play TTS

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
# Play TTS -- name it so it can be paused, resumed, or stopped later
client.calling.play(
call_id="call-id-xxx",
control_id="play-1",
play=[{"type": "tts", "text": "Hello from the REST API!"}]
)

Play Audio File

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
client.calling.play(
call_id="call-id-xxx",
play=[{"type": "audio", "url": "https://example.com/greeting.mp3"}]
)

Play Multiple Items

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
client.calling.play(
call_id="call-id-xxx",
play=[
{"type": "tts", "text": "Please hold while we connect you."},
{"type": "silence", "duration": 1},
{"type": "audio", "url": "https://example.com/hold-music.mp3"},
]
)