How to associate a user to its phone via API call

Hello There,
I am building an automate process on another platform (Okta) that when a user leaves the company, the process will issue API calls to delete this user's soft phone and then his/her Genesys user account. I can find user ID by searching user based on email, but how do I link a user ID to his/her phone to retrieve phone id in order to delete the phone via API call? I don't see there is any direct link btw user object and phone object.
Anybody had similar situation and could provide some guidance?
thank you in advance!

Hi,

You can get a user's phone number with their user ID using this api: https://developer.genesys.cloud/devapps/api-explorer#get-api-v2-users--userId-

@Zino_Onokpise ,
thanks for infor. Which field is for phone number or ID from your screen shot? is that phone number unique to the user?

Yes, that screenshot is a schema from a 200 response on that api link sent earlier, you can access schema on api responses by clicking the api responses drop down on each api tile

but I don't see any field on user object can reference phone object, or vice versa...
in other word, i cannot retrieve associated phone object based on the user object, can I?

This is something you'll have to manage outside of Genesys Cloud as this is not a concept in the platform. A user can use any station they're permitted to by using PUT /api/v2/users/{userId}/station/associatedstation/{stationId}. A user only "has a phone" when they're actively using it.

If you want to create the concept of a 1:1 relationship between a user and a phone, you need to come up with a way to create that linkage outside of Genesys Cloud. That could be something as simple as a naming convention or could be somewhere that you maintain a list of userID/stationID pairs for a direct lookup.

Note that a user can have a default station (User > station.defaultStation), but that is not required and can be updated after the user is created. That creates the potential that deleting a user and their set default station could delete a station that is not the same phone they were configured with when they were created.

1 Like

@tim.smith ,
thanks for explanation. The termination document I got from the user who performs manual steps now is to delete user's soft phone and user account when user leaves company. I am not familiar with Genesys at all, but from data pulled on user, station, lines, phone objects, i found below linkage which I am not sure if I am on right path:

  1. retrieve userid: user search based on user email, one API call;
  2. retrieve station id based on user.userid = station.webRtcUserId:
  3. retrieve phone id based on phone.lines.id = station.id
  4. delete phone first via API: /api/v2/telephony/providers/edges/phones/{id}
  5. then delete user via API: /api/v2/users/{id}

Does above look right?

thank you so much!