download signed document as JSON from docusign - node.js

It seems that docusign only supports downloading the signed documents as PDF instead of JSON.
I need to 'read' the filled fields of the documents (the document has some fields to fill in).
I can upload the document as JSON and it gets parsed, so why can't I donwload it as JSON?
How do companies normally handle the field values?
Thanks!

You don't need the actual PDF document to get the values, you need to parse the call coming back from DocuSign since that has total envelope data. The webhooks for notification contains the data and you can parse that to retrieve the envelope data.
Do you know if its also possible with a GET call instead of the webhook? It could be the server is down etc, so I can't imagine DocuSign does have something like GET:envelope/:id/data or something.. But really cannot find anything like it
Yes. You can either use a GET call (included below) any time you want to get envelope data or you can set up the webhooks so that DocuSign will send you updates whenever it has one!
The following GET call retrieve envelope data from {{envelopeId}}. By parsing the response from the call you can retrieve all information that was filled on the envelope.
{{baseUrl}}/envelopes/{{envelopeId}}/recipients?include_tabs=true
I hope this helps.
P.S. Summarized our comments to have a complete answer.

The PDF format is, for lack of better words, a complicated jumble of compiled data that can be difficult to parse. What it appears docusign will do is take the data provided and fill the PDF document fields that are previously identified.
With docusign returning the PDF, you will need to parse the PDF input fields to receive the field values. There are several libraries that can be used to parse the various form fields and do what you would like. Check out:
https://www.npmjs.com/package/pdfreader
https://www.npmjs.com/package/pdf2json
I am sure there are more that would work for you as well if you look around if these don't work for you.

Related

Custom document metadata when using DocuSign REST API

Is there a way that I can provide any custom document metadata when adding documents to my DocuSign envelopes when using the REST API?
DocuSign appear to enforce the use of a positive integer for the DocumentId's we provide in the envelope. Whilst we are indeed using a positive integer, sometimes, there is some additional info that we need to supply, which we would like to come back in the DocuSign webhook events for specific documents.
I've had a look at the Document object but can't see anything obvious that I could use. An example would be simply providing a true/false along with a specific document, which I can inspect when I receive the DS webhook events.
At the moment, the only workaround I can think of is to add an Envelope Custom Field which contains any of my DocumentId's where 'true' is applicable, which feels like a bit of a shoddy solution, and I don't know if there's a character limit in those Envelope Custom Fields, which could break such a workaround.
Custom envelope text fields give you complete flexibility on providing meta-data that you can get back from the webhook. Here is some information about this:
This is how you create a custom field for an envelope:
https://developers.docusign.com/docs/esign-rest-api/reference/Envelopes/EnvelopeCustomFields/create/
This article shows code examples in 7 languagues on how to get the custom fields values :
https://developers.docusign.com/docs/esign-rest-api/how-to/get-envelope-custom-field-values/

Is it possible to conditionally display DocuSign template parts/sections?

I would like to know if it is possible to show/hide parts of DocuSign document template depending on the data which is passed in as a request.
I already have document template created and uploaded to DocuSign. I then use templateId to create envelope for that document and I also send some data (as json) to prepopulate certain fields inside the envelope.
The thing I am asking now is:
If the template has, let's say, 3 paragraphs, is it possible to hide one of them completely, based on the passed in json data?
Creating and uploading multiple templates is not an option due to large number of conditionally displayed sections.
I have been reading DocuSign API documentation, but couldn't find an answer to this.
To do that you will have to use Responsive Signing.
This feature change the format of the document you sign from PDF to HTML.
With HTML being the format, there are a lot more things you can do.
For example, you can use what we call "Smart Sections" which is exactly what you want. Sections that can be shown off/on based on logic you set.
Find out more about the responsive signing API here - https://developers.docusign.com/esign-rest-api/guides/responsive-signing/api-overview

Docusign API, "Correct Document" or just change fields

Using the Docusign API, I am trying to change the fields that exist on a document. When I first create the document, I am able to change field values using "tabs." I get how to do that.
When I am trying to edit, or in Docusign's terms "correct," a document after it has been sent out, but before being signed, I am having trouble figuring out how to access those fields again to change the values.
I have tried using the API avenue described here ( PUT /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}/fields ), but even after successful calls, the values of the fields aren't changing, and I believe it is because I should be trying to access the tabs, as I did when first changing the tab values as I created the document, instead of targeting the fields, since the two seem to be different. Any thoughts? Thank you in advance for your answers.
To update Tab values you should use the putRecipientTabs api.
Once a signer completes the Signing process, the tab values cannot be updated.
Also not all Tab values can be updated. See this answer for more information.
The putEnvelopeDocumentFields api is for a different purpose. Document fields are different from Tabs. Document fields are an array of name-value custom data strings to be added to a document. Custom document field information is returned in the status, but otherwise is not used by DocuSign.
I figured it out.
The "fields" we are seeing on documents are "tabs," and they are children of the recipients.
The hierarchy goes envelope > recipients > tabs, which tabs we were trying to change. Not envelope > document > fields, which refers to something else--just familiarizing with the language of the api.
Here is a link to the reference for how to change "fields" aka "tabs", and that link includes sample requests.
One thing that helped me target my actual fields, since I kept on getting an error that the field didn't exist for the recipient, is to do a get request of all available tabs and use that response body as the request body for the update call (where we change the field values). Then you know the field information will be accurate, paring the body down to exactly the "fields" aka "tabs" you are interested in targeting.

retrieve individual documents from an envelope that has multiple instead of getting back combined

I am using the rest API calling the envelope.Create() passing in a List of Byte arrays and filenames.
How can I retrieve each individual document separately after the signing ceremony?
The GetCompletedDocument sends me back the whole thing in one PDF. GetEnvelopeDocumentInfo just gets me names and URIs.
Using /restapi/v2
https://docs.docusign.com/esign/restapi/Envelopes/EnvelopeDocuments/get/
That should give you an idea of how to grab individual documents.

Retrieving Recipient Status via REST API

There appears to be two ways I can gather status information about individual recipients on an envelope:
GET - v2/accounts/:accountId/envelopes/:envelopeId/recipients
GET - v2/accounts/:accountId/envelopes/:envelopeId/audit_events
Unfortunately, each of these suffers from a separate limitation that is making it difficult for me to use either.
This API call returns two DateTime values of interest: deliveredDateTime and signedDateTime. I am able to call and use this API successfully. However, it appears to me that deliveredDateTime is not specified until the user actually clicks the email link AND clicks the review documents button on the signer view. Since what I was actually interested in might be better described as sentDateTime, deliveredDateTime doesn't appear to work for my needs.
This API call returns a detailed list of all events that have transpired on the envelope, including individual receipient status updates. However, the data format is such that in order to tie the result data back to recipients, I have to do string matches on the recipient name. I'd prefer to do the match based on email or, better still, recipientID, but the audit log entries for "sent invitations" and "signed" don't contain these fields. Here is an example (click here to view larger):
Is there an API call other than these two that I can use? Is there a way to get additional data in the audit event API call?
Thank you in advance,
Andrew
I don't believe there's a way to get additional data from the audit_events call since the DocuSign API documentation (which is up to date) indicates that call has no parameters (other than the envelopeId in the URL).
I think you're stuck with doing a string comparison on the userName value to identify/link your recipients, however I want to point out that once you do that you can then link to their unique recipientGuid through the first api call you've highlighted here.
For instance, the /audit_events API call seems to achieve what you want and has all the info you need, however it identifies the recipients through their userNames. If you then make a call on the same envelope and check the response from the /recipients URI, it contains the name, email, recipientId, and recipientGuid for each and every recipient in the envelope. Match the user names and you now have access to their IDs, etc.
So in the end I don't believe there's one API call to achieve this but you can solve by doing one string compare and combining the results from the API calls you've highlighted.

Resources