Initiating cobrowse session via Conversations API returns 400 Bad Request

Anyone know why the cobrowse initiation endpoint is rejecting my payload with a generic 400 error? I am trying to automate session starts for QA audits using PowerShell. The documentation implies a simple POST should suffice, but I cannot get it to stick.

Here is the snippet I am using:

$uri = "https://api.mypurecloud.com/api/v2/conversations/webmessaging/sessions/$sessionId/cobrowse"
$payload = @{
 initiator = @{
 id = "agentId_123"
 type = "agent"
 }
}

Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Body ($payload | ConvertTo-Json) -Headers $authHeader

The token is valid (I can query the session details right before this). The error response is unhelpful:

The request could not be understood by the server due to malformed syntax. Please check the request body format.

I have tried changing the initiator object structure to include name, but it fails the same way. Is there a specific JSON schema requirement for the cobrowse initiation that isn’t documented? I am on PowerShell 7.4.

The quickest way to solve this is to ensure the payload schema matches the required initiator object structure.

$payload = @{
 initiator = @{
 type = "user"
 id = $userId
 }
} | ConvertTo-Json -Depth 10

Validate the JSON depth to prevent serialization truncation.

Have you tried using my typed Python wrapper instead of raw PowerShell? The generic 400 often stems from implicit type conversion issues in dynamic languages. My Pydantic models enforce strict schema validation before the HTTP request is even sent.

from genesys_cloud_wrapper import CobrowseInitiator

initiator = CobrowseInitiator(type="user", id=USER_ID)
client.conversations.post_cobrowse(session_id, payload=initiator)

The wrapper handles serialization depth automatically. This prevents the truncation errors mentioned in the suggestion above. Check if your user ID format matches the API spec exactly.