docusignapi

DocuSign Envelope with multiple documents with different Signatories


We have a requirement where we have to send multiple documents for signatures.

For Example:Document 1 has to signed by only Signatory 1, Document 2
has to be signed by only Signatory 2, Document 3 has to be signed by
only Signatory 3.

Can we use a single envelope containing all the documents? Also, can all signatories see all documents during signing or can we ensure that Signatory see only those documents where his/her signature us required?

Thanks!!


Solution

  • You can do this using document visibility. That feature enables you to specific which recipient sees which document.

    You can find a code example showcasing how to do this here - https://developers.docusign.com/docs/esign-rest-api/how-to/set-document-visibility/

    Here is the C# code:

    private static EnvelopeDefinition PrepareEnvelope(
        string signer1Email,
        string signer1Name,
        string signer2Email,
        string signer2Name,
        string ccEmail,
        string ccName,
        string docPdf,
        string docDocx,
        string docHtml)
    {
        EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
        {
            EmailSubject = "Please sign this document set",
            Documents = PrepareDocumentsForTemplate(
                signer1Email,
                signer1Name,
                ccEmail,
                ccName,
                docPdf,
                docDocx,
                docHtml),
            EnforceSignerVisibility = "true",
        };
    
        Signer signer1 = PrepareSigner(
            signer1Email,
            signer1Name,
            "1",
            "1",
            new List<string> { "2", "3" },
            "**signature_1**",
            "pixels",
            "20",
            "10");
        Signer signer2 = PrepareSigner(
            signer2Email,
            signer2Name,
            "2",
            "1",
            new List<string> { "1" },
            "/sn1/",
            "pixels",
            "20",
            "10");
    
        CarbonCopy carbonCopy = new CarbonCopy
        {
            Email = ccEmail,
            Name = ccName,
            RecipientId = "3",
            RoutingOrder = "2",
        };
    
        envelopeDefinition.Recipients = new Recipients
        {
            CarbonCopies = new List<CarbonCopy> { carbonCopy },
            Signers = new List<Signer> { signer1, signer2, },
        };
    
        envelopeDefinition.Status = "sent";
    
        return envelopeDefinition;
    }
    
    private static Signer PrepareSigner(
        string signerEmail,
        string signerName,
        string recipientId,
        string routingOrder,
        List<string> excludedDocuments,
        string tabsAnchorString,
        string tabsAnchorUnits,
        string tabsAnchorXOffset,
        string tabsAnchorYOffset)
    {
        return new Signer
        {
            Email = signerEmail,
            Name = signerName,
            RecipientId = recipientId,
            RoutingOrder = routingOrder,
            ExcludedDocuments = excludedDocuments,
            Tabs = new Tabs
            {
                SignHereTabs = new List<SignHere>
                {
                    new SignHere
                    {
                        AnchorString = tabsAnchorString,
                        AnchorUnits = tabsAnchorUnits,
                        AnchorXOffset = tabsAnchorXOffset,
                        AnchorYOffset = tabsAnchorYOffset,
                    },
                },
            },
        };
    }
    
    private static List<Document> PrepareDocumentsForTemplate(
        string signer1Email,
        string signer1Name,
        string ccEmail,
        string ccName,
        string docPdf,
        string docDocx,
        string docHtml)
    {
        byte[] pdfFileContentInBytes = System.IO.File.ReadAllBytes(docPdf);
        byte[] docxFileContentInBytes = System.IO.File.ReadAllBytes(docDocx);
    
        string htmlFileContentsString = System.IO.File.ReadAllText(docHtml);
        htmlFileContentsString = htmlFileContentsString.Replace("{USER_EMAIL}", signer1Email);
        htmlFileContentsString = htmlFileContentsString.Replace("{USER_FULLNAME}", signer1Name);
        htmlFileContentsString = htmlFileContentsString.Replace("{CC_EMAIL}", ccEmail);
        htmlFileContentsString = htmlFileContentsString.Replace("{CC_NAME}", ccName);
        byte[] htlmFileContentInBytes = System.Text.Encoding.UTF8.GetBytes(htmlFileContentsString);
    
        return new List<Document>
        {
            new Document
            {
                DocumentBase64 = Convert.ToBase64String(htlmFileContentInBytes),
                Name = "Order acknowledgement",
                FileExtension = "html",
                DocumentId = "1",
            },
            new Document
            {
                DocumentBase64 = Convert.ToBase64String(docxFileContentInBytes),
                Name = "Battle Plan",
                FileExtension = "docx",
                DocumentId = "2",
            },
            new Document
            {
                DocumentBase64 = Convert.ToBase64String(pdfFileContentInBytes),
                Name = "Lorem Ipsum",
                FileExtension = "pdf",
                DocumentId = "3",
            },
        };
    }