question

James Peragine avatar image
James Peragine asked Phong Vu commented

Admin API Account

How can I setup an Admin account that can access records for all agents in an API call?

I want to get ALL records for from ALL agents for a phone number. ie. if I want to return all SMS messages that were sent to a phone number company wide.

Right now I have to provide credentials for a specific agent and it will only return Calls or SMS message that were sent from that one agent.

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

Login your app with an Admin user (user extension with the Super Admin role. E.g. the default 101 extension). Read account extension and parse the response to make a list of extension ids (Note: extension id, NOT extension number!). Then read the message store of each extension by specifying the extension id for that extension in the query path. If you have an account with a large number of extensions (> 50 extensions) , do take care of the API rate limit. Here is a snippet code in Node JS, showing how to extensions and read the message store of other extension.

var extensionList = []
function get_extensions() {
  platform.get('/restapi/v1.0/account/~/extension')
      .then(function(resp){
          var jsonObj = resp.json
          for (var record of jsonObj.records){
              extensionList.push(record.id)
          }
          readExtensionMessageStore()
      })
      .catch(function(resp){
          console.log("Something went wrong.")
      })
}

function readExtensionMessageStore(){
  async.each(extensionList,
    function(extensionId, callback){
        var endpoint = '/account/~/extension/'+ extensionId +'/message-store
        platform.get(endpoint, {
                   dateFrom: '2018-01-01T00:00:00.000Z',
                   dateTo: '2018-07-31T23:59:59.999Z',
                   phoneNumber: "1223343434"
                   messageType: 'SMS'
          })
          .then(function (resp) {
            var jsonObj = resp.json()
            console.log(extensionId)
            console.log("=========== EXTENSION MESSAGE STORE ===========")
            console.log(JSON.stringify(jsonObj))
            console.log("+++++++++++++++++++++++++++++++++++++")
          })
          .catch(function(ex){
            console.log(ex.message)
          })
    }
  )
}


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

James Peragine avatar image
James Peragine answered Phong Vu commented

Nice I will work on getting this implemented this evening.


Can the same thing be accomplished using the API with a CURL command and putting the Super Admins login details in the header?

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Surely it will work with CURL.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys