cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3977
Views
0
Helpful
3
Replies

Create user using admin api

Brian_Fleishman
Level 1
Level 1

I currently have duo 2fa integrated with our custom webapp. I would like to now be able to create a user on our account using the admin api. But I cannot find any documentation that has an example of how to do so.

I can see from the documentation that it’s a post command, but it has no specifics. Can anyone give me an example of that or point me in the right direction?

Thanks you.
-Brian

3 Replies 3

DuoKristina
Cisco Employee
Cisco Employee

Hello Brian_Fleishman!

The best reference is our Admin API documentation. The API Details section should help you figure it out. Additionally, you may find it useful to look at our API demo clients out on our GitHub, like our Python demo client.

Duo, not DUO.

Brian_Fleishman
Level 1
Level 1

I’ve poured through that documentation, but it doesn’t give any examples of an http post. And unfortunately I’m not that familiar with any of the languages that are in the documentation, except for Java.

Do you know of any place where I can see a working example of an http post to create or delete a user? Thanks.

Todd_Haddaway
Level 1
Level 1

Hi Brian,
I was in the same boat just hours ago. I was having issues trying to figure out how to just retrieve a user’s information via the admin API. I’m doing it in PHP, but I’m sure the translation to java would be, hopefully, straight forward:

  1. See Duo Admin API | Duo Security for docs
  2. Download source files at https://github.com/duosecurity
  3. Files of interest will be in the folder duo_api_php/src
  4. Retrieve the integration key, secret key and api URL by logging into the Duo console (www.duo.com) and navigating to Applications and clicking on the Admin API user that you have set up in “first steps” of Duo Admin API | Duo Security

I created a sample php script that pulled the information for one user (see below). To create a user you would call the “create_user” method that is contained in the Admin.php file. You can see in that function/method its doing a POST. Parameters are found here: Duo Admin API | Duo Security

Sample source code for calling the “users” method of the “Admin” class

<?php
namespace DuoAPI;
 
include 'Requester.php';
include 'CurlRequester.php';
include 'Client.php';
include 'Admin.php';
 
$D = new Admin("integration key here","secret key here","api-stuffhere.duosecurity.com");
# just a particular user     
#  $users = $D->users("smith");

# all users
  $users = $D->users();

  // Loop through Array
  foreach ($users["response"]["response"] as $key => $value) {
print $value["username"] .  "  " . $value["email"] .  "  " . $value["realname"] . "\n";
  }
 
 ?>
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links