Trying to trigger recording start/stop on an active conversation via the REST API. Hitting POST /api/v2/recordings/controls/{controlId} but getting a 404. Is this endpoint even exposed for external use or do I need to use a specific webhook payload?
Are you hitting that endpoint against the correct environment? The 404 usually means the controlId isn’t valid or the recording session hasn’t actually started yet on the server side. You can’t just guess the ID. You need to fetch the active conversations first to find the specific control object.
Here is how I usually handle this in my DevOps scripts. First, get the conversation ID. Then, look at the controls array inside the conversation object. That’s where the real ID lives.
from purecloudplatformclientv2 import ConversationApi, RecordingApi
# 1. Get the conversation (assuming you have the conv_id from an event or search)
conversation_api = ConversationApi()
conv = conversation_api.get_conversation(id=conv_id)
# 2. Find the recording control ID
recording_control_id = None
for control in conv.controls:
if control.type == 'recording':
recording_control_id = control.id
break
if not recording_control_id:
print("No active recording control found")
else:
# 3. Toggle the recording
recording_api = RecordingApi()
# To stop: set active to False. To start: set active to True.
# Note: This is a PATCH or PUT depending on the SDK version
# The payload needs to be a ControlRequest
from purecloudplatformclientv2.models import ControlRequest
request_body = ControlRequest(active=False) # Stop recording
recording_api.put_recording_control(control_id=recording_control_id, body=request_body)
The key thing here is that controls is a list. If you’re in a multi-party call, there might be multiple control objects. Also, make sure your OAuth token has the recording:control scope. Without it, you’ll get a 403 instead of a 404, but it’s worth checking. I’ve seen cases where the recording starts but the control ID takes a second to populate, so adding a small sleep might help if you’re doing this immediately after initiating the call.