Pause and resume a call recording over REST
Start recording a live call from your own backend, pause it while a card number is read out, resume it, and stop it, all by control id over REST.
The claim
A recording does not have to be declared in the call’s document. Any process holding the call id can start one with POST /api/calling/calls and command: calling.record, then pause, resume and stop it by the control_id it chose. That is how an agent desktop with a Pause recording button works when the call itself was set up somewhere else.
Why it holds
The vendored REST spec, tools/openapi/rest.json, is the authority for the shapes.
calling.recordrequirescontrol_idandrecord, andrecordrequiresaudio. The audio params includestereo,direction,formatandmax_length, where0means no limit.- Three audio params decide when the recording stops on its own, and their REST defaults suit a voice prompt:
initial_timeout4 seconds,end_silence_timeout0.5 seconds,terminators#. Left alone they would end a call recording during the first pause. SWML’s whole-call verb,record_call, defaults the same three to0,0and the empty string, and that is what this recipe sends. calling.record.pauserequirescontrol_idand takes abehavior:skipomits the paused audio from the file,silencereplaces it with silence and keeps the timing.calling.record.resumeandcalling.record.stoprequire onlycontrol_id.
The verifier proves the five requests. The spec is the authority for what the platform does with them.
How it works
CONTROL_ID = "agent-desk-recording"
WHOLE_CALL = {"initial_timeout": 0, "end_silence_timeout": 0, "terminators": ""}
def start(call_id, status_url=None):
audio = {"stereo": True, "direction": "both", "format": "mp3", "max_length": 0,
**WHOLE_CALL}
params = {"control_id": CONTROL_ID, "record": {"audio": audio}}
if status_url:
params["status_url"] = status_url
return client.calling.record(call_id, **params)
def pause(call_id):
return client.calling.record_pause(call_id, control_id=CONTROL_ID, behavior="silence")What the platform receives for pause:
{"command": "calling.record.pause",
"id": "6d3f4a0e-2b1c-4e7a-9f0d-1c2b3a4d5e6f",
"params": {"control_id": "agent-desk-recording", "behavior": "silence"}}The SDK’s calling namespace, rest/namespaces/calling.py, sends every call command to that one path and puts the call id in id. The control id is yours to choose. It must be unique among the recordings active on the call, and the same value carries through pause, resume and stop.
The spec says the HTTP response to calling.record returns the call leg and not the recording URL. Pass a status_url to receive a webhook when the recording finishes, with the final URL. Without one, the call’s events endpoint is where the URL turns up.
Limitations
The verifier proves the requests, not the file. Whether the pause reads as a gap of silence is what the finished recording shows.
Pausing the recording does not pause the call. The caller keeps talking; only the file stops filling.
What a recording does at initial_timeout: 0 is the platform’s behaviour, not something this recipe proves. The value is the one SWML uses for a whole-call recording.
What to change first
Change PAUSE_BEHAVIOR to "skip" and run the verifier. The exact body comparison fails on behavior, which is the point: the two values produce different files, and the verifier pins which one this recipe ships.