I am trying to get outbound sms logs against each individual phone number configured in twilio sub-account. I am using PHP programming language and looked into the api console: https://www.twilio.com/docs/api/rest/usage-records
But according to my exploration, usage-record api only returns total usage information against my twilio account. i.e. 500 outbound sms against all the three subscribed numbers in my account say N1, N2 and N3. What I want here is to retrieve the number of sms sent and received individually against each number N1, N2 and N3. Please help me in this regard.
Thanks
I have already did like this.
$sub_acc = $client->accounts->get($sub_account->sid);
$numbers = $sub_acc->incoming_phone_numbers;
$phone_sms_count = array();
foreach ($numbers as $number) {
$sms_count = 0;
foreach ($sub_acc->messages->getIterator(0, 50, array(
"From" => $number->phone_number,
"DateSent" => $last_six_months_date)) as $sms)
{
$sms_count++;
}
$phone_sms_count[$number->phone_number] = $sms_count;
}
But it takes too much time to calculate sms counts for each number. I have configured 5 numbers in single subaccount and I have 10 subaccounts this will break the limits. Is there any way to get sms counts for each phone number without iterating messages?