简体   繁体   中英

DocuSign REST API - Send envelopes as a different user

I am setting up a web app that uses DocuSign to send an eSignature request to various different clients. Each request to a different client needs to have a different displayed sender name and email address, and not just the main name on the DocuSign account. The completed e-signed form also needs to be emailed to these client-specific email addresses as well.

I have created a new second login within my DocuSign account as a test, and am able to get it to display this login's name/email, but only when I generate an entirely new temporary demo API key from that account and use that in the application.

I am able to change the reply email by altering the EnvelopeDefinition.EmailSettings.ReplyEmailAddressOverride field, but the envelope email sent to signers still displays the main account name/email, and signed docs are emailed to the main email.

How can I change the name and email address sent to the signer and the email address signed docs are received by?

            string signerName = "John Doe";
            string signerEmail = "johndoe@fake.com";
            string accessToken = "{The DocuSign API KEY}";
            string accountId = "{The DocuSign Account Number}";

            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name = "Please Sign This Form",
                FileExtension = "docx",
                DocumentId = "1"
            };
            Document[] documents = new Document[] { document };

            Signer signer = new Signer
            {
                Email = signerEmail,
                Name = signerName,
                RecipientId = "1",
                RoutingOrder = "1"
            };

            Tabs tabs = new Tabs();

            SignHere signHereTab = new SignHere
            {
                DocumentId = "1",
                PageNumber = "1",
                AnchorString = "Patient Signature or Mark",
                AnchorUnits = "pixels",
                AnchorXOffset = "10",
                AnchorYOffset = "-18",
                Width = "160"
            };
            List<SignHere> signatureTabs = new List<SignHere>();
            signatureTabs.Add(signHereTab);
            tabs.SignHereTabs = signatureTabs;

            FullName nameTab = new FullName
            {
                DocumentId = "1",
                PageNumber = "1",
                TabLabel = "Full Name",
                Value = signerName,
                AnchorUnits = "pixels",
                AnchorString = "Name:",
                AnchorXOffset = "133",
                AnchorYOffset = "5"
            };
            List<FullName> nameTabs = new List<FullName>();
            nameTabs.Add(nameTab);
            tabs.FullNameTabs = nameTabs;

            signer.Tabs = tabs;

            Recipients recipients = new Recipients
            {
                Signers = new List<Signer> { signer }
            };
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = "Please Sign Form",
                Documents = new List<Document>(documents),
                Recipients = recipients,
                Status = "sent"
            };

            //Override the reply email address
            envelopeDefinition.EmailSettings = new EmailSettings();
            envelopeDefinition.EmailSettings.ReplyEmailAddressOverride = "client-specific-email@fake.com";
            envelopeDefinition.EmailSettings.ReplyEmailNameOverride = "Test Account";

            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken); 

            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
            EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

If your app wants to send as various different people (users) on your DocuSign account, the right answer is to impersonate them using the OAuth JWT flow. See the JWT examples, the eg-01 code examples, on github.com/docusign.

For each user impersonated, your app will need their user guid from DocuSign. It is available from the Users section of the administration tool.

The old legacy authentication header technique is not supported for new apps.

Since you are using the Token Generator on Developer Center https://developers.docusign.com/oauth-token-generator , your choice for now is to login to that website with the other user you wish to use and that token would be for that other user.

Long term I would suggest you look into using JWT Auth. That has the option of specifiying the userId and you can switch users. You also have to use real auth if you want to move your app out of the developer sandbox and into production anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM