Blog
Home/

Common API Tasks🐈: View a complete envelope from your app

Author Inbar Gazit
Inbar GazitSr. Manager, Developer Content
Summary3 min read

Learn how to use the eSignature REST API to embed the Docusign viewer in your app and show the completed envelope.

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

      Table of contents

      Common API Tasks🐈: View a complete envelope from your app

      Welcome to an incredible 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 edition I’m going to show you a simple thing that is frequently requested by developers, and while it’s very easy to do, it’s not often clear how to do it. As you know, when an envelope is complete, there’s a final PDF copy that represents the agreed-upon contract, the final agreement, with all the signatures and other tabs (signing elements) from all the recipients. On the Developer Center we have an article showing you how to download this PDF, as well as other related PDFs (such as the certificate of completion). That article assumes you want to download the document as a file, but what if you want to use the same Docusign viewer that users of the Docusign web app can use to view the complete envelope? What if you want to integrate or embed this viewer inside your own application? This can be done using the Docusign eSignature REST API, and I’m going to show you how. 

      Before we get to the code snippets, here is the information you need to make this API call:

      • accountId**:** Needed for almost all API calls, this is the GUID account ID for the Docusign account containing the complete envelope.

      • envelopeId**:** The unique identifier for the complete envelope.

      • userName**:** The name of the user that sent the envelope. It can also be one of the recipients of this envelope.

      • emailAddress**:** The email address of the user that sent the envelope. It can also be one of the recipients of this envelope.

      C#

      var docuSignClient = new DocuSignClient(basePath);
      // You will need to obtain an access token using your chosen authentication method
      docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
      EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
      
      RecipientViewRequest recipientViewRequest = new RecipientViewRequest();
      recipientViewRequest.UserName = userName;
      recipientViewRequest.Email = emailAddress;
      recipientViewRequest.ReturnUrl = "https://www.docusign.com";
      // In this example, your application is responsible for authentication, and no additional authentication will be required
      recipientViewRequest.AuthenticationMethod = "none";
      ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, recipientViewRequest);
      string url = viewUrl.Url; // URL expires in 5 minutes
      
      

      Java

      Configuration config = new Configuration(new ApiClient(basePath));
      // You will need to obtain an access token using your chosen authentication method
      config.addDefaultHeader("Authorization", "Bearer " + accessToken);
      EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
      
      RecipientViewRequest recipientViewRequest = new RecipientViewRequest();
      recipientViewRequest.setUserName(userName);
      recipientViewRequest.setEmail(emailAddress);
      recipientViewRequest.setReturnUrl("https://www.docusign.com");
      // In this example, your application is responsible for authentication, and no additional authentication will be required
      recipientViewRequest.setAuthenticationMethod("none");
      ViewUrl viewUrl = envelopesApi.createRecipientView(accountId, envelopeId, recipientViewRequest);
      String url = viewUrl.getUrl(); // URL expires in 5 minutes
      
      

      Node

      let dsApiClient = new docusign.ApiClient();
      dsApiClient.setBasePath(basePath);
      // You will need to obtain an access token using your chosen authentication method
      dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + accessToken);
      let envelopesApi = new docusign.EnvelopesApi(dsApiClient);
      
      let recipientViewRequest = new docusign.RecipientViewRequest();
      recipientViewRequest.userName = userName;
      recipientViewRequest.email = emailAddress;
      recipientViewRequest.returnUrl = 'https://www.docusign.com';
      // In this example, your application is responsible for authentication, and no additional authentication will be required
      recipientViewRequest.authenticationMethod = 'none';
      let viewUrl = envelopesApi.createRecipientView(accountId, envelopeId, recipientViewRequest);
      let url = viewUrl.Url; // URL expires in 5 minutes
      
      

      PHP

      $api_client = new \Docusign\eSign\client\ApiClient($base_path);
      $config = new \Docusign\eSign\Model\Configuration($api_client);
      # You will need to obtain an access token using your chosen authentication method
      $config->addDefaultHeader('Authorization', 'Bearer ' + $access_token);
      $envelopes_api = new \Docusign\eSign\Api\EnvelopesApi($api_client);
      
      $recipient_view_request = new \Docusign\eSign\Model\RecipientViewRequest();
      $recipient_view_request->setUserName($user_name);
      $recipient_view_request->setEmail($email_address);
      $recipient_view_request->setReturnUrl('https://www.docusign.com');
      # In this example, your application is responsible for authentication, and no additional authentication will be required
      $recipient_view_request->setAuthenticationMethod('none');
      $view_url = $envelopes_api->createRecipientView($account_id, $envelope_id, $recipient_view_request);
      $url = $view_Url->getUrl(); # URL expires in 5 minutes
      
      

      Python

      api_client = ApiClient()
      # You will need to obtain an access token using your chosen authentication method
      api_client.set_default_header('Authorization', 'Bearer ' + access_token)
      envelopes_api = EnvelopesApi(api_client)
      
      recipient_view_request = RecipientViewRequest()
      recipient_view_request.user_name = user_name
      recipient_view_request.email = email_address
      recipient_view_request.return_url = 'https://www.docusign.com'
      # In this example, your application is responsible for authentication, and no additional authentication will be required
      recipient_view_request.authentication_method = 'none'
      view_url = envelopes_api.create_recipient_view(account_id, envelope_id, recipient_view_request)
      url = view_url.Url # URL expires in 5 minute
      
      

      Ruby

      config = DocuSign_eSign::Configuration.new
      config.host = base_path
      api_client = DocuSign_eSign::ApiClient.new config
      # You will need to obtain an access token using your chosen authentication method
      api_client.DefaultHeader['Authorization'] = 'Bearer ' + access_token
      envelopes_api = DocuSign_eSign::EnvelopesApi.new api_client
      
      recipient_view_request = DocuSign_eSign::RecipientViewRequest.new
      recipient_view_request.user_name = user_name
      recipient_view_request.email = email_address
      recipient_view_request.return_url = 'https://www.docusign.com'
      # In this example, your application is responsible for authentication, and no additional authentication will be required
      recipient_view_request.authentication_method = 'none'
      view_url = envelopes_api.create_recipient_view(account_id, envelope_id, recipient_view_request)
      url = view_url.Url # URL expires in 5 minute
      
      

      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

      Author 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

      • Common API Tasks🐈: List all your Maestro workflows using the Maestro API
        Common API Tasks

        Common API Tasks🐈: List all your Maestro workflows using the Maestro API

        Author Inbar Gazit
        Inbar Gazit
      • Common API Tasks🐈: Find a web form by name

        Common API Tasks🐈: Find a web form by name

        Author Inbar Gazit
        Inbar Gazit
      Common API Tasks🐈: Find a web form by name

      Common API Tasks🐈: Find a web form by name

      Author Inbar Gazit
      Inbar Gazit

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

      Explore Docusign IAMTry eSignature for Free
      Person smiling while presenting