Common API Tasks🐈: Update the name of a DocuSign user

Common API Tasks: Update the name of a DocuSign user

Welcome to a prodigious new edition of the CAT🐈 (Common API Tasks) blog series. The CAT blogs provide all you need to complete small, specific, SDK-supported tasks using one of our APIs. You can find all articles in this series on the DocuSign Developer Blog.

In this episode I’m going to show you how to use the DocuSign eSignature REST API to change the name (first name and/or last name) of a specific DocuSign user. Users in DocuSign have, at a minimum, an email address and a full name. If your integration supports multiple users and enables each user to log in using their DocuSign credentials (typically done by using Authentication Code Grant type of authentication for your application) then you may have a feature showing the user their name (with some message like “Welcome to MyApp Jane Doe”). This is also done in the DocuSign web app in the top-right corner where you can see the user’s initials (first letter for first and last names) and if you select that a menu will appear showing the full name of the logged in user.

Sometimes users need to change their name for various reasons such as typos in the original name, getting married, using a nickname, etc. Using the web app, any user can change their own name by clicking on the same top-right menu and selecting Manage Profile. At that point they can select the UPDATE button next to their name and modify it. Administrators of the DocuSign account can also modify the names of any of the users in the account. They do that by going to eSignature Admin (“Settings” menu at the top of the web app), selecting Users from the left-side menu and then finding the user they want to modify. Using the Actions menu, they can select Edit to modify the user name (as well as other user information). 

Well, then, would you be so surprised if I told you that you can do this programmatically? After all, this is what we do around here. So, here are some simple code snippets as usual. Note that you need to provide the userId for the specific user whose name you want to modify and that user must be on the same account as the one used to obtain the OAuth access token.

C#

var apiClient = new ApiClient(basePath);
// You will need to obtain an access token using your chosen authentication method
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
UsersApi usersApi = new UsersApi(apiClient);
UserProfile userProfile = new UserProfile();
userProfile.UserDetails = new UserInformation();
userProfile.UserDetails.FirstName = "Inbar";
userProfile.UserDetails.LastName = "Gazit";
usersApi.UpdateProfile(accountId, userId, userProfile);

Java

// You will need to obtain an access token using your chosen authentication flow 
Configuration config = new Configuration(new ApiClient(basePath));
config.addDefaultHeader("Authorization", "Bearer " + accessToken);
UsersApi usersApi = new UsersApi(config);
UserProfile userProfile = new UserProfile();
userProfile.setUserDetails(new UserInformation());
userProfile.getUserDetails().setFirstName("Inbar");
userProfile.getUserDetails().setLastName("Gazit");
usersApi.UpdateProfile(accountId, userId, userProfile);

Node.js

// You will need to obtain an access token using your chosen authentication flow 
let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + accessToken);
UserApi usersApi = new docusign.UsersApi(apiClient);
let userProfile = new docusign.UserProfile();
userProfile.userDetails = new docusign.UserInformation();
userProfile.userDetails.firstName = 'Inbar';
userProfile.userDetails.lastName = 'Gazit';
usersApi.updateProfile(accountId, userId, userProfile);

PHP

# You will need to obtain an access token using your chosen authentication flow 
$api_client = new \DocuSign\eSign\client\ApiClient($base_path);
$config = new \DocuSign\eSign\Model\Configuration($api_client);
$config->addDefaultHeader('Authorization', 'Bearer ' + $access_token);
$users_api = new \DocuSign\eSign\Api\UsersApi($api_client);
$user_profile = new \DocuSign\eSign\Model\UserProfile();
$user_profile->setUserDetails(new \DocuSign\eSign\Model\UserInformation());
$user_profile->getUserDetails()->setFirstName('Inbar');
$user_profile->getUserDetails()->setLastName('Gazit');
$users_api->updateProfile($account_id, $user_id, $user_profile);

Python

# You will need to obtain an access token using your chosen authentication flow 
api_client = ApiClient()
api_client.set_default_header('Authorization', 'Bearer ' + access_token)
users_api = UsersApi(api_client)
user_profile = UserProfile()
user_profile.user_details = UserInformation()
user_profile.user_details.first_name = 'Inbar'
user_profile.user_details.last_name = 'Gazit'
users_api.update_profile(account_id, user_id, user_profile)

Ruby

# You will need to obtain an access token using your chosen authentication flow 
config = DocuSign_eSign::Configuration.new
config.host = base_path
api_client = DocuSign_eSign::ApiClient.new config
api_client.DefaultHeader['Authorization'] = 'Bearer ' + access_token
users_api = DocuSign_eSign::UsersApi.new api_client
user_profile = DocuSign_eSign::UserProfile.new
user_profile.user_details = DocuSign_eSign::UserInformation.new
user_profile.user_details.first_name = 'Inbar'
user_profile.user_details.last_name = 'Gazit'
users_api.update_profile(account_id, user_id, user_profile)

That’s all folks! I hope you found it useful. If you have any questions, comments, or suggestions for topics for future Common API Tasks posts, feel free to email me. Until next time...

Additional resources

Inbar Gazit
Author
Inbar Gazit
Sr. Manager, Developer Content
Published