I’m trying to automate an outbound call flow where a system initiates a call on behalf of a specific agent. The idea is that the agent gets the call connected to them immediately, but the external party sees the agent’s extension number as the caller ID.
I’m using the Genesys Cloud Python SDK for this. I have the access token sorted out via client credentials flow, so auth isn’t the issue. The problem hits when I try to POST to /api/v2/conversations/calls.
Here is the payload I’m sending:
import purecloud_platform_sdk
from purecloud_platform_sdk.models import CreateCallRequest, Participant
client = purecloud_platform_sdk.ApiClient(
host="https://api.eu-genesyscloud.com",
access_token=my_token
)
# The agent's ID
agent_id = "12345-67890-abcdef"
# The number to call
target_number = "tel:+441234567890"
# I want the call to originate FROM the agent
from_participant = Participant(
id=agent_id,
address=f"user:{agent_id}",
to="tel:+441234567890"
)
to_participant = Participant(
to=f"user:{agent_id}" # Connecting back to the agent? Or just leaving blank?
)
request = CreateCallRequest(
participants=[from_participant, to_participant]
)
try:
response = client.conversations_api.post_conversations_calls(body=request)
print(f"Call created: {response.id}")
except Exception as e:
print(f"Error: {e}")
When I run this, I get a 400 Bad Request. The error message says Address is not valid. It specifically points to the from_participant address.
I’ve tried using user:{agent_id} and tel:{agent_extension} but both fail. I thought maybe I need to use the agent’s actual phone number address instead of their user ID. But the docs say you can use user IDs for internal routing.
Also, am I structuring the to_participant correctly? If I’m making the call on behalf of the agent, do I even need a second participant in the request body, or does the API assume the caller is the initiator?
I’m a bit confused by the difference between id and address in the Participant object. The id is clearly the UUID, but what exactly goes in address for an outbound call originating from a user?
Any help would be great. I’ve been staring at the API docs for an hour and it’s not clicking.