3

Is there a way to use the API to get the URL for a user to view a particular envelope on the DocuSign web site? I'm not trying to use the embedded signing experience, so the various envelope "views" provided by the API are not the desired URLs. The goal is provide a link in a custom web application that when clicked would show the envelope based on the user's sign-in to the Docusign web site, redirecting to the Docusign login page if necessary (the "console" URL provides the desired UI but does not force this kind of normal website authentication).

I've seen a couple other posts, including url for managing an evelope and get document url. The latter one looked promising (though in my case the desired URL is for the overall envelope, not a specific document), but doesn't provide a code example for constructing the complete URL.

I'm using C#, with code that includes the following (based on the get envelope API):

EnvelopesApi envelopesApi = new EnvelopesApi(loginResult.ApiConfiguration);
var envelope = envelopesApi.GetEnvelope(loginResult.AccountId, envelopeId);

string envelopeUri = envelope.EnvelopeUri;

Uri baseUri;
if (Uri.TryCreate(baseUrl, UriKind.Absolute, out baseUri))
{
    var uriBuilder = new UriBuilder(baseUri.Scheme, baseUri.Host);
    uriBuilder.Path = envelopeUri;

    envelopeUrl = uriBuilder.Uri.AbsoluteUri;
}

The "baseURL" is from the login result. An example of the resulting "envelopeUrl" is https://demo.docusign.net/envelopes/c47dfe7b-3b2c-4885-95b8-56ac7c5aba18

However, that URL returns a 404 error. Is there more needed in the path portion of the URL? The documentation isn't clear how to use the returned envelopeUri, or whether it is for API use or part of a normal website URL for use in a browser.

Tim K
  • 33
  • 1
  • 4

3 Answers3

1

There are a few methods of requesting a recipient view. You can obtain a console view, a sender view, or a recipient view. In your case it sounds like you want the signing view. If you supplied a ClientUserId you'll need to specify it in your request, otherwise you'll target the name / email of the recipient and make a POST call to https://{endpoint}.docusign.net/restapi/v2/accounts/$accountId/envelopes/$envelopeId/view/recipient

Example:

{ "returnUrl": "http://localhost/returnUrl", "authenticationMethod":"email", "email": "recipientemail@email.com", "userName": "RecipientName" }

This results in a response containing the in-session signing link that your recipient can use to access the envelope.

        EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.Configuration);
        RecipientViewRequest viewOptions = new RecipientViewRequest()
        {
            ReturnUrl = returnurl,
            ClientUserId = "1234",  // Must match if supplied when creating the envelope
            AuthenticationMethod = "email",
            UserName = "recipientName",
            Email = "recipientEmail"
        };


        ViewUrl recipientView = envelopesApi.CreateRecipientView(AccountId, EnvelopeId, viewOptions);
Matt King DS
  • 1,252
  • 9
  • 6
  • I've already tried some of the mentioned "views", but that doesn't meet the requirements. As stated in the original post, I do not want the views for embedded signing. What I'm looking for is a supported way of getting the URL to view an envelope in such a way that, if not already signed in, requires the user to sign-in via the DocuSign login page. The various "view" URLs don't meet this authentication requirement. – Tim K Aug 22 '17 at 17:50
1

You mentioned that console URL provides you the desired UI so if you want console URL with normal website authentication then you can use Authorization Code Grant, https://docs.docusign.com/esign/guide/authentication/oa2_auth_code.html#starting-the-authentication-code-grant

Ask user to authenticate via DS WebApp and after authentication, you need to generate their access token using OAUTH APIs, once you get access token then use Console View to show DS WebApp to the user.

Amit K Bist
  • 6,760
  • 1
  • 11
  • 26
  • This is the best answer so far. I had overlooked that part of the documentation since my app currently uses the DocuSign APIs from server-side code (I should have pointed out in the original post that I was using a service integration via the legacy header). I will definitely try this route if I have a need for it in the future; for now I've bypassed the whole issue by using the API to download documents as a PDF, which is sufficient for what my app needs at the moment. – Tim K Sep 05 '17 at 13:57
  • Hi @TimK Can you please provide the api call you are using to download the pdf. – ramesh m May 25 '21 at 10:47
  • @ramesh-m, that question is probably a little off topic for this old post. If using C# like the code above, use EnvelopesAPI.GetDocument to download the PDF. The relevant API doc is [here](https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/get/) – Tim K May 26 '21 at 13:17
0

Redirect the user to the Docusign web app

The app should prompt the user for credentials and show the envelope details page if the user has access to the envelope.

https://appdemo.docusign.com/documents/details/c47dfe7b-3b2c-4885-95b8-56ac7c5aba18
Praveen Reddy
  • 7,295
  • 2
  • 21
  • 43
  • I've seen URLs like that in the browser address bar, but relying on that isn't a good idea unless it's documented somewhere. Using the API to get the URL is preferred. – Tim K Aug 17 '17 at 17:05
  • Unfortunately there is no such option through the API. You can however build an app by yourself on top of the REST API. The [DocuSign rest api](https://docs.docusign.com/esign/) should provide you all the envelope information in json/xml format. That might not be simple but its possible. For ex: The DocuSign web app is built on top of the REST API. – Praveen Reddy Aug 17 '17 at 17:17