Getting a 400 Bad Request when trying to kick off a recording via the API. The UI works fine, but the code fails.
- Endpoint:
POST /api/v2/recordings/sessions/{sessionId}/startRecording
- Payload:
{} (empty JSON body as per docs)
- Token: Valid OAuth2 token
Here’s the response body:
{"errors": [{"code": "invalidRequest", "message": "The request is invalid"}]}
Any idea what’s missing?
You’re sending an empty object {}. That’s usually what triggers the 400. The API expects at least a recordingType or specific config params depending on your org’s recording rules. Even if it’s a “record all” setup, the endpoint often demands explicit intent.
Try adding recordingType to the body. Here’s the working payload I use for standard call recordings:
{
"recordingType": "call"
}
If you’re trying to record a screen share or something else, swap that value out. Also, double-check the token scopes. call:recording:write is mandatory. If you’re using a service account, make sure it has the right permissions attached.
It’s annoying the docs don’t explicitly say “don’t send an empty body,” but that’s Genesys for you.
Spot on, . I ran into this exact same headache last week when building a hybrid recording trigger. The docs for that endpoint are a bit light on the actual JSON schema requirements, which is super frustrating.
Adding recordingType definitely fixed the 400 error. Just a quick heads up for anyone else hitting this wall: if you’re dealing with a conference or multi-leg interaction, you might need to specify which leg you want to record. Here’s the payload that worked for my standard outbound calls using the Python SDK, which handles the token refresh automatically so I don’t have to worry about that part.
from platformclientv2 import RecordingApi, StartRecordingRequest
# Assuming platform_client is already initialized and authenticated
recording_api = RecordingApi(platform_client)
start_recording_request = StartRecordingRequest()
start_recording_request.recording_type = "call" # Crucial field
try:
# Replace with your actual session ID
session_id = "your-session-id-here"
result = recording_api.post_recordings_sessions_session_id_start_recording(
session_id=session_id,
body=start_recording_request
)
print(f"Recording started: {result}")
except Exception as e:
print(f"Failed to start recording: {e}")
It’s worth checking your org’s recording rules too. If you have a rule that says “Record if agent is present,” the API call might still fail if the session state doesn’t match that criteria at the moment of the call. Double check the interaction metadata if the payload fix doesn’t immediately clear it up.