Perl api example


I am looking for an example of using the perl api to get a list one phone numbers in duo and deleting phone numbers from duo. If you use the web admin console to delete a user it deletes the phone device if no one else is using it also. The api to delete a user does not. As a result, I have 600+ orphaned phones that need to be deleted. The web pages that describe the apis seem to be remarkably absent of any examples of how to actually use them.

The following is an example perl program to delete a phone that doesn’t quite work. It always returns a “40401 Resource not found” error.

use Net::Duo;
use Data::Dumper;
use Net::Duo::Admin;
use Net::Duo::Admin::User;
use Net::Duo::Admin::Phone;
my ($cmd,$arg)=@ARGV;
my %keys;
my $duo= Net::Duo->new(%keys);
my $u="[$arg]";
my $result=$duo->call_json(‘DELETE’,"/admin/v1/phones/$u");
print Dumper($result),"\n";

The code generating the $duo object works for accessing user data, but not phone data. Does anyone have any suggestions for actually getting this to work?

Thanks in advance.


Hi @bidwell,

We have API demonstration clients for different languages in GitHub. These are linked directly from the Admin API documentation. Here’s the one for Perl.

Hope that helps!