Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Can I create a new user using Rest Api calls?

restapi
users
api

#1

Hello,

I’m trying to find a way to create users that’s more efficient than going to each account and creating one through the GUI. I checked the API explorer and it gave me access to get a list of users, find a particular user and reset the password but nothing on creating the new user.

Is there a way to create a new user with REST Api? If so, could somebody point me toward some documentation on the same.

Your help is much appreciated!!

Thanks.

Regards,
Karan


#2

Hi @karanpreet.singh - Unfortunately this API functionality is only available to New Relic partners.

I have already asked that this be opened up to Admin API key access.


#3

Hi, @karanpreet.singh: I frequently need to add large numbers of users to our training accounts, so I wrote the following Selenium script. To run it, you will need to install:

To run the script, open a Terminal window and execute $ node /path/to/script.js.

Please note that this script was written by me, as an individual developer, for my personal use. It is not developed or supported by New Relic. It is provided as-is, without warranty or tech support. Use at your own risk.

var accountId = 'YOUR_ACCOUNT_ID';
var email = 'YOUR_LOGIN_EMAIL';
var password = 'YOUR_PASSWORD';

// Input file containing list of emails to add
var inputFile = 'emails.txt';
// Use 'a' to add users as Admin, 'u' to add as User, 'r' as Restricted User
var userLevel = 'u';

var LineReader = require('line-reader-sync');
var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().forBrowser('chrome').build();

// Login to RPM
newRelicLogin(driver, email, password);
// Navigate to account settings page
driver.get('https://rpm.newrelic.com/accounts/' + accountId);

// Open inputFile
var reader = new LineReader(inputFile);

do {
    // Call addUser for each line of file
    var line = reader.readline();
    if (line != null) {
        addUser(line);
    }
} while (line != null);

driver.quit();

function newRelicLogin(driver, email, password) {
    driver.get('https://login.newrelic.com/login')
        .then(function() {
            // User name
            return driver.findElement(webdriver.By.id('login_email')).sendKeys(email);
        })
        .then(function() {
            // Password
            return driver.findElement(webdriver.By.id('login_password')).sendKeys(password);
        })
        .then(function() {
            // Click Submit
            return driver.findElement(webdriver.By.id('login_submit')).click();
        });
}

function addUser(email) {
    // Wait until 'Add user' link is available
    driver.wait(function() { 
            return driver.isElementPresent(webdriver.By.css('a.icon.add')); 
        }).then(
            function() {
                // Display New User form
                return driver.executeScript('RPM.toggleNewUserForm();').then(
                    function() {
                        // Wait for form to display
                        return driver.sleep(1000);
                    }).then(
                        function() {
                            // Add user
                            return driver.findElement(webdriver.By.id('account_view_user_email')).sendKeys(email).then(
                                function() {
                                    return driver.findElement(webdriver.By.id('account_view_level')).sendKeys(userLevel).then(
                                        function () {
                                            return driver.findElement(webdriver.By.id('Account view_submit')).click();
                                        }
                                    );
                                }
                            ).then(
                                function() {
                                    // Wait for page to reload
                                    return driver.sleep(1000);
                                }
                            );
                        }
                    );
            }  
        );
}

Feature Idea: Automatically assign an Add-On role to new users?
#4

It would be good for Admin keys to be able to access the user API which is available to New Relic partners.


#5

Thanks for the script Phil.

Although I was hoping that something like this would be available through the API, at least to admins as it’s a fairly common task and becomes cumbersome if it needs to be done for multiple accounts and multiple users.

Your script does give me an idea to create something similar, perhaps without a dependency on selenium.

Regards,
Karan


#6

Hi, @stefan_garnham: Sure, I agree. In the meantime, however, I need a way to add large numbers of users for training and workshops; I can’t wait until the API team gets around to adding this capability, so I found a workaround.

This doesn’t mean I don’t think we should offer this capability as an API, it just means I live in the real world and have to get my work done. :wink:


#7

@karanpreet.singh, have you thought of using Single Sign On to handle users:
https://blog.newrelic.com/2013/01/09/new-relic-sso-integration-a-new-enterprise-feature-for-you/

Was about a 10 minute task last time I set this up with Azure. Assuming you’ve got an Active Directory source of users, something like ADFS is pretty easy to configure as well. Not done ADFS/NR but ADFS integration into other SaaS providers has been pretty easy.

Regards

Paul


Oct. 14, 2016 Post of the Week—Alerts, Synthetics and Insights!
#8

Excellent share @pault!

@karanpreet.singh Let us know if this answers your questions. Note: SSO integration is available for our Pro Subscription customers.


#9

Unfortunately NewRelic SSO doesn’t have a “just in time” provisioning function and accounts still need to be manually added to the GUI before SSO users can login :confused:
IMO These administration API’s should be shared with customers as they provide basic functionality that are needed to automate administration.


#10

Hey @Grant.delaRosa! I definitely hear you—this is great feedback. Passing your point about sharing with customers along to our Product Management team. :thumbsup:


#11

Hi, has there been any movement on this? Is this feature on the roadmap?

Here is the scenario - we are using SAML for authentication whereby authentication is via Azure AD, great, awesome!! All I simply need to do is add user accounts to the relevant AD group and presto - users can get access.

But only half the job has been completed at this stage. I still need to manually add the 100 users to New Relic :frowning: :frowning: :frowning: :frowning:

C’mon folks, this has been outstanding for 18 months. Rather than providing the API please implement just in time provisioning using SCIM so as the customer only needs to add users to an AD group and with the magic of SCIM the user account will be auto provisioned in New Relic when the user logs on first time.

We understand that NR only has a finite amount of engineering capacity and that everything has the be prioritised - however this is table-stakes for a SaaS these days.


#12

Hello,

Just wanted to add that I did get this feature through the partnership API. Although, I still think this needs to be available for owners/admins, the bulk of this can now be done using the API.

Another thing that I’d like to add here is that there should probably be an update to the API. There are now add-on roles available that I cannot add to a user using the API. This is something that would make life a lot easier and can help automate the whole process.

@Adrian.Stewart Just in time provisioning for SAML sounds like a great idea. I’m kinda surprised it isn’t available.


#13

Hey there folks -

I can appreciate your frustration in waiting to see this implemented. We’ve been hard at work reworking our RBAC controls, custom roles, and other user management features over the last year.

We’re continuing to work on user management, and I know the team is aware of this thread. Sorry that we’re still playing a waiting game, but you will continue to see improvements roll ou!


#14

Hi.
I think this needs to be prioritized ASAP. Group based RBAC is an absolute MUST-HAVE for any organization trying to roll out New Relic to multiple applications who have multiple support squads/teams.

We are currently expanding our new relic growth and this is a major hindrance for us in expanding our new relic usage.


#15

Hi @deepam.shah - you are not alone in that thinking. We do have a Feature Idea for creating users via SAML, so please feel free to vote there and add any usage details you would like to see:


#16

Thanks for reaching out @hross. I hope to see some features soon on RBAC and user account provisioning.


#17

Note the whole answer to the question of seemlessly provisioning new users, but there is the option of Bulk User Actions in the Users and Roles section of the Account settings.
Should be able to Create, Update and Delete users based on a CSV file list.


#18

+1 looking for API access to add users or automated synch with SAML via SCIM.


#19

Thanks for adding your +1 here @mike.keennon - I’ll get that added internally


#20

+1 it will be nice to have this feature available on the admin api key