How do I kick off a cobrowse session programmatically to inject a trace ID? I’m sending a POST to /api/v2/conversations/cobrowse/sessions with the agent and customer details, but it’s returning a 400 Bad Request. Here’s the payload I’m using:
{
"type": "cobrowse",
"to": [{"id": "agent-id", "type": "user"}],
"from": {"id": "customer-id", "type": "user"}
}
The docs are vague on the exact schema required for the to object. Am I missing a specific capability check or endpoint?
You’re hitting a 400 because the cobrowse endpoint expects a specific session context, not just user IDs. The payload you posted is missing the required externalContactId or the proper routing configuration if you’re trying to bridge an existing voice or messaging session. Genesys won’t let you spawn a cobrowse session in a vacuum without linking it to an active conversation or a pre-registered external contact.
Try using the SDK to handle the authentication and payload structure instead of raw curl. It’s cleaner and less prone to schema errors.
from purecloudplatformclientv2 import ConversationsApi
api_instance = ConversationsApi()
body = {
"type": "cobrowse",
"to": [{"id": "agent-id", "type": "user"}],
"from": {"id": "customer-id", "type": "externalContact"}, # Note the type
"externalContactId": "some-uuid" # Required for external triggers
}
try:
result = api_instance.post_conversations_cobrowse_sessions(body=body)
print(result)
except Exception as e:
print("Exception: %s\n" % e)
Check the from type. If it’s a user, it has to be in the same org. If it’s external, you need that ID.