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
How do I use the API to assign phone number to an extension?
Tags: phone numbers
Nov 14, 2023 at 12:33pm   •   1 replies  •  0 likes
Jackson Khan

Hello,

I have multiple phone numbers in inventory. I want to be able to assign a phone number to an extension I created.


I tried this PATCH command, but it keeps saying the extensionID number is not found: https://developers.ringcentral.com/api-reference/Phone-Numbers/assignPhoneNumberV2


I even tried to do a get of the extension number I want to use, using this GET commad: https://developers.ringcentral.com/api-reference/Phone-Numbers/listExtensionPhoneNumbers


But it still can't find the extension number, it can only show me the results of all the extensions I have in my ringcentral account if I uses the tilde "~"


Is it possible to assign phone numbers to an user's extension? I want to be able to assign a phone number to an extension I created, and have that number be the primary fax and fax only number type.

1 Answer
answered on Nov 15, 2023 at 9:00am  

Where did you get the extension id and make sure that it's valid.

Show me the code how you call the PATCH method to assign a number.


 0
on Nov 15, 2023 at 11:20am   •  0 likes

Is the extension number itself the extensionID? For example, when I GET info for an account, this is the response:


{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 1,
  "startIndex": 1,
  "itemsPerPage": 100,
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User"
      ],
      "id": "63548308004",
      "meta": {
        "resourceType": "User",
        "created": "2023-11-15T19:17:30.342Z",
        "lastModified": "2023-11-15T19:17:30.342Z",
        "location": "https://platform.ringcentral.com/scim/v2/Users/63548308004"
      },
      "userName": "test.user15@wellthy.com",
      "name": {
        "formatted": "Test User15",
        "familyName": "User15",
        "givenName": "Test"
      },
      "active": true,
      "emails": [
        {
          "value": "test.user15@wellthy.com",
          "type": "work"
        }
      ],
      "phoneNumbers": [
        {
          "value": "326",
          "type": "other"
        }
      ]
    }
  ]
}

So is "326" the extenstion ID? Because when I try to do a get extension phone number list, it gives a 404 when I enter extensionID as 326:


curl --request GET \
  --url 'https://platform.ringcentral.com/restapi/v1.0/account/~/extension/326/phone-number?page=1&perPage=100'\


{
  "errorCode": "CMN-102",
  "message": "Resource for parameter [extensionId] is not found",
  "errors": [
    {
      "errorCode": "CMN-102",
      "message": "Resource for parameter [extensionId] is not found",
      "parameterName": "extensionId"
    }
  ],
  "parameterName": "extensionId"
}

I also want to make sure that I am not changing the company number for our entire account, just the direct number for the user using the extension.


EDIT: I found the issue, I needed to use the "id" not the extension number. I am able to add a phone line now!

The only other thing I have to figure out is if there is an API to make the phone number type fax only,


1700083373393.png


And also if there is an API that can make that primary number as the caller ID for fax number in user's profile

1700083475365.png

on Nov 15, 2023 at 3:42pm   •  0 likes

That is the thing. Extension id (an identifier) is different than extension number (a label).

Don't specify the type when assign a phone number. For some reason, it causes a error Bad request. I will report this to get it fixed.

on Nov 16, 2023 at 11:11am   •  0 likes

Great, thanks! But do you know if there is an API to do the other steps I wanted: make the phone number fax only and also make the primary number as the caller ID for fax number?

on Nov 16, 2023 at 12:24pm   •  0 likes

For changing the phone number type, it was intended to support via the "type" parameter in the update phone number API. But it seems that it would not work that way. So the team may need to provide a different API to do that.

For changing the Fax caller id, use this API instead. Here is the sample code in Node JS to read an extension phone numbers and assign the fax caller id.

async function read_extension_phonenumber(){
    var endpoint = "/restapi/v1.0/account/~/extension/~/phone-number"
    var params = {
      usageType: ["DirectNumber"]
    }
    var resp = await platform.get(endpoint, params)
    var jsonObj = await resp.json()
    for (var record of jsonObj.records){
        if (record.phoneNumber == '+1209683xxxx'){
          set_extension_fax_caller_id(record.id)
          break
        }
    }
}
async function set_extension_fax_caller_id(phoneId){
    var endpoint = "/restapi/v1.0/account/~/extension/~/caller-id"
    var bodyParams = {
      byFeature: [
        {
          feature: "FaxNumber",
          callerId: {
            type: "PhoneNumber",
            phoneInfo: {
              id: phoneId
            }
          }
        }
      ]
    }
    var resp = await platform.put(endpoint, bodyParams)
    var jsonObj = await resp.json()
    console.log(jsonObj)
}

I don't remember if the extension primary number can be set via API or not. But I will have search for it and update you later.

on Nov 17, 2023 at 12:39pm   •  0 likes

great, that worked! looking forward to the devs fixing the voicefax type issue.



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