Docusign API server templates local docs and tabs - docusignapi

I'm working on a DocuSign integration. I have the basics functional but can't seem to figure out how to merge a local document (PDF) with a server template such that tabs configured on the server template get used or overlaid on the passed document.
My template is defined on the server and I can use it directly from the web UI without issue (it's a W4 form). The template has three tabs (SSN, Sign here, and date) as you can see below. Accessing this template via it's ID using the API Explorer yields the following json
{
"envelopeTemplateDefinition": {
"templateId": "_redacted_",
"name": "W4 3/13/2017",
"shared": "true",
"password": "",
"description": "",
"lastModified": "2017-06-05T18:45:28.4470000Z",
"lastModifiedBy": {
"userName": "Andrew",
"userId": "_redacted_",
"email": "my_email_address",
"uri": "/users/_redacted_
},
"pageCount": 2,
"uri": "/templates/_redacted_",
"folderName": "Templates",
"folderId": "_redacted_",
"folderUri": "/folders/_redacted_",
"owner": {
"userName": "Andrew",
"userId": "_redacted_",
"email": "my_email_address"
}
},
"documents": [
{
"documentId": "46677269",
"uri": "/envelopes/_redacted_/documents/46677269",
"name": "W4.pdf",
"order": "1",
"pages": "2",
"display": "inline",
"includeInDownload": "true",
"signerMustAcknowledge": "no_interaction",
"templateLocked": "false",
"templateRequired": "false",
"documentGroup": "content"
}
],
"emailSubject": "Please DocuSign: W4.pdf",
"emailBlurb": "",
"signingLocation": "online",
"autoNavigation": "true",
"envelopeIdStamping": "true",
"authoritativeCopy": "false",
"notification": {
"reminders": {
"reminderEnabled": "false",
"reminderDelay": "0",
"reminderFrequency": "0"
},
"expirations": {
"expireEnabled": "true",
"expireAfter": "120",
"expireWarn": "0"
}
},
"enforceSignerVisibility": "false",
"enableWetSign": "true",
"allowMarkup": "false",
"allowReassign": "true",
"recipients": {
"signers": [
{
"defaultRecipient": "false",
"tabs": {
"signHereTabs": [
{
"stampType": "signature",
"name": "SignHere",
"tabLabel": "Signature _redacted_",
"scaleValue": 1.0,
"optional": "false",
"documentId": "46677269",
"recipientId": "94043042",
"pageNumber": "1",
"xPosition": "193",
"yPosition": "682",
"tabId": "_redacted_",
"templateLocked": "false",
"templateRequired": "false"
}
],
"dateSignedTabs": [
{
"name": "DateSigned",
"value": "",
"tabLabel": "Date Signed _redacted_",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size9",
"documentId": "46677269",
"recipientId": "94043042",
"pageNumber": "1",
"xPosition": "480",
"yPosition": "713",
"tabId": "_redacted_",
"templateLocked": "false",
"templateRequired": "false"
}
],
"ssnTabs": [
{
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"requireAll": "false",
"value": "",
"width": 144,
"required": "true",
"locked": "false",
"concealValueOnDocument": "true",
"disableAutoSize": "false",
"maxLength": 4000,
"tabLabel": "Text _redacted_",
"font": "lucidaconsole",
"fontColor": "black",
"fontSize": "size9",
"documentId": "46677269",
"recipientId": "94043042",
"pageNumber": "1",
"xPosition": "442",
"yPosition": "563",
"tabId": "_redacted_",
"templateLocked": "false",
"templateRequired": "false"
}
]
},
"signInEachLocation": "false",
"name": "",
"email": "",
"recipientId": "94043042",
"accessCode": "",
"requireIdLookup": "false",
"routingOrder": "1",
"note": "",
"roleName": "New Employee",
"deliveryMethod": "email",
"templateLocked": "false",
"templateRequired": "false",
"inheritEmailNotificationConfiguration": "false"
}
],
"agents": [ ],
"editors": [ ],
"intermediaries": [ ],
"carbonCopies": [ ],
"certifiedDeliveries": [ ],
"inPersonSigners": [ ],
"recipientCount": "1"
}
}
What I want to do is apply this template to a PDF that's already partially filled out such that when the signer get's it the tabs defined in the server template are used for the sining.
As it stands now, there's nothing. Just the partially filled out PDF I passed in below as base64 data, with none of the server template tabs to fill out or sign. Here's my json for the API call (in PHP).
$data = array (
"emailBlurb" => "Test Email Body",
"emailSubject" => "Test Email Subject",
"status" => "sent",
"compositeTemplates" => array(array(
"document" => array(
"documentId" => 46677269,
"name" => $documentName,
"documentBase64" => $document
),
"serverTemplates" => array(array(
"sequence" => 1,
"templateId" => "_redacted_"
)),
"inlineTemplates" => array(array(
"sequence" => 2,
"recipients" => array(
"signers" => array(array(
"email" => $recipientEmail,
"name" => $recipientName,
"recipientId" => $recipientID,
"roleName" => "New Employee"
))
)
))
))
); //$data = array...
I suspect that I'm simply missing some appropriate reference to the tabs defined in the server template. But documentation is atrocious and I've already spent several hours combing the web. Any help would be much appreciated.
UPDATE1
As requested, here's the code that generates the envelope successfully:
function c_requestSignature($templateID, $recipientName, $recipientEmail, $recipientID, $document){
//function sets up the passed document for signing using the specified template
$documentName = "W4"; //FIXME fetch document name using templateID
$baseURL = c_docusignBaseURL();
$accountId = c_docusignAccountId();
$header = c_docusignHeader();
$data = array (
"emailSubject" => "Please sign " . $documentName,
//"emailBlurb" => "Test Email Body",
"status" => "sent",
"compositeTemplates" => array(
"compositeTemplate" => array(
"serverTemplates" => array(
"serverTemplate" => array(
"sequence" => "1",
"templateId" => "_redacted_"
)
),
"inlineTemplates" => array(
"inlineTemplate" => array(
"sequence" => "2",
"recipients" => array(
"signers" => array(
"signer" => array(
"name" => $recipientName,
"email" => $recipientEmail,
"roleName" => "NewHire"
)
)
)
)
),
"document" => array(
"documentId" => "1",
"name" => $documentName,
"fileExtension" => "pdf",
"documentBase64" => $document
)
)
)
);
// Send to the /envelopes end point, which is relative to the baseUrl received above.
$curl = curl_init($baseURL . "/envelopes" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl); // Do it!
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "Error calling DocuSign, status is:" . $status . "\nerror text: ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];
error_log ("successfully created envelope: $envelopeId");
$url = getSignatureURL($envelopeId, $recipientName, $recipientEmail, $recipientID);
return $url;
}//c_requestSignature()...
The function getSignatureURL() has code as follows:
function getSignatureURL($envelopeId, $recipientName, $recipientEmail, $recipientID){
//function retrieves the signing ceremony UX URL from DocuSign
$baseURL = c_docusignBaseURL();
$accountId = c_docusignAccountId();
$header = c_docusignHeader();
//set up the data we'll send to the Docusign server
$data = array("returnUrl" => "http://_redacted_",
"authenticationMethod" => "none",
"email" => $recipientEmail,
"name" => $recipientName,
"recipientId" => $recipientID,
//"recipientId" => "1",
//"clientUserId" => $recipientID,
"userName" => $recipientName
);
$data_string = json_encode($data);
//set up curl
$curl = curl_init($baseURL . "/envelopes/$envelopeId/views/recipient" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
"X-DocuSign-Authentication: $header" )
);
//make the API call
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 201 ) {
echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
print_r($json_response); echo "\n";
exit(-1);
}
//retrieve and process the response
$response = json_decode($json_response, true);
return $response["url"];
}
UPDATE 2
Here's the raw json as requested...
{
"emailSubject": "some subject",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "_redacted_"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "Andrew Tester1",
"email": "my_email_address",
"roleName": "NewHire",
"recipientId": "1234",
"clientUserId": "1234"
}
]
}
}
],
"document": {
"documentId": "1",
"name": "W4",
"fileExtension": "pdf",
"documentBase64": "_redacted_"
}
}
]
}
Update 3
I had a problem which was preventing me from seeing the proper output of the above json. With that fixed, now I'm getting the following error:
Error calling DocuSign, status is:400 error text: { "errorCode":
"TAB_REFERS_TO_MISSING_DOCUMENT", "message": "The DocumentId specified
in the tab element does not refer to a document in this envelope. Tab
refers to DocumentId 46677269 which is not present." }
If I change the document stanza above as follows:
"document": {
"documentId": "46677269",
"name": "W4",
"fileExtension": "pdf",
"documentBase64": "_redacted_"
}
The error goes away, but I still get a signing ceremony with no tabs.

The following request can be used to create an envelope from the Server Template. The server templates document will be replaced with the new document that is specified in the request.
{
"emailSubject": "Test Email Subject",
"emailBlurb" : "Test Email Body",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "86841739-f12d-460e-9807-23a9b90cff6b"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Jane Doe",
"email": "janedoe#acme.com",
"roleName": "New Employee"
}
]
}
}
],
"document": {
"documentId": "1",
"name": "Your Doc Name",
"fileExtension": "pdf",
"documentBase64": ""
}
}
]
}

Well this was a thorny problem, but I found the solution (finally), with some help form the folk at Docusign. I thought I'd post it here for those who might run into this in the future.
Solution
The json structure passed to the DocuSign API is extremely important. If there are any errors in it at all, it won't work right, and the error message is not always helpful. Furthermore, in what I was doing, the specific parameters passed were also crucial. The envelope generation code above is correct, though with the caveat that you must specify the PDF document ID that is part of the template stored on DocuSign's servers. You can query this via their API given the envelope ID (which is what I'm doing). Apparently this didn't use to be required, but now it is and there's no documentation anywhere stating that.
My fundamental problem with the signature tabs though, was the code requesting the signing ceremony URL. I had extra parameters which were being accepted without error, but were messing things up. Discovered this, by using DocuSign's REST API explorer to generate a working signing ceremony URL (complete with all the proper signature tabs), and comparing the output json whith what I was trying to pass in my code.
Here's the working PHP code that generates the correct json:
$data = array(
"authenticationMethod" => "email",
"clientUserId" => $recipientID,
"email" => $recipientEmail,
"returnUrl" => "_redacted_",
"userName" => $recipientName
);
$data_string = json_encode($data);

Related

Docusign API Explorer not pre-populating fields

I tried filling in the tabs with labels and values, but when I send the request the tabs are not pre-populated, also does anyone know how does the fullname tab get populated?
{
"emailSubject": "Welcome to Soul Gym",
"status": "sent",
"templateId": "196b0d27-b967-4380-bb2c-013051ec9e45",
"templateRoles": [
{
"clientUserId": "marcus.yeo#business.edu.sg",
"email": "marcus.yeo#business.edu.sg",
"name": "Marcus Yeo",
"roleName": "New Member",
"tabs": {
"emailTabs": [
{
"tabLabel": "Email",
"value": "marcus.yeo#business.edu.sg"
}
],
"fullNameTabs": [
{
"tabLabel": "FullName"
},
{
"tabLabel": "FullName2"
}
],
"textTabs": [
{
"tabLabel": "Address",
"value": "32 Duke Road"
}
]
}
}
]
It looks like you're missing the documentId and tabPositions to display the full name on your document. Here is an example working request body with raw document omitted:
{
"documents": [
{
"documentBase64": "<Base64BytesHere>",
"documentId": "1",
"fileExtension": "docx",
"name": "testFile"
}
],
"emailSubject": "testing envelope",
"recipients": {
"signers": [
{
"email": "john.doe#example.com",
"name": "Docusign Test Signer",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"fullNameTabs": [
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "280",
"yPosition": "172"
},
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "480",
"yPosition": "300"
}
],
"signHereTabs": [
{
"documentId": "1",
"pageNumber": "1",
"xPosition": "120",
"yPosition": "300"
}
]
}
}
]
},
"status": "sent"
}
And the resulting fullName placement shown on a demo document I tried with this request json:
Though I didn't use an envelope templateId here, the mechanism works the same, set the documentID, pageNumber, & x/y coordinates to inject the fullName on your documents. Feel free to check out the Quickstart tool as well to find a full DocuSign implementation in a language of your choice that you can modify to suit your needs.

Docusign API - Create envelope, apply template, prefill values

Many questions address portions of my request, but I cannot seem to make a complete solution work. I have created a template on my site (it has various text fields, initial fields, and signature block). Single recipient, using anchor tags for the fields. When I take a .docx file, create an envelope via the api, I want to apply the template previously mentioned, and then prefill 4 text fields on the document/template.
Anchor tags are not placing the fields appropriately.
Any advise/suggestions?
Working request call is:
{
"documents":
[
{
"documentBase64":"<BASE64STREAM>",
"documentId":"3",
"fileExtension":"docx",
"name":"10001000_20170803_FILE"
}
],
"emailSubject": "TEST - Group Audit - 10001000",
"templateId": "TEMPLATE_ID",
"templateRoles" :
[
{
"email": "JDOE#email.com",
"name": "JOHN DOE",
"roleName": "signer1",
"tabs":
{
"textTabs":
[
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupname",
"value": "TEST GROUP ONE"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "groupnumber",
"value": "10001000"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "txt",
"value": "my#email.com"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "fein",
"value": "870142380"
},
{
"documentId": "3",
"recipientId": "1",
"tabLabel": "physicaladdress",
"value": "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
],
"status":"sent"
}
Based on the information you've provided, I understand your scenario to be as follows:
You've created a template via the DocuSign UI; that template contains a 'placeholder' document (which you will replace at run-time via your Create/Send Envlope API call) and defines the recipient(s) and tabs for that document.
When you create/send the envelope via API, you want to specify the document as part of the API request (i.e., to be used instead of the 'placeholder' document that the DocuSign template contains) and also auto-populate some of the tabs that the template defines.
If that's an accurate description of what you're trying to achieve, then you need to use Composite Templates in the API request structure. Here's an example of a Create/Send Envelope JSON request that uses composite templates (and contains data based upon the information you provided in your question):
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "TEMPLATE_ID"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "JOHN DOE",
"email": "JDOE#email.com",
"roleName": "signer1",
"tabs":
{
"textTabs":[
{
"tabLabel" : "groupname",
"value" : "TEST GROUP ONE"
},
{
"tabLabel" : "groupnumber",
"value" : "10001000"
},
{
"tabLabel" : "txt",
"value" : "my#email.com"
},
{
"tabLabel" : "fein",
"value" : "870142380"
},
{
"tabLabel" : "physicaladdress",
"value" : "1 STREET WAY, , MY CITY, CA, 98001"
}
]
}
}
]
}
}
],
"document": {
"documentId": "3",
"name": "10001000_20170803_FILE.docx",
"fileExtension": "docx",
"documentBase64": "BASE64STREAM"
}
}
],
"status": "sent",
"emailSubject": "TEST - Group Audit - 10001000"
}

Docusign API signHere tabs - not converting form fields into tabs

I am trying to convert form fields with name signature_1 and pre-filled value of signature_1.
I have been following this guide:
https://www.docusign.com/developer-center/explore/features/stick-etabs
Here is the issue that i have already written up on the problem: https://github.com/karmaradio/karma/issues/440
Docusign is creating signHere tabs on the contract, but always at the top left, so it isn't recognising the signature_1 form field.
The object i send to docusign:
{
emailBlurb: "Please sign the document using link provided.",
emailSubject: "Karma document sign",
documents: [
{
documentBase64: "encoded",
documentId: 1,
name: "jackum-mur-PAYE-1.pdf",
transformPdfFields: "true"
}
],
recipients: {
signers: [
{
email: "jmurphy+c#gmail.com",
name: "jackum mur",
recipientId: 1,
routingOrder: 1,
tabs: {
signHereTabs: [
{
documentId: "1",
pageNumber: "1",
tabLabel: "signature_1"
}
]
}
},
{
email: "jmurphy+first#gmail.com",
name: "first signee",
recipientId: 2,
routingOrder: 2,
tabs: {
signHereTabs: [
{
documentId: "1",
pageNumber: "1",
tabLabel: "signature_2"
}
]
}
},
{
email: "jmurphy+second#gmail.com",
name: "second signee",
recipientId: 3,
routingOrder: 3,
tabs: {
signHereTabs: [
{
documentId: "1",
pageNumber: "1",
tabLabel: "signature_3"
}
]
}
},
status: "sent"
}
After examining the document you have shared, the following json should covert the form fields appropriately. Looking at the convention of your Tab labels, it is not clear which tabs apply to a particular recipient. So I have manually mapped each tabLabel to a recipient. From my example you can move the tabs based on the correct recipient.
If you want similar tab types to automatically populate with the same data then see here
Here is the CreateEnvelope request.
POST /v2/accounts/{accountId}/envelopes
{
"emailSubject": "Document with Form fields",
"status": "sent",
"compositeTemplates": [
{
"document": {
"documentBase64": "<Add the bas64 encoded document bytes here>",
"documentId": "1",
"name": "p60-form.pdf",
"transformPdfFields": "true"
},
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "jmurphy+c#gmail.com",
"name": "jackum mur",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"signHereTabs": [
{
"tabLabel": "signature_1"
},
{
"tabLabel": "signature_1DocuSignSignHere"
}
],
"textTabs": [
{
"tabLabel": "signature_1 Student Loan deductions",
"value" : "<Pre-Fill Tab Value here>"
},
{
"tabLabel": "Student Loan deductions",
"value" : "<Pre-Fill Tab Value here>"
},
{
"tabLabel": "PAYE reference",
"value" : "<Pre-Fill Tab Value here>"
},
{
"tabLabel": "Your employer's full name and address (including postcode",
"value" : "<Pre-Fill Tab Value here>"
}
]
}
},
{
"email": "jmurphy+first#gmail.com",
"name": "first signee",
"recipientId": "2",
"routingOrder": "2",
"tabs": {
"signHereTabs": [
{
"tabLabel": "signature_2"
},
{
"tabLabel": "signature_2 DocuSignSignHere"
}
],
"textTabs": [
{
"tabLabel": "signature_2",
"value" : "<Pre-Fill Tab Value here>"
},
{
"tabLabel": "signature_2 Your employers full name and address including postcode",
"value" : "<Pre-Fill Tab Value here>"
}
]
}
},
{
"email": "jmurphy+second#gmail.com",
"name": "second signee",
"recipientId": "3",
"routingOrder": "3",
"tabs": {
"signHereTabs": [
{
"tabLabel": "signature_3"
},
{
"tabLabel": "signature_3 DocuSignSignHere"
}
],
"textTabs": [
{
"tabLabel": "signature_3 PAYE reference",
"value" : "<Pre-Fill Tab Value here>"
}
]
}
}
]
}
}
]
}
]
}

Custom message body for each recipient in docusign

I am using a demo account of Docusign integrating with force.com sites using Apex.
I created a template and want to send two different mail body to two different recipient. I have two roles Agent and Broker.
In Broker mail body I want to use Agent Recipient Name. I can get the name in subject by using [[Agent_UserName]] but not in body. Is there any way to use Merge fields in Mail body.
Merge fields are not supported in the email Body.
Here is a sample CreateEnvelope request to send unique Email Subject/Body per recipient. You will have to add the emailNotification property for each recipient
{
"status": "created",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "recipient one",
"email": "recipientone#acme.com",
"routingOrder": "1",
"recipientId" : "1",
"roleName" : "texter",
"tabs": {
"textTabs" : [
{
"xPosition" : "100", "yPosition" : "100", "documentId" : "1","pageNumber" : "1"
}
]
},
"emailNotification": {
"emailSubject": "subject for one",
"emailBody": "Body for One",
"supportedLanguage": "en"
}
},
{
"name": "Jane Doe",
"email": "janedoe#acme.com",
"routingOrder": "2",
"recipientId" : "2",
"roleName" : "signer",
"tabs": {
"signHereTabs" : [
{
"xPosition" : "100", "yPosition" : "200", "documentId" : "1", "pageNumber" : "1"
}
]
},
"emailNotification": {
"emailSubject": "subject for two",
"emailBody": "Body for two",
"supportedLanguage": "en"
}
}
]
},
"documents": [
{
"documentId": "1",
"name": "Contract",
"fileExtension": "txt",
"documentBase64": "RG9jIFRXTyBUV08gVFdP"
}
]
}
]
}
]
}

DocuSign REST API - can't control Document Visibility on Envelopes from Documents?

The Docusign REST API describes a way to control document visibility when creating envelopes from documents:
https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/
The option is enforceSignerVisibility. However when I attempt to use this option, the visibility is NOT limited. Am I doing something wrong?
I am using a modified version of the PHP DocuSign helper library (some features/options added).
Here is a test case I created. In this case, there are two signers and two documents. Signer 1 has a signature on Document 1 and Signer 2 has a signature on Document 2. The goal is that Signer 1 would only see Document 1 and Signer 2 would only see Document 2. However, the below example results in both signers seeing both documents:
Code
<?php
$client = new DocuSign_Client;
$service = new DocuSign_RequestSignatureService($client);
$documents = array(
new DocuSign_Document(
"TestDoc1",
1,
file_get_contents( $_SERVER['DOCUMENT_ROOT'].'/sandbox/ncg/test1.pdf' )
),
new DocuSign_Document(
"TestDoc2",
2,
file_get_contents( $_SERVER['DOCUMENT_ROOT'].'/sandbox/ncg/test2.pdf' )
)
);
$signer1 = new DocuSign_Recipient(
1,
1,
"Signer 1",
"test.tfcornerstone+t1#gmail.com",
NULL
);
$signer1->setTab("signHereTabs",array(
"anchorYOffset" => "0",
"anchorXOffset" => "0",
"anchorString" => "[__[Signer1]__]",
"anchorIgnoreIfNotPresent" => true,
) );
$signer2 = new DocuSign_Recipient(
1,
2,
"Signer 2",
"test.tfcornerstone+t2#gmail.com",
NULL
);
$signer2->setTab("signHereTabs",array(
"anchorYOffset" => "0",
"anchorXOffset" => "0",
"anchorString" => "[__[Signer2]__]",
"anchorIgnoreIfNotPresent" => true,
) );
$recipients = array( $signer1, $signer2 );
$emailSubject = "Test Doc";
$emailBlurb = "Testing Visibility";
$status = 'sent'; // can be "created" or "sent"
$eventNotifications = new DocuSign_EventNotification(
$url, //url
false, //loggingEnabled
false, //requireAcknowledgment,
false, //useSoapInterface,
NULL, //soapNameSpace,
false, //includeCertificateWithSoap,
false, //signMessageWithX509Cert,
false, //includeDocuments,
false, //includeTimeZone,
false, //includeSenderAccountAsCustomField,
NULL, //envelopeEvents,
array( "Completed", "Sent" ) //recipientEvents
);
$options = array(
"enforceSignerVisibility" => true,
);
$response = $service->signature->createEnvelopeFromDocument(
$emailSubject,
$emailBlurb,
$status,
$documents,
$recipients,
$eventNotifications,
$options
);
d($response);
CURL request
Url: https://www.docusign.net/restapi/v2/accounts/XXXXX/envelopes
Method: POST
Headers:
--myboundary
Content-Type: application/json
Content-Disposition: form-data
{"emailSubject":"Test Doc","emailBlurb":"Testing Visibility","documents":[{"name":"TestDoc1","documentId":1},{"name":"TestDoc2","documentId":2}],"status":"sent","enforceSignerVisibility":true,"recipients":{"signers":[{"routingOrder":1,"recipientId":1,"name":"Signer 1","email":"test.tfcornerstone+t1#gmail.com","clientUserId":null,"tabs":{"signHereTabs":[{"anchorYOffset":"0","anchorXOffset":"0","anchorString":"[__[Signer1]__]","anchorIgnoreIfNotPresent":true}]},"embeddedRecipientStartUrl":null,"excludedDocuments":null},{"routingOrder":1,"recipientId":2,"name":"Signer 2","email":"test.tfcornerstone+t2#gmail.com","clientUserId":null,"tabs":{"signHereTabs":[{"anchorYOffset":"0","anchorXOffset":"0","anchorString":"[__[Signer2]__]","anchorIgnoreIfNotPresent":true}]},"embeddedRecipientStartUrl":null,"excludedDocuments":null}]},"eventNotification":{"loggingEnabled":false,"requireAcknowledgment":false,"useSoapInterface":false,"includeCertificateWithSoap":false,"signMessageWithX509Cert":false,"includeDocuments":false,"includeTimeZone":false,"includeSenderAccountAsCustomField":false,"recipientEvents":[{"recipientEventStatusCode":"Completed"},{"recipientEventStatusCode":"Sent"}]}}
<<PDF CONTENT>>--myboundary--
Formatted JSON data
{
"emailSubject": "Test Doc",
"emailBlurb": "Testing Visibility",
"documents": [
{
"name": "TestDoc1",
"documentId": 1
},
{
"name": "TestDoc2",
"documentId": 2
}
],
"status": "sent",
"enforceSignerVisibility": true,
"recipients": {
"signers": [
{
"routingOrder": 1,
"recipientId": 1,
"name": "Signer 1",
"email": "test.tfcornerstone+t1#gmail.com",
"clientUserId": null,
"tabs": {
"signHereTabs": [
{
"anchorYOffset": "0",
"anchorXOffset": "0",
"anchorString": "[__[Signer1]__]",
"anchorIgnoreIfNotPresent": true
}
]
},
"embeddedRecipientStartUrl": null,
"excludedDocuments": null
},
{
"routingOrder": 1,
"recipientId": 2,
"name": "Signer 2",
"email": "test.tfcornerstone+t2#gmail.com",
"clientUserId": null,
"tabs": {
"signHereTabs": [
{
"anchorYOffset": "0",
"anchorXOffset": "0",
"anchorString": "[__[Signer2]__]",
"anchorIgnoreIfNotPresent": true
}
]
},
"embeddedRecipientStartUrl": null,
"excludedDocuments": null
}
]
},
"eventNotification": {
"loggingEnabled": false,
"requireAcknowledgment": false,
"useSoapInterface": false,
"includeCertificateWithSoap": false,
"signMessageWithX509Cert": false,
"includeDocuments": false,
"includeTimeZone": false,
"includeSenderAccountAsCustomField": false,
"recipientEvents": [
{
"recipientEventStatusCode": "Completed"
},
{
"recipientEventStatusCode": "Sent"
}
]
}
}
I don't believe DocVis can be set to "Off" in order to enforce it in the API. In Preferences -> Features change the DocVis dropdown to "Sender Can Set Must Sign To View Unless Sender Account" and give the same request another shot.

Resources