API Explorer: Including Envelope Custom Fields - docusignapi

Trying to send from a DS template that has a required envelope custom field. From documentation I'd expect a Custom Field selection under envelopeId but not finding it.
Is this supported in the DS API explorer? Thanks!
Error code: ENVELOPE_CUSTOM_FIELD_MISSING.
Message: A required envelope custom field is missing. The custom field 'Cost Center' requires a value.

You can use this API call - https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopecustomfields/create/
So, you may need 3 API calls:
Create envelope in "draft" status.
Add custom fields.
Send it.
There may be a way to do this with fewer API calls, but I don't know how.

Related

Grabbing docusign envelope status and recipients in a single API call

I'm using the docusign api and am having some trouble with a query string param. Basically I'm trying to grab the recipient information of an envelope along with the status of the envelope in a single call.
I am able to grab each of information individually with the following api calls and they both work
1.) Envelope endpoint (has a status field with overall envelope status such as Signed, Voided, Declined, etc...):
https://na2.docusign.net/restapi/v2/accounts/:accountId/envelopes/:docusignEnvelopeId/
2.) Envelope/recipients endpoint (has information regarding recipients)
https://na2.docusign.net/restapi/v2/accounts/:accountId/envelopes/:docusignEnvelopeId/recipients
However, I'm trying to see if I can grab these information all within one API call. According to the docs here for the general envelope endpoint, I think I should be able to with a query param
https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/get#request.
Under the include Optional Query Parameters section, there's a param for "include" which says I can grab recipients from the 1st endpoint. "Specifies additional information about the envelope to return. Enter a comma-separated list, such as tabs,recipients. Valid values are..."
I've been trying to modify the first endpoint with this include param to look something like this...
https://na2.docusign.net/restapi/v2/accounts/:accountId/envelopes/:docusignEnvelopeId?include=recipients
But I have been unable to have recipients show up as well. Was wondering if I'm just typing in the param wrong or if this is not available anymore. Any help would be appreciated!
Thanks :)
The include parameters were added in v2.1 of the eSignature API, so they don't work in v2. Changing your URL to https://na2.docusign.net/restapi/v2.1/accounts/:accountId/envelopes/:docusignEnvelopeId?include=recipients should return the recipient info.

Docusign - Populate tabs in envelope using REST API

I have created a template in DocuSign with a number of fields. I have also built an application that creates an envelope from that template and sends it using the REST API.
In that process I also would like to prepopulate those fields in the envelope document before sending to the first recipient. For achieving this I have looked at the update method for recipient tabs (https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeRecipientTabs/update)
However when using the update method I need to have the tabId which is unique for each envelope. If I have 20 tabs in a document I have to fetch them all for getting the ID before doing an update. Is there a better way of doing this?
The API must be able to determine the unique tab you wish to update, so a unique ID of some sort is required to do so. Note also tabs are for a specific recipient and you need to specify the page number as well.

Save Docusign Document as Template through API

The docusign website allows for me to save a document as a template, but I have not been able to find a way to do this programmatically through the API. Is there a simple way to save a document as a template?
Yes, you can create a Template via the API by issuing this request:
POST /v2/accounts/{accountId}/templates
The API documentation contains details about this operation.
UPDATE
Do I understand correctly that your goal is to create a Template that's based upon an existing DocuSign Document, i.e., to mimic the following functionality in the DocuSign web UI?
If that's the case, then I'm not aware of any single API call that can do this. Instead, I believe you'll need to issue a series of API calls, to retrieve info about the existing Document(s) and then create the new Template using that info:
1) Get information about the existing DocuSign Document (envelope): GET /v2/accounts/{accountId}/envelopes/{envelopeId} (docs)
This operation returns recipient info (including tabs for each recipient) as well as envelope data like email subject, email body, reminders, etc. It also returns a documentsUri property that you can use to get the document(s) that belong to the envelope.
2) Get the list of document(s) that the envelope contains by issuing a GET request to the URI specified by the documentsUri from the prior response. (docs)
This operation returns information about each document in the specified envelope, but does not return document contents.
3) For each document listed in the prior API response, issue a GET request to the URI specified by the uri property for the document. (docs)
4) Finally, create a new Template using the data that you received in response to the previous API requests: POST /v2/accounts/{accountId}/templates (docs)
Note: As a final note -- if you're using one of the DocuSign SDKs, it's possible that there might be a function that you can call to implement this scenario, without having to piece together all of these API calls yourself. I'm not familiar enough with the SDKs to say whether or not they provide this type of functionality, but it'd be worth checking for, if you're using an SDK.

Track envelope status in salesforce using envelope external source Id via API

I am using Docusign package in my org. By using a custom buttom I am able to send a record for docusign approval. In this i set Source Id as record Id and track the status in a custom field on that record. But now I m using Docusign SOAP API and sending a record for docusign via Apex. But now I am unable to set envelope external source id in code and therefore status is not getting updated in that record.
Please reply if anyone has any idea how to set source id via apex and track status?
The best way to do this is to create an envelope custom field in your API call for the recordID and pass that through in your APEX code. The DocuSign for Salesforce manage package does this automatically and that's how the data gets written back to the correct records using Connect.
Create the envelope custom field in DocuSign and then add the CustomField Schema Type to your API call and populate it with the source ID. Then in Connect under the DocuSign Status Object map that Custom Field back to either the five out of the box objects or your custom object.

How can my application retrieve custom fields from a DocuSign transaction?

I am working with DocuSign custom fields. I want to get all my custom fields that were created in the admin console by using a REST API call.
Is there any REST call to get all the custom fields?
I believe you're wanting the information that you've set up displayed in JSON via REST.
endpoint: GET https://{server}/restapi/v2/accounts/{accountId}/custom_fields
This will return your textCustomFields and listCustomFields

Resources