Making Calls Using RingOut
The RingOut option enables the users to make a call from any other outside number (not RingCentral number) by means of the RingCentral account, when it is not convenient for them to use the RingCentral number. This feature is available for softphone, web service and mobile applications.
The user specifies a certain number under the forwarding number list, starts RingOut and enters the required called number. RingCentral makes a call to the specified forwarding number and connects the user with the called number.
The API treats a two-legged RingOut call as a resource that can be created, retrieved, or deleted via the POST
, GET
and DELETE
methods correspondingly.
Sample Code to Get Started with RingOut
The two-legged RingOut call can be created via the following request:
POST /restapi/v1.0/account/~/extension/~/ring-out
Content-Type: application/json
Authorization: Bearer <access-token>
{
"from": {"phoneNumber": "13445554444"}, /* from parameter is optional if there is a default number in user's forwarding numbers */
"to": {"phoneNumber": "13455553434"}, /* to parameter is required */
"playPrompt": true /* optional field */
}
const RC = require('@ringcentral/sdk').SDK
require('dotenv').config();
const CALLER = process.env.RINGOUT_CALLER
const RECIPIENT = process.env.RINGOUT_RECIPIENT
var rcsdk = new RC({
'server': process.env.RC_SERVER_URL,
'clientId': process.env.RC_CLIENT_ID,
'clientSecret': process.env.RC_CLIENT_SECRET
});
var platform = rcsdk.platform();
platform.login({ 'jwt': process.env.RC_JWT })
platform.on(platform.events.loginSuccess, () => {
call_ringout()
})
async function call_ringout() {
try {
var resp = await platform.post('/restapi/v1.0/account/~/extension/~/ring-out', {
'from': { 'phoneNumber': CALLER },
'to': { 'phoneNumber': RECIPIENT },
'playPrompt': false
})
var jsonObj = await resp.json()
console.log("Call placed. Call status: " + jsonObj.status.callStatus)
} catch (e) {
console.log(e.message)
}
}
#!/usr/bin/python
# You get the environment parameters from your
# application dashbord in your developer account
# https://developers.ringcentral.com
import os
import sys
from dotenv import load_dotenv
from ringcentral import SDK
load_dotenv()
CALLER = os.environ.get('RINGOUT_CALLER')
RECIPIENT = os.environ.get('RINGOUT_RECIPIENT')
rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),
os.environ.get('RC_CLIENT_SECRET'),
os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()
try:
platform.login( jwt=os.environ.get('RC_JWT') )
except Exception as e:
sys.exit("Unable to authenticate to platform: " + str(e))
resp = platform.post('/restapi/v1.0/account/~/extension/~/ring-out',
{
'from' : { 'phoneNumber': CALLER },
'to' : { 'phoneNumber': RECIPIENT },
'playPrompt' : False
})
print(f'Call placed. Call status: {resp.json().status.callStatus}')
<?php
/* You get the environment parameters from your
application dashbord in your developer account
https://developers.ringcentral.com */
require('vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();
$CALLER = $_ENV['RINGOUT_CALLER'];
$RECIPIENT = $_ENV['RINGOUT_RECIPIENT'];
$rcsdk = new RingCentral\SDK\SDK( $_ENV['RC_CLIENT_ID'],
$_ENV['RC_CLIENT_SECRET'],
$_ENV['RC_SERVER_URL'] );
$platform = $rcsdk->platform();
$platform->login( [ "jwt" => $_ENV['RC_JWT'] ] );
$resp = $platform->post('/account/~/extension/~/ring-out',
array(
'from' => array('phoneNumber' => $CALLER ),
'to' => array('phoneNumber' => $RECIPIENT),
'playPrompt' => false
));
print_r ("Call placed. Call status: " . $resp->json()->status->callStatus);
?>
using System;
using System.Threading.Tasks;
using RingCentral;
namespace Call_Ringout
{
class Program
{
static RestClient restClient;
static void Main(string[] args)
{
restClient = new RestClient(
Environment.GetEnvironmentVariable("RC_CLIENT_ID"),
Environment.GetEnvironmentVariable("RC_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RC_SERVER_URL"));
restClient.Authorize(
Environment.GetEnvironmentVariable("RC_JWT")).Wait();
call_ringout().Wait();
}
static private async Task call_ringout()
{
var parameters = new MakeRingOutRequest();
parameters.from = new MakeRingOutCallerInfoRequestFrom {
phoneNumber = Environment.GetEnvironmentVariable("RINGOUT_CALLER")
};
parameters.to = new MakeRingOutCallerInfoRequestTo {
phoneNumber = Environment.GetEnvironmentVariable("RINGOUT_RECIPIENT")
};
parameters.playPrompt = false;
var resp = await restClient.Restapi().Account().Extension().RingOut().Post(parameters);
Console.WriteLine("Call Placed. Call status" + resp.status.callStatus);
}
}
}
import com.ringcentral.*;
import com.ringcentral.definitions.*;
import java.io.IOException;
public class RingoutQuickStart {
static String RINGOUT_CALLER = System.getenv("RINGOUT_CALLER");
static String RINGOUT_RECIPIENT = System.getenv("RINGOUT_RECIPIENT");
static RestClient rc;
public static void main(String[] args) {
var obj = new RingoutQuickStart();
rc = new RestClient( System.getenv("RC_CLIENT_ID"),
System.getenv("RC_CLIENT_SECRET"),
System.getenv("RC_SERVER_URL") );
try {
rc.authorize(System.getenv("RC_JWT"));
obj.call_ringout();
} catch (RestException | IOException e) {
e.printStackTrace();
}
}
public void call_ringout() throws RestException, IOException {
MakeRingOutRequest requestBody = new MakeRingOutRequest();
requestBody.from(new MakeRingOutCallerInfoRequestFrom().phoneNumber(
RINGOUT_CALLER ));
requestBody.to(new MakeRingOutCallerInfoRequestTo().phoneNumber(
RINGOUT_RECIPIENT));
requestBody.playPrompt = false;
var response = rc.restapi().account().extension().ringOut().post(requestBody);
System.out.println("Call Placed. Call status: " + response.status.callStatus);
}
}
#!usr/bin/ruby
# You get the environment parameters from your
# application dashbord in your developer account
# https://developers.ringcentral.com
require 'ringcentral'
require 'dotenv/load'
CALLER = ENV['RINGOUT_CALLER']
RECIPIENT = ENV['RINGOUT_RECIPIENT']
$rc = RingCentral.new(ENV['RC_CLIENT_ID'],
ENV['RC_CLIENRT_SECRET'],
ENV['RC_SERVER_URL'])
$rc.authorize(jwt: ENV['RC_JWT'])
resp = $rc.post('/restapi/v1.0/account/~/extension/~/ring-out', payload: {
from: { phoneNumber: CALLER },
to: { phoneNumber: RECIPIENT },
playPrompt: false
})
puts "Call placed. Call status: " + resp.body['status']['callStatus']
Request parameters
Parameter | Description |
---|---|
from |
Refers to the number of the calling party. Required field only if there is no default number in the user's forwarding number list. The phoneNumber attribute should comply with the E.164 standard. As a result of validation of the phoneNumber attribute the server may return the error code: 400 Bad Request - phoneNumber specified in the field is empty or invalid. |
to |
Refers to the called party number. Required field. If this field is missing from the request, the 400 Bad Request error is returned. The phoneNumber attribute should comply with the E.164 standard. As a result of validation of the phoneNumber attribute the server may return the error code: 400 Bad Request - phoneNumber specified in the field is empty or invalid. |
playPrompt |
The audio prompt that the calling party hears when the call is connected. Optional field. It corresponds to the setting in the RingCentral application "Prompt me to dial 1 before connecting" (When selected, the system will ask you to press "1" on your phone's key pad before connecting to the destination number). |
Example response
The response can be as follows:
{
"id": 234343434,
"uri": "/restapi/v1.0/account/~/extension/~/ringout/234343434",
"status": {
"callStatus": "Success",
"callerStatus": "Success",
"calleeStatus": "Success"
}
}
Response parameters
callStatus
Value | Description |
---|---|
InProgress |
Connection is being established |
Success |
Both legs connected (Answered) |
CannotReach |
Failure state (one or both legs are in invalid state for call connection) |
NoAnsweringMachine |
Internal server failure |
callerStatus and calleeStatus
Value | Description |
---|---|
InProgress |
Connection to the target leg is being established |
Busy |
Target device is busy |
NoAnswer |
The call has been dropped because of timeout |
Rejected |
|
Success |
Call party has answered the call |
Finished |
The call was terminated (In Progress > Success > Finished) |
GenericError |
|
InternationalDisabled |
|
NoSessionFound |
RingOut status was requested for RingOut session which does not exist (e.g was already Closed) |
Invalid |
RingOut session state is unknown due to internal failure |
Call status is generated as a combination of both call legs statuses (caller and callee):
Caller or Callee statuses are separately generated for the target call party:
RingOut Flow
See how the statuses are changing during successful call on the flowchart below:
Failed call:
How to check on the status of a RingOut call in progress
You can poll the RingOut endpoint to get the status of an ongoing outbound RingOut call.
GET /restapi/v1.0/account/~/extension/~/ring-out/234343434
The response will be similar to the following:
{
"id": 234343434,
"uri": "/restapi/v1.0/account/~/extension/~/ringout/234343434",
"status": {
"callStatus": "Success",
"callerStatus": "Success",
"calleeStatus": "Success"
}
}
How to cancel a RingOut in progress
RingCentral does not currently support call control for outbound calls. However, you can cancel a RingOut call while the callee's party status is InProgress
by making a DELETE
request to the RingOut endpoint as shown below:
DELETE /restapi/v1.0/account/~/extension/~/ring-out/234343434
If successful, the platform will respond with a 204.
Deleting the RingOut is only available when the RingOut has been initiated and the call has not yet been connected. For example, if you initiate a RingOut and immediately call the DELETE RingOut endpoint, the call would get terminated as long as the RingOut between the two parties is not connected (first leg has not been established). If the first leg of the call has been initiated, then the DELETE API will not terminate the call.
Setting the caller ID for RingOut calls
RingCentral allows users to select which number to use for their caller ID name (CNAM
) value when making calls. However, this can only be done through the RingCentral administrative console, and cannot be set at runtime or programmatically. To set the CallerId for the RingOut API, set the "RingOut from Web" value as available in the Online Account Portal. More information on this can be found in KB Article #3471.