News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Is there an API endpoint that contains Direct Number for an extension from RingCentral?
Tags: rest api
Mar 30, 2022 at 12:23pm   •   2 replies  •  0 likes
James Smith

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.

on Mar 30, 2022 at 2:45pm   •  0 likes

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
1 Answer
answered on Mar 30, 2022 at 4:04pm  

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" ]
        }

 0
on Mar 31, 2022 at 6:20am   •  0 likes

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?

on Mar 31, 2022 at 11:36am   •  0 likes

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

1648751793130.png

on Mar 31, 2022 at 12:00pm   •  0 likes

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.

on Mar 31, 2022 at 12:20pm   •  0 likes

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.

on Mar 31, 2022 at 12:34pm   •  0 likes

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

on Mar 31, 2022 at 1:54pm   •  0 likes

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.

1648760048389.png

on Mar 31, 2022 at 1:58pm   •  0 likes

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.

1648760314809.png

on Mar 31, 2022 at 2:21pm   •  0 likes

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?

on Mar 31, 2022 at 3:01pm   •  0 likes

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.

1648764076101.png

on Mar 31, 2022 at 4:13pm   •  0 likes

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

on Apr 1, 2022 at 7:24am   •  0 likes

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.

on Apr 1, 2022 at 8:54am   •  0 likes

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"

on Apr 1, 2022 at 9:44am   •  0 likes

See the difference?

usageType="DirectNumber" 
// vs.
usageType: [ "DirectNumber" ]

1648831590068.png

on Apr 1, 2022 at 12:05pm   •  0 likes

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?

on Apr 4, 2022 at 7:33am   •  0 likes

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

on Apr 4, 2022 at 7:38am   •  0 likes

That might not be the direct number, but a digital line. It depends on the extension setting for its primary number.

on Apr 4, 2022 at 8:49am   •  0 likes

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.

1649087197167.png


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

on Apr 4, 2022 at 9:20am   •  0 likes

Can you give me the extension id? I can see that this is a site, not a user extension.

on Apr 4, 2022 at 9:28am   •  0 likes

Is it secure to pass the extension ID through this chat?

on Apr 4, 2022 at 9:29am   •  0 likes

Yes, just an extension id is safe.

on Apr 4, 2022 at 9:31am   •  0 likes

Okay thanks for clarifying. Here is the extension ID for the example screenshot sent earlier.

2238768015

on Apr 4, 2022 at 9:34am   •  0 likes

This is not the one you read the number above.

on Apr 4, 2022 at 9:42am   •  0 likes

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

on Apr 4, 2022 at 9:47am   •  0 likes

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

1649090758375.png

The user primary number is the number the user chose in the setting and it can be one of the numbers discussed above

1649090817055.png

on Apr 4, 2022 at 9:59am   •  0 likes

Okay, and thats my ultimate question. How do I get that primary number for all employees(extensions) through your APIs?

1649091520639.png

on Apr 4, 2022 at 10:57am   •  0 likes

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.

on Apr 4, 2022 at 11:22am   •  0 likes

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

on Apr 4, 2022 at 11:40am   •  0 likes

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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us