Embedded Signing - Signing from My App - docusignapi

I'm working on get the signing process on an iFrame to Embedded docusign on my app.
I have trying to work on this based on this tutorials:
Docusign Embedded Signing using template
https://developers.docusign.com/esign-rest-api/guides/features/embedding
Based on what I understood, if you want to embedded you have to create the "create the envelope on the fly". So you don't specify the templateId correct?
So what I don't fully get is, how I get the documentBase64 string value? I have to get it manually? Or docusing api has an endpoint that will return that?
Also I want to know, what happen to the custom fields I added to the template? I can't use them?
Right now this is the json I'm sending:
{{baseUrl}}/envelopes
{
"emailSubject":"This is a custom email subjet, look at the doc.",
"status":"sent",
"templateId":"a0847413-35ac-48ed-9ed6-9b7f96019eda",
"templateRoles":[
{
"email":"mauriciotaranto#email.com",
"name":"Mauricio T",
"clientUserId": "1234",
"roleName":"Test",
"routingOrder":"1",
"tabs": {
"textTabs": [
{
"tabLabel": "Custom",
"value": "This is a custom value"
},
{
"tabLabel": "NewCustom",
"value": "Another custom value added using API"
},
{
"tabLabel": "NewCustom1",
"value": "Last custom value added using API"
}
]
}
}
],
}
And then I go to the recipient view to get the URL:
{{baseUrl}}/envelopes/{{envelopeId}}/views/recipient
{
"returnUrl": "https://www.google.com.uy",
"authenticationMethod": "None",
"email": "mauriciotaranto#email.com",
"userName": "Mauricio T",
"clientUserId": "1234"
}
As far as I understood this way will not allow the user to sing the document.
Need to do it with the document instead.
Can you explain to me how this should work?
Thanks!
UPDATE:
Im manually parsing the bytes of the document to base64. and send this json:
"status":"sent",
"emailSubject":"Envelope with Embedded Signer",
"documents":[
{
"documentId":"1",
"name":"contract.pdf",
"documentBase64":bytes
}
],
"recipients":{
"signers":[
{
"email":"mauriciotaranto#hotmail.com",
"name":"Mauricio T",
"recipientId":"1",
"clientUserId":"1234"
}
]
}
}
I change the headers, add the accept: application/json and content-type: multipart/from-data
And this is the response I get:
{
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
}

You can create envelopes in any way, either by using Templates or by passing base64 of document or both as well using Composite Template. When you send templates, then you already have added signers tabs on the document in the templates so you just need to populate the signer details like name and email in creating an envelope and/or pre-populate the DS Tabs value. But when you send document as base64, then you need to tell DocuSign how to add DS Tabs on the document, either by using
X and Y position of the tabs
AnchorString
PDF Field Transformation
Embedded Signing is a type of signing, to implement that you need to just add clientUserId in the signers details. This can be done in both ways either by using template or by passing document as base64 or both as well using Composite Template. Once you have an embedded signer by adding clientUserId then you need to generate signing URL as explained in your qs, by using Recipient View URL, as soon as URL is generated then you will open this URL in IFrame or on new tab.
In the link which you shared is having very small code snippet and it does not have complete example, check Complete Example, and you will see that they are adding DS Tabs on the document using X/Y position.

Related

Can't download Docusign document when envelope name has quotes

I'm using the Docusign API (via the ruby docusign_rest gem) and repro'd this using Postman.
I have an envelope whose name has quotes in it. When I tried to download the signed PDF, I get an error message:
https://www.docusign.net/restapi/v2/accounts/{account_id}/envelopes/{envelope_id}/documents/1
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "The format of value 'file; filename=\"My filename (\"MF\") has quotes.pdf\"; documentid=\"1\"' is invalid."
}
When I list the documents, it shows the name of the envelope having quotes.
https://www.docusign.net/restapi/v2/accounts/{account_id}/envelopes/{envelope_id}/documents
{
"envelopeId": "{envelope_id}",
"envelopeDocuments": [
{
"documentId": "1",
"name": "My filename (\"MF\") has quotes.pdf",
"type": "content",
"uri": "/envelopes/{envelop_id}/documents/1",
etc...
}
}
I can change my code to prevent quotes for new documents, but I have existing signed documents that I can't download. How can I download them? Or fix them?
You will need to properly escape the quotes in your json.
The only way to know what is really happening is to see the api logs.
Added
To see the api logs, you have two choices:
See the instructions
Use the API Logging Feature of the new (still beta) Recipe tool. has a more convenient interface to the API Logger.
Using the current docusign_rest release (v0.3.1) I was able to create an envelope with a quote in the document's filename and then download that document:
client = DocusignRest::Client.new
res = client.create_envelope_from_document(email: {subject: "test email subject",body: "this is the email body and it's large!"}, signers: [{embedded: true, name: 'Joe Dimaggio', email: 'joe.dimaggio#example.org', role_name: 'Issuer',sign_here_tabs: [{anchor_string: 'sign here',anchor_x_offset: '-30',anchor_y_offset: '35'}]},], files: [{path: '/Users/tomcopeland/github.com/docusign_rest/test".pdf', name: 'test".pdf'},],status: 'sent')
client.get_document_from_envelope(envelope_id: res['envelopeId'], document_id: "1", local_save_path: "/tmp/foobar.pdf")
client.get_documents_from_envelope(envelope_id: res['envelopeId'])["envelopeDocuments"].map {|d| d["name"] }
=> ["test\".pdf", "Summary"]
Also, this latest release supports call logging so, if needed, you can extract logs client-side.

Pre-populating Template Tabs with REST API

Trying to pre-populate some fields before sending an envelope using a template in my account, but when the signer/recipient receives the link to the document in their email, the fields are left blank. Here's a portion of the JSON I'm using to make the request in the API:
var body = JSON.stringify({
"emailSubject": "DocuSign API call - Request Signature",
"templateId": templateId,
"templateRoles": [{
"email": recipientEmail,
"name": recipientName,
"roleName": templateRoleName,
"tabs": {
"companyTabs": [
{
"tabLabel": "\\*SignerCompany",
"value": recipientCompany
},
],
"titleTabs": [
{
"tabLabel": "\\*SignerTitle",
"value": recipientTitle
}
]
}
}],
"status": "sent", ....
So the company and title tabs with the labels "SignerCompany" and "SignerTitle" aren't being pre-filled for the recipient. I've tried changing font colors and other things and those seem to work, but somehow the value just doesn't.
I've viewed many similar problems with trying to pre-populate these templates but haven't been able to figure it out. Any help is much appreciated!
This was just asked (and answered) in another recent Stack Overflow post. The issue is that you can not set the company and title tabs in particular (they are read-only).
The system populates their data based on the user's account profile, so if no profile or no data in their profile they'll show up as blank as you're seeing.
See this post for a more detailed answer: https://stackoverflow.com/a/38009218/1968395

DocuSign API - create envelopes using composite templates

I would like to create envelopes using static/composite templates. I have created template, roles and have
configured tags related to the roles into my DocuSign account. I also have retrieved the templateid
of this template to reference this template from API call.
Is there a way to overlay the document from the template with another document at runtime using an
API call?
I tried doing the same using the API Explorer(using REST based API call) but instead of overlaying the
document, it got appended to the document from the template.
My main reason of doing this is to use the tags for recipient roles so that at run time, I do
not need configure the tags for the recipients. In my case, the recipient tags remain the same
for all the recipients/envelopes but the document changes every time I create an envelope.
Please advise,
Yes you can do this. Composite templates are the way to go. When you make the call, create a single composite template structure which references both the server-side template and your document. The inlineTemplate with your document should be in sequence 1 whereas your serverTemplate should be in sequence 2. E.g.:
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject":"DocuSign API - Composite Templates",
"emailBlurb":"Composite Templates Sample 1",
"status":"sent",
"compositeTemplates":[
{
"compositeTemplateId": "1",
"inlineTemplates":[
{
"sequence":"1",
"recipients":{
"signers":[
{
"email":"me#u.them",
"name":"My Signer",
"recipientId":1,
"roleName":"Signer1",
"tabs":{
"textTabs":[
{
"tabLabel":"NDACompany",
"value":"ACME Co USA"
}
]
}
}
]
},
"documents": [
{
"documentId": "1",
"name": "Test Doc.txt"
}
]
}
],
"serverTemplates":[
{
"sequence":"2",
"templateId":"83A07CB0-CF0C-4823-B68A-42EE983F301A"
}
]
}
]
}
--f6e755d3-bbcf-44e5-b276-8ae626f97220
Content-Type: text/plain
Content-Disposition: file; filename="Test Doc.txt"; documentid=1; compositeTemplateId=1
Howdy. Please sign!
--f6e755d3-bbcf-44e5-b276-8ae626f97220--

Docusign API Invalid email address error with signature from document request with inPersonSigner recipient type

I'm currently testing an API call that will ultimately allow for an agent to provide signature and another party to sign in person. In sending the call via API Explorer I continue to receive the following response:
{
"errorCode": "INVALID_EMAIL_ADDRESS_FOR_RECIPIENT",
"message": "The email address for one of the recipients is not valid."
}
I've read in the REST API guide that this needs to be enabled for my account; it may be that my demo dev account does not have this enabled. I just need to verify whether or not that I'm not omitting any essential parameters in this call. I've tried passing in my email (as the account holder) and still receive this error. Here is my request body JSON:
{
"emailBlurb": "test",
"emailSubject": "test",
"documents": [
{
"name": "ChiropractorPlusApplication.pdf",
"documentId": "1"
}
],
"recipients": {
"inPersonSigners": [
{
"hostName": "Joe Host",
"recipientId": "1",
"name": "Name",
"email": "host#gmail.com",
"signerName": "Insured"
}
]
},
"status": "sent"
}
Thanks!
I believe you have found a bug with the REST API Explorer in that it's missing at least one field for In Person Signers. If you look at the REST API documentation you'll see that there's one more required parameter for In Person Signers, which is the hostEmail
Try adding to your JSON
"hostEmail" : "host's email address",
And I have a feeling that will do the trick. See page 275 of REST API v2 PDF for info on In Person Signers recipient type. It first shows a sample request with all the options then below that it lists the required fields for this recipient type:
http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf

Docusign: Dynamically Populate Fields In Document

I am using docusign to send off vendor agreements. The agreements are all the same wording, except for vendor name and address. Is there a way I can pass information to the envelope creation script (PHP) to dynamically populate name and address fields on a template document?
Yes you can definitely populate tabs in an embedded signing view. This is all controlled through the
tabLabel
property of each tab in your request body. For instance, if you login to the DocuSign Console and add two data fields (textTabs) to your envelope where one has the label "email" and the other has a label of "address" then the following JSON body prefills those tabs based on the value passed.
"tabs": {
"textTabs": [
{
"tabLabel": "address",
"value": "123 Main St. SF, CA"
},
{
"tabLabel": "email",
"value": "sample#email.com"
}
]
}
}
],
"status": "sent"
}

Resources