SMS & PHP - Working Sandbox app code not working with graduated app

  • 14 August 2023
  • 3 replies

Hello All,

New to RingCentral development, but I created an app with an SMS endpoint (send SMS only) and built some code to get it working in the sandbox. Code works perfectly using the Sandbox credentials/client/server info. The app was then graduated, so I updated the following to the graduated app's credentials/info:

$client_id = 'production_appclientid'; //Removed for security
$client_secret = 'production_appclientsecret'; //Removed for security
$server_url = '';
$rc_jwt = 'production_jwt_key'; //Removed for security

Having changed only the above 4 lines of code, the app is now failing at the highlighted line below:

function send_sms($fromNumber){
  global $platform, $RECIPIENT;
  try {
    $requestBody = array(
       'from' => array ('phoneNumber' => $fromNumber),
       'to' => array( array('phoneNumber' => $RECIPIENT) 
       'text' => 'test'
    $endpoint = "/account/~/extension/~/sms";
    $resp = $platform->post($endpoint, $requestBody);
    $jsonObj = $resp->json();
    print("SMS sent. Message id: " . $jsonObj->id . PHP_EOL);
  } catch (RingCentralSDKHttpApiException $e) {
    exit("Error message: " . $e->message . PHP_EOL);

I still have the Sandbox Environment active, do I need to suspend that? The Production Environment Status is "Active", and I'm able to see the requests I'm submitting are generating errors via the analytics panel.

When I view the Production End Points analytics, I see the errors are all to the endpoint "1/account/*/extension/*/sms". Every request to that endpoint in the Production Environment results in an error 403 or 400. Do I need to enable another endpoint for my app?

Any help/suggestions appreciated.

3 replies

Did you also call this function to detect the user's phone numbers and if the "from" phone number is SMS enabled?

  Read phone number(s) that belongs to the authenticated user and detect if a phone number
  has the SMS capability
function read_extension_phone_number_detect_sms_feature(){
  global $platform;
  $endpoint = "/restapi/v1.0/account/~/extension/~/phone-number";
  $resp = $platform->get($endpoint);
  $jsonObj = $resp->json();
  foreach ($resp->json()->records as $record){
    foreach ($record->features as $feature){
      if ($feature == "SmsSender"){
        // If a user has multiple phone numbers, check and decide which number
        // to be used for sending SMS message.
        return send_sms($record->phoneNumber);
  if (count($jsonObj->records) == 0){
    exit("This user does not own a phone number!");
    exit("None of this user's phone number(s) has the SMS capability!");

Your user extension does not need to have a license and phone. But it does need a phone number. You can purchase a phone number and assign to the user as a direct number then that user can send text message from his own number.

Thank you. I appreciate all your help.