I am looking at the extensions API and I see a businessPhone in the payload. It turns out that this is the best contact number and we do not give most users the ability to update this field. We need to be able to access the direct number assigned to them in RingCentral. Can that be found in an API? The extensions API does provide us with the additional information we need, but I do not see the direct phone number.
I think I have found the API endpoint I am looking for
https://developers.ringcentral.com/api-reference/Phone-Numbers/listExtensionPhoneNumbers
but this doesnt give me the result set I expect, even when I add the filter below, I still get multiple records back for just one extension ID. Any help anyone could provide would be greatly appreciated?
usageType=DirectNumber
Based on your own comment, you want to read direct number of all extensions under your account, right? If that is what you expected, use the account phone number endpoint.
var endpoint = `/restapi/v1.0/account/~/phone-number` var params = { usageType: [ "DirectNumber" ] }
Well no what I need comes from the extensions endpoint. Unfortunately, the phone number there, labeled businessPhone, is nothing but the best contact phone number, which is blank for most of our records. I thought it was the direct RingCentral number for that extension. Since that is not the case, I posted this question, but soon after found the endpoint reference page that I listed in my comment, which pulls phone numbers for a given extension id. I then added the uri parameter to limit the results to "DirectNumber", but I am still getting multiple phone numbers for a single extensionId?
Gotcha. Because you mentioned the DirectNumber so I misunderstood your need.
I think the `/phone-number` endpoint should support the BusinessMobileNumber as it's shown in the documentation. But some how the API does not return the number. I will check with the team to see what could be wrong with that.
Meanwhile, I guess that you want to read the Mobile phone specified in the user details, right? If so, the only way to read that number of all extensions is to call this API and parse the 'contact' object in the response to get the businesPhone number. This will shown the Mobile Phone of a user as display in the User Details
No I want the DirectNumber, but when I filter for directNumber for a specific extension, I get multiple records back.. I already have the businessPhone from the extension API call, but businessPhone is misleading. As you pointed out, its best contact number and for our account it is blank for most users, so businessPhone is a misleading name. I just need to get the RingCentral assigned main phone number for a given extension (we want to pull it for all extensions i.e. employees).From my research the that number should be the DirectNumber.
Well, it was not clear to me in your previous message. If you would split the businessPhone part in a separate paragraph as an extra info. And ask for the way to read user's direct numbers, then it would be easier for me to understand.
Anyway, this is your problem "No I want the DirectNumber, but when I filter for directNumber for a specific extension, I get multiple records back", right?
You may get multiple records back because a user can have multiple direct numbers. Here is what I read a user extension in my account:
async function read_user_phone_numbers(id){ console.log("===== read_user_phone_numbers ======") var endpoint = `/restapi/v1.0/account/~/extension/${id}/phone-number` try{ var params = { usageType: [ "DirectNumber" ] } const resp = await rcsdk.get(endpoint, params) var jsonObj = await resp.json() for (var record of jsonObj.records){ console.log(record.usageType) console.log(record.phoneNumber) console.log("=======") } }catch (e){ console.log(e.message) } } // response ===== read_user_phone_numbers ====== DirectNumber +1209284xxxx ======= DirectNumber +1209248xxxx ======= DirectNumber +1209294xxxx ======= DirectNumber +1888247xxxx =======
As you can see, this user has 4 direct numbers and all are read and listed.
Back to the businessNumber, I know the name is misleading but it just mean the user's own Mobile phone number as he added to his profile in the example screenshot I shared earlier.
Okay I understand, I will start trying to break this up into separate paragraphs. So I guess what I need to know is how can a user have more than one direct RingCentral number and what each one is for?
If I just look at my profile pop up in the RingCentral App, how can I focus in and get that direct number displayed on the right side?
Thanks,
James
Only Admin can see and add more direct number for a user. Here is the example view if you log in your account as a super admin.
I see that you check from the user profile from the RC app. That will show the main/primary direct number. If you open the dial pad and select the "Call from" dropdown, you will see more direct number if the user has multiple.
Thats what I don't understand. Everyone has several directNumbers under their extension ID when calling the Phone-numbers API Could something have happened during our setup back in 2020?
Do I need to check for a name withn the DirectNumber type that is equal to the name from the extension API call?
Nothing has changed in this. I check your account and this is yours. You can see other company numbers and main company number because those are account shared numbers to be used as a caller id. You should delete your screenshots as you expose your real company number in public.
I have deleted those screenshots. Thanks for the heads up.
So
is there a way to narrow down the results of the phone-number API call with usageType="directNumber" to just the directNumber for an Employee/extension without all the account shared directNumbers?
I really am just looking for a 1 to 1 call and return. So, just for example, I call the phone-number API against a specific user extension id, and then I get one record back containing that user's/extension id's specific directNumber. Just like the results you get back when you click on the download user list button in the admin interface.
Thanks,
James
Yes. That is what I showed you above with my code and the result.
var params = { usageType: [ "DirectNumber" ] }
If your result shows other numbers such as CompanyNumber, then I am sure that something is wrong with your filter. It must be an array of strings. Show me little of your code when you call the API so I can check.
Sure here is an example API call to phone-numbers.
x = a given extensionId
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/x/phone-number?usageType="DirectNumber"
See the difference?
usageType="DirectNumber" // vs. usageType: [ "DirectNumber" ]
I see the difference, but I don't understand. I built this based on the API reference guide for phone-numbers.
Is usageType: ["DirectNumber"] still passed as a URI parameter?
If so, could you provide the complete url as an example?
Hi,
I found a key called primary in the payload for phone-number. It looks like that will allow me to narrow down to the user's specific direct number.
Can you confirm if this is the case?
Thanks,
James
That might not be the direct number, but a digital line. It depends on the extension setting for its primary number.
Here is an obfuscated screenshot of my payload when putting in my extension id to the phone-number API with usageType=DirectNumber
I have the primary key highlighted.
Can you elaborate your answer? Hopefully a visual of what I am seeing will help clarify my question if I worded it poorly.
Thanks,
James
Can you give me the extension id? I can see that this is a site, not a user extension.
Is it secure to pass the extension ID through this chat?
Yes, just an extension id is safe.
Okay thanks for clarifying. Here is the extension ID for the example screenshot sent earlier.
2238768015
This is not the one you read the number above.
I'm afraid I don't understand. That is the extension ID that I used to make a call to phone-numbers endpoint with the URL parameter... UsageType=DirectNumber
Would it be possible to setup a call? This really needs to be resolved as soon as possible.
Thanks,
James
All in all, this is how a number is listed as a direct number
A digital line (one with a phone under the Phones tab)
A direct number (under the Numbers tab)
A call queue number, which the user is a member of
The user primary number is the number the user chose in the setting and it can be one of the numbers discussed above
Okay, and thats my ultimate question. How do I get that primary number for all employees(extensions) through your APIs?
I don't see any filter to read only user's primary number. So the only way is to read user direct number(s) then iterate thru the records array to pick the number which has the primary = true.
Unfortunately, the Get company numbers API does not return the "primary" flag so it cannot be used in your use case.
Okay thats what I figured, but it gets me what I need. Thanks for verifying that for me.
Unfortunately, I am running into a 429 "too many requests" error because I have to call the phone-numbers end point once for each employee. The endpoint we have been looking at isin the light usage group, but that still only gets 50 calls per minute. We have over 1000 employees.
I tried calling this endpoint instead
https://platform.ringcentral.com/restapi/v1.0/account/~/phone-number
but I get the same 429 message because there are about 26 pages to return all records from that endpoint. Do you know a way around this limit issue?
Thanks,
James
Yes, throttling limit for this API is 50 calls per minute. You will need to control the API calls following the limit. Read the info once in a while and store the info in your database to reuse.
Just in case, you can use one of the techniques I explained here to control your API calls
https://medium.com/ringcentral-developers/ringcentral-api-rate-limit-explained-2280fe53cb16
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder