Reputation: 16354
How can a number be appended to an existing RingCentral Ring Group using the REST API? I can't seem to find a way to add a number to a call forwarding RingGroup. I can add it as another forwarding rule, but what I would really like to do is append it to an existing RingGroup.
In the Online Account Portal (https://service.ringcentral.com), creating a Ring Group works by selecting two or more forwarding numbers and clicking "Create Ring Group" as shown below.
A Ring Group looks like the following:
Upvotes: 2
Views: 375
Reputation: 16354
In the RingCentral API, a Ring Group is simply an array of more than one forwarding number in the answering rule of interest. Each answering rule has a forwarding
property with an array of forwarding.rules
where each rule has an array of forwardingNumbers
. The rules are ordered by the 1-based index
property. A rule with more than one forwardingNumbers
is a Ring Group.
To add a number, retrieve the current forwarding numbers from the rule of interest and add the forwarding number id of the phone number you want to add to the answering rule.
You can retrieve a list of your answering rules from the extension/answering-rule
endpoint. The default answering rule ids are below and you can also have custom answering rules.
business-hours-rule
: account/~/extension/~/answering-rule/business-hours-rule
after-hours-rule
: account/~/extension/~/answering-rule/after-hours-rule
These are both in the Answering Rules List endpoint:
To add an number to a Ring Group, first register it as a forwarding number and then add the forwarding number id to the Ring Group. These are described in the steps below.
1. Creating a Forwarding Number
If you don't already have a RingCentral forwarding number for the phone number you want to add, call the POST extension/forwarding-number
API to create a new forwarding number.
POST /restapi/v1.0/account/11111111/extension/22222222/forwarding-number
{
"phoneNumber" : "+12125550100",
"label" : "Work"
}
2. Updating an Answering Rule
The easiest way to add a forwarding number to an existing Ring Group is to call the answering rules endpoint for the rule you wish to update a Ring Group for and then update the rule using the data in the forwarding
property with the addition of the new forwarding number id. Identify the Ring Group of interest using the forwarding.rules
array, create an array of existing and new forwardingNumberIds, and then send that as the body of the update request as shown below.
2.1. Getting the Existing Answering Rule
Get the ruleId
you are interested in and then call the following endpoint to get the existing setting:
/restapi/v1.0/account/{accountId}/extension/{extensionId}/answering-rule/{ruleId}
You will get a JSON object with a number of properties. To update the Ring Group we just need to call the rule endpoint using the PUT
method with the updated forwarding
property.
# Get Answering Rule Response
GET /restapi/v1.0/account/11111111/extension/22222222/answering-rule/business-hours-rule
<snip>
"forwarding": {
"notifyMySoftPhones": true,
"notifyAdminSoftPhones": false,
"softPhonesRingCount": 5,
"ringingMode": "Sequentially",
"rules": [
{
"index": 1,
"ringCount": 3,
"forwardingNumbers": [
{
"uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/forwarding-number/33333333",
"id": "33333333",
"phoneNumber": "+16505550100",
"label": "My Phone3"
}
]
}
]
},
2.2 Updating the Answering Rule
The following is an example of adding the phone number as forwarding rule id 44444444
. You can also update other properties. Additional forwarding properties that can be updated include the following from the response above: notifyMySoftPhones
, notifyAdminSoftPhones
, softPhonesRingCount
, and ringingMode
.
In the example below, ~
is used for accountId
and extensionId
. Here, ~
indicates the current authorizing user, also the user associated with the access token.
# Update Answering Rule Request
PUT /restapi/v1.0/account/~/extension/~/answering-rule/business-hours-rule
{
"forwarding": {
"rules": [
{
"index": 1,
"ringCount": 3,
"forwardingNumbers": [
{
"id": "33333333"
},
{
"id": "44444444"
}
]
}
]
}
}
After this, retrieving the answering rule API endpoint will show an array of forwarding numbers and the Online Account Portal will show a Ring Group. The Online Account Portal is available at:
Upvotes: 2