We are working with docusign Composite Template API with PHP. We Tried to add a custom document with base64 encoded format with signHereTabs object with values. We are able to create envelope and views for recipient successfully.But the issue is it's not generating signHereTabs which we are tried for recipient. Can you please help us to resolve this issue? Sample Request in json to create envelope:
{
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"clientUserId": "1000",
"name": "Full Name",
"email": "my email",
"recipientId": "1",
"roleName": "Sender",
"tabs": {
"signHereTabs": [
{
"anchorString": "\/sig1\/",
"anchorUnits": "pixels",
"anchorXOffset": "20",
"anchorYOffset": "10"
}
]
}
}
]
},
"customFields": {
"textCustomFields": [
{
"name": "MyOwnField",
"required": "true",
"show": "true",
"value": "MyValue"
}
]
}
}
],
"document": {
"documentBase64": "<base64 encoded string>",
"documentId": "1",
"fileExtension": "pdf",
"name": "Agreement.pdf",
"transformPdfFields": false
}
}
]
}
View Recipient sample request:
{
"document": {
"documentBase64": "<base64 encoded string>",
"documentId": "1",
"fileExtension": "pdf",
"name": "Agreement.pdf",
"transformPdfFields": false
}
}
The fields (tabs) need to be a part of the signers object.
Here's a working example from the API Request Builder:
{
"emailSubject": "Please sign the attached document",
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"document": {
"filename": "anchorfields.pdf",
"name": "Example document",
"fileExtension": "pdf",
"documentId": "1"
},
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "[email protected]",
"name": "Signer's name",
"recipientId": "1",
"clientUserId": "1000",
"tabs": {
"signHereTabs": [
{
"anchorString": "/sig1/",
"anchorXOffset": "20",
"anchorUnits": "pixels"
}
]
}
}
]
}
}
]
}
]
}
Here it is with the PHP SDK (auto-generated by the API Request Builder):
<?php # DocuSign Builder example. Generated: Sat, 03 Sep 2022 18:34:12 GMT
# DocuSign ?�? 2022. MIT License -- https://opensource.org/licenses/MIT
# @see <a href="https://developers.docusign.com">DocuSign Developer Center</a>
require_once ('vendor/autoload.php');
require_once ('vendor/docusign/esign-client/autoload.php');
# Note: the access_token is for testing and is temporary. It is only good for 8 hours from the time you
# authenticated with API Request Builder.
const base_uri = 'https://demo.docusign.net/';
const access_token = '';
const account_id = '';
const document_directory = '.'; # The directory with your documents, relative to this script's directory
#
function sendDocuSignEnvelope() {
$docs_path = getcwd() . '/' . document_directory . '/';
$document1 = new \DocuSign\eSign\Model\Document([
'document_id' => "1",
'file_extension' => "pdf",
'document_base64' => base64_encode(file_get_contents($docs_path.'anchorfields.pdf')), # filename is anchorfields.pdf
'name' => "Example document"
]);
$sign_here_tab1 = new \DocuSign\eSign\Model\SignHere([
'anchor_string' => "/sig1/",
'anchor_units' => "pixels",
'anchor_x_offset' => "20"
]);
$sign_here_tabs1 = [$sign_here_tab1];
$tabs1 = new \DocuSign\eSign\Model\Tabs([
'sign_here_tabs' => $sign_here_tabs1
]);
$signer1 = new \DocuSign\eSign\Model\Signer([
'client_user_id' => "1000",
'email' => "[email protected]",
'name' => "Signer's name",
'recipient_id' => "1",
'tabs' => $tabs1
]);
$signers1 = [$signer1];
$recipients1 = new \DocuSign\eSign\Model\Recipients([
'signers' => $signers1
]);
$inline_template1 = new \DocuSign\eSign\Model\InlineTemplate([
'recipients' => $recipients1,
'sequence' => "1"
]);
$inline_templates1 = [$inline_template1];
$composite_template1 = new \DocuSign\eSign\Model\CompositeTemplate([
'composite_template_id' => "1",
'document' => $document1,
'inline_templates' => $inline_templates1
]);
$composite_templates1 = [$composite_template1];
$envelope_definition = new \DocuSign\eSign\Model\EnvelopeDefinition([
'composite_templates' => $composite_templates1,
'email_subject' => "Please sign the attached document",
'status' => "sent"
]);
try {
$config = new \DocuSign\eSign\Configuration();
$config->setHost(base_uri . 'restapi');
$config->addDefaultHeader('Authorization', 'Bearer ' . access_token);
$api_client = new \DocuSign\eSign\Client\ApiClient($config);
$envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
$result = $envelope_api->createEnvelope(account_id, $envelope_definition);
$envelope_id = $result->getEnvelopeId();
printf("\nEnvelope status: %s. Envelope ID: %s\n", $result->getStatus(), $result->getEnvelopeId());
return $envelope_id;
} catch (Exception $e) {
printf ("\n\nException from createEnvelope!\n%s", $e->getMessage());
if ($e instanceof DocuSign\eSign\Client\ApiException) {
printf ("\nAPI error information: \n%s", $e->getResponseBody());
}
return FALSE;
}
}
function recipientView ($envelope_id) {
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest([
'authentication_method' => "None",
'client_user_id' => "1000",
'email' => "[email protected]",
'return_url' => "https://docusign.com",
'user_name' => "Signer's name"
]);
if (!$recipient_view_request || !$envelope_id) {return;}
try {
$config = new \DocuSign\eSign\Configuration();
$config->setHost(base_uri . 'restapi');
$config->addDefaultHeader('Authorization', 'Bearer ' . access_token);
$api_client = new \DocuSign\eSign\Client\ApiClient($config);
$envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
$result = $envelope_api->createRecipientView(account_id, $envelope_id,
$recipient_view_request);
print ("\nCreate recipient view succeeded.");
printf ("Open the signing ceremony's long URL within 5 minutes: \n%s\n\n", $result->getUrl());
} catch (Exception $e) {
printf ("\n\nException from createRecipientView!\n%s", $e->getMessage());
if ($e instanceof DocuSign\eSign\Client\ApiException) {
printf ("\nAPI error information: \n%s", $e->getResponseBody());
}
}
}
# The mainline
$envelope_id = sendDocuSignEnvelope();
recipientView($envelope_id);
print("Done.\n");
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.