Thank you so much.
Original Message:
Sent: 10-10-2025 03:11
From: Jerome Saint-Marc
Subject: How do I create a new phone with Genesys Cloud API and Python?
Hello,
I must say I had not created a phone via API before....
As the Create phone page was mentioning line base settings, I have tried the following:
- You will need to retrieve the id of the line base settings that corresponds to the type of phone you are using. I assume you are creating a webRTC phone. You will find one entry for it using GET /api/v2/telephony/providers/edges/linebasesettings
- Then, just add a couple of lines in your code, to set it under a line object
api_client = PureCloudPlatformClientV2.api_client.ApiClient() \ .get_client_credentials_token(GENESYS_CLOUD_CLIENT_ID, GENESYS_CLOUD_CLIENT_SECRET)api_instance = PureCloudPlatformClientV2.TelephonyProvidersEdgeApi(api_client)body_phone = PureCloudPlatformClientV2.Phone()body_phone.name = "WebRTC_API_TEST_CR9"body_phone.site = PureCloudPlatformClientV2.Site()body_phone.site.id = "e6*****1-2**7-**61-9f**-3**********0" # valid site idbody_phone.phone_base_settings = PureCloudPlatformClientV2.PhoneBaseSettings()body_phone.phone_base_settings.id = "9######4-c8##-##d2-9##7-2##########5" #valid base_setting idfirst_line = PureCloudPlatformClientV2.Line()first_line.line_base_settings = PureCloudPlatformClientV2.DomainEntityRef()first_line.line_base_settings.id = "########-####-####-####-############" #ID of the line base settings corresponding to the type of phone phone you want to usebody_phone.lines = [first_line]body_phone.web_rtc_user = PureCloudPlatformClientV2.User()body_phone.web_rtc_user.id = "1######6-##51-4e##-#92#-2##########2" # id of a person without phone but with phone license (Cloud CX 3)api_response = api_instance.post_telephony_providers_edges_phones(body_phone)
This worked in my test org.
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 10-09-2025 10:46
From: Giampiero Casu
Subject: How do I create a new phone with Genesys Cloud API and Python?
Hi, I need to create a phone using the Genesys Cloud API and Python.
Using the Genesys Cloud web interface, I can create the phone simply by entering the following 4 parameters:
1 - Phone Name
2 - Base Settings
3 - Site
4 - Person
Unfortunately, when I try to use the API, using the post_telephony_providers_edges_phones method, it gives me an error saying it can't find the line.
Where can I find the line? How can I fix it? What should the API call body structure be?
This is my code:
api_client = PureCloudPlatformClientV2.api_client.ApiClient() \
.get_client_credentials_token(GENESYS_CLOUD_CLIENT_ID, GENESYS_CLOUD_CLIENT_SECRET)
api_instance = PureCloudPlatformClientV2.TelephonyProvidersEdgeApi(api_client)
body_phone = PureCloudPlatformClientV2.Phone()
body_phone.name = "WebRTC_API_TEST_CR9"
body_phone.site = PureCloudPlatformClientV2.Site()
body_phone.site.id = "e6*****1-2**7-**61-9f**-3**********0" # valid site id
body_phone.phone_base_settings = PureCloudPlatformClientV2.PhoneBaseSettings()
body_phone.phone_base_settings.id = "9######4-c8##-##d2-9##7-2##########5" #valid base_setting id
body_phone.web_rtc_user = PureCloudPlatformClientV2.User()
body_phone.web_rtc_user.id = "1######6-##51-4e##-#92#-2##########2" # id of a person without phone but with phone license (Cloud CX 3)
api_response = api_instance.post_telephony_providers_edges_phones(body_phone)
And this is the error the API returns.
HTTP response body: {"message":"A phone must contain at least one line.","code":"lines.required","status":400,"contextId":"e734a81d-7f1a-4310-b1e4-a519c8292034","details":[],"errors":[]}
I tried reading the tutorial, but it's only in JavaScript, not Python, and I can't figure out where I'm going wrong.
Thank you so much in advance if anyone is kind enough to help me resolve this issue.
Regards.
#PlatformAPI
------------------------------
Giampy
------------------------------