Blog
Home/

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

Inbar Gazit
Inbar GazitSr. Manager, Developer Content
•
Summary•3 min read

Let Inbar show you how to use the eSignature API to change the user name of a user in your Docusign account.

    • C#
    • Java
    • Node.js
    • PHP
    • Python
    • Ruby
    • Additional resources

    Table of contents

    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
    Inbar GazitSr. Manager, Developer Content

    Inbar Gazit has been with Docusign since 2013 in various engineering roles. Since 2019 he has focused on developer content. Inbar works on code examples including the launchers, available on GitHub in eight languages, and helps build sample apps showcasing the various Docusign APIs. He is also active on StackOverflow, answering your questions. Inbar can be reached at inbar.gazit@docusign.com.

    More posts from this author

    Related posts

    • Developers

      Shaping the future of banking and financial services in Hong Kong: A Docusign primer for developers, Part 3

    • Paige Rossi
      Paige Rossi
    • Developer Spotlight: Abhishek Anmol, Birlasoft

      Matthew Lusher
      Matthew Lusher
    Paige Rossi
    Paige Rossi

    Developer Spotlight: Abhishek Anmol, Birlasoft

    Matthew Lusher
    Matthew Lusher

    Discover what's new with Docusign IAM or start with eSignature for free

    Explore Docusign IAMTry eSignature for Free
    Person smiling while presenting