'Example of DocuSign REST API EnvelopeAttachment: update?

Could someone please supply an example of the use of the DocuSign REST API EnvelopeAttachment: update request (PUT /restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/attachments/{attachmentId})? What I want to do is add an attachment to an envelope in draft mode that will be seen by the signer when it is sent. Not a signer attachment. An attachment that will be seen by the signer in the signing page.

The example in the DocuSign REST API documentation is terribly vague.



Solution 1:[1]

I think we should clear up what your objective is, and why you want an envelopeAttachment over a signerAttachment. You say:

What I want to do is add an attachment to an envelope in draft mode that will be seen by the signer when it is sent.

EnvelopeAttachments are not visible through the interface and signers will not be able to see it unless they use the API to download envelopeAttachments. View the source for my claim here. If you want to have a document signer see an attachment, you do want signer attachments. Maybe this blog post is what you are looking for if not.

All that being said, I can also provide some examples for EnvelopeAttachments. The request I'm making in my example is a create, but as far as I can tell the difference between update and create exists server side and the request is the same. These are in groovy.

// define the data for the request
def attachmentContent = JsonOutput.toJson([
    attachments: [ [
        attachmentId: 1,
        label: "ExampleLabel",
        attachmentType: ".txt",
        name: "ExampleName",
        accessControl: "senderAndAllRecipients",
        data: ExampleFile.contents.bytes.encodeBase64().toString()
    ] ]
])

// put request against this url for adding attachments
def attachmentUrl = "${ESIGN_API_URL}/v2/accounts/${ACCT_ID}/envelopes/${ENV_ID}/attachments"

// invokeDocuSignApi is just a wrapper for a curl request
def response = invokeDocuSignApi("PUT", attachmentUrl, attachmentContent, ACCESS_TOKEN)

This will add attachments to the envelope. These attachments are only visible through the API, so they won't work for your problem statement and I recommend signerAttachments.

Of note, envelopeAttachments added when the envelope is a draft are deleted when the envelope is sent. You can add envelopeAttachments to an in progress envelope, so I just added them after sending. Not sure if it's a bug or not but the workaround is simple. I'll update this thread after I figure it out : )

Solution 2:[2]

I have learned that what I wanted to do was add a document to the envelope rather than adding an attachment. I am now successfully adding documents to my envelope and everything is working as I would expect.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Albert Furlong
Solution 2 David Schuler