is there any way to create a template using docusign api - docusignapi

i am using the rest api (in php-codeigniter) for docusign. Currently i am creating templates from demo.docusign.net. Is there any API call to create a docusign template from my site by uploading a document ?

Yes,
The VERB is POST and the URI is {vx}/accounts/{accountid}/templates
Documentation Here
The DocuSign REST API Operations is at https://www.docusign.net/restapi/help#
Also the endpoint information is covered in this other Stack Overflow Question What WSDL URL to use for SOAP using Sandbox account?
The DocuSign Online Help Documentation is at https://docs.docusign.com/esign

Here is my solution from this post here. I uploaded an HTML file as a template for the signature document. This will able to give you an idea how to upload files as template.
// set recipient information
$recipientName = "";
$recipientEmail = "";
// configure the document we want signed
$documentFileName = "/../document.html";
$documentName = "document.html";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($this->getApiClient());
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName)));
$document->setName($documentName);
$document->setFileExtension('html');
$document->setDocumentId("2");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setXPosition("100");
$signHere->setYPosition("100");
$signHere->setDocumentId("2");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId("1234"); // must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Please sign this doc");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
echo "$envelop_summary\n";
If you need more in depth information you can visit the docusign page.

In case it isn't clear, you can also upload a document when creating an envelope via the API. Thus you can bypass creating a template if you don't actually need one.

Related

How to send document to client's more than one personal email ids to sign it using DocuSignAPI .NET Client?

I've setup a developer sandbox environment of DocuSign. Using its C#.NET API Client, I want to send a document for signing to client's more than one personal email ids. Once the client opens any email to see and sign it, the corresponding DocuSign envelope state should get updated to Completed.
Also, I tried to achieve the above behavior through multiple signer recipients, but the envelope state gets marked completed, when all the signer recipients sign the document. Here I want any signer recipient sign should be enough to complete the document signing workflow.
Please suggest how to get it done
Regards,
A
In order to deliver an envelope to several emails in a single role, you'll need to create a Signing Group. Signing Groups can be created and managed through the API, so you'll be able to do that programatically.
While you'll need to implement your own business logic and error checking, a sample of creating a Signing Group in c# looks like:
SigningGroup signingGroup = new SigningGroup();
signingGroup.GroupName = "SigningGroup_" + DateTime.UtcNow.Ticks.ToString();
signingGroup.GroupType = "sharedSigningGroup";
signingGroup.Users = new List<SigningGroupUser>();
SigningGroupUser signingGroupUser1 = new SigningGroupUser();
signingGroupUser1.UserName = "Example Signer";
signingGroupUser1.Email = "signer#example.com";
signingGroup.Users.Add(signingGroupUser1);
SigningGroupUser signingGroupUser2 = new SigningGroupUser();
signingGroupUser2.UserName = "Example Signer";
signingGroupUser2.Email = "personal.email#example.com";
signingGroup.Users.Add(signingGroupUser2);
SigningGroupInformation signingGroupInformation = new SigningGroupInformation();
signingGroupInformation.Groups = new List<SigningGroup> { signingGroup };
SigningGroupsApi signingGroupsApi = new SigningGroupsApi(apiClient.Configuration);
SigningGroupInformation newGroupInfo = signingGroupsApi.CreateList(accountId, signingGroupInformation);
string newGroupId = newGroupInfo.Groups[0].SigningGroupId;
To use the Signing Group in an envelope, define a signer with that group ID:
Signer signer = new Signer
{
SigningGroupId = newGroupId,
RecipientId = "1",
RoutingOrder = "1"
};
Once the envelope is created as a draft, you can then clean up the signing group:
signingGroupsApi.DeleteList(accountId, newGroupInfo);

DocuSign API - How do I make the signer receives a copy of the signed document

I have this thing working for like 2 years. Then it stopped sending emails to the signers after they signed a document. By the way the document is created from a widget embedded method.
I'm using the PHP SDK of the docusign API. And here's a summary of my code
$envelopeApi = new \DocuSign\eSign\Api\EnvelopesApi($apiClient);
$document = new \DocuSign\eSign\Model\Document();
$document->setDocumentBase64("My document template");
$document->setName("My template name);
$document->setDocumentId("randomly generated document ID");
// creates the sign here
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setAnchorString("Signature:");
$signHere->setAnchorIgnoreIfNotPresent("false");
$signHere->setAnchorUnits("pixels");
$signHere->setAnchorYOffset("50");
$signHere->setAnchorXOffset("5");
$signHere->setDocumentId("The document ID");
$signHere->setRecipientId("The recipient ID, randomly generated");
// add the signature tab to the envelope's list of tabs
$tabs = new \DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add the signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setName("Recipient Name");
$signer->setEmail("Recipient Email");
$signer->setRecipientId("The recipient ID");
$signer->setTabs($tabs);
$signer->setClientUserId("The client user ID");
// Add a recipient to sign the document
$recipients = new \DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new \DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("Mail subject");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelopeApi->createEnvelope("Owner account ID", $envelop_definition, null);
I knew that by adding the envelope definition status "sent" would send a copy to the signer but thats not the case. Did something happened recently on the API that I have to adapt? I checked the documentation but still the same. So I'm not sure if I'm doing the right thing.
Any help would be greatly appreciated. Thanks in advance.
By setting a ClientUserId for your signer, you are creating a Captive Recipient. If you want DocuSign to do email delivery, remove the ClientUserId parameter and a Remote Recipient will be created instead.

Multple signer issue in docusign embedded signing

I'm trying to get 2 user signed with docusign embedded sign. I'm using the example code given by Docusign/github. I'd like that the second user, see that the first user has signed the document so, based ob some explanation here, I try to get the envelope id, when the first signer has signed the document, but i obtain an error. It seems that there is something wrong in the second recipient. Someone would help?
$username_docusign=$config['username_docusign'];
$password_docusign=$config['password_docusign'];
$integrator_key_docusign=$config['integrator_key_docusign'];
$host_docusign=$config['host_docusign'];
// create a new DocuSign configuration and assign host and header(s)
$config = new DocuSign\eSign\Configuration();
$config->setSSLVerification(false);
$config->setHost($host_docusign);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username_docusign . "\",\"Password\":\"" . $password_docusign . "\",\"IntegratorKey\":\"" . $integrator_key_docusign . "\"}");
/////////////////////////////////////////////////////////////////////////
// STEP 1: Login() API
/////////////////////////////////////////////////////////////////////////
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
// we will first make the Login() call which exists in the AuthenticationApi...
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
// optional login parameters
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
// call the login() API
$loginInformation = $authenticationApi->login($options);
// parse the login results
if(isset($loginInformation) && count($loginInformation) > 0)
{
// note: defaulting to first account found, user might be a
// member of multiple accounts
$loginAccount = $loginInformation->getLoginAccounts()[0];
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
echo "Account ID = $accountId\n";
}
}
}
/////////////////////////////////////////////////////////////////////////
// STEP 2: Create & Send Envelope with Embedded Recipient
/////////////////////////////////////////////////////////////////////////
// set recipient information
$recipientName = "user1";
$recipientEmail = "email1";
// configure the document we want signed
$recipientName2 = "user2";
$recipientEmail2 = "email2";
$documentFileName = "hhhh.pdf";
$documentName = "hhhh.pdf";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents($document)));
$document->setName($documentName);
$document->setDocumentId("1");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setAnchorString("Sign here user1");//here my text in html
$signHere->setAnchorXOffset("3");
$signHere->setAnchorYOffset("0");
$signHere->setAnchorUnits("inches");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId('12345');
$signHere2 = new \DocuSign\eSign\Model\SignHere();
$signHere2->setAnchorString("Sign here user2");//here my text in html
$signHere2->setAnchorXOffset("3");
$signHere2->setAnchorYOffset("0");
$signHere2->setAnchorUnits("inches");
$signHere2->setPageNumber("1");
$signHere2->setRecipientId("2");
// add the signature tab to the envelope's list of tabs
$tabs2 = new DocuSign\eSign\Model\Tabs();
$tabs2->setSignHereTabs(array($signHere2));
// add a signer to the envelope
$signer2 = new \DocuSign\eSign\Model\Signer();
$signer2->setEmail($recipientEmail2);
$signer2->setName($recipientName2);
$signer2->setRecipientId("2");
$signer2->setTabs($tabs2);
$signer2->setClientUserId('123456');
// must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer),array($signer2) );
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("oggetto mail");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
/////////////////////////////////////////////////////////////////////////
// STEP 3: Request Recipient View (aka signing URL)
/////////////////////////////////////////////////////////////////////////
// instantiate a RecipientViewRequest object
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest();
// set where the recipient is re-directed once they are done signing
$recipient_view_request->setReturnUrl("http://www.elevationworld.com/adr/embedded.php?iddocumento_firmato=".$_GET['iddocumento']."&idutente_firmato=".$_SESSION['email']."&enevelope=".$envelop_summary->getEnvelopeId());
// configure the embedded signer
if ($_GET['enevelope']=="") {
$recipient_view_request->setUserName($recipientName);
$recipient_view_request->setEmail($recipientEmail);
// must reference the same clientUserId that was set for the recipient when they
// were added to the envelope in step 2
$recipient_view_request->setClientUserId('12345');
// used to indicate on the certificate of completion how the user authenticated
$recipient_view_request->setAuthenticationMethod("email");
// generate the recipient view! (aka embedded signing URL)
$signingView = $envelopeApi->createRecipientView($accountId, $envelop_summary->getEnvelopeId(), $recipient_view_request);
$signurl= $signingView->getUrl();
} else {
$recipient_view_request->setUserName($recipientName2);
$recipient_view_request->setEmail($recipientEmail2);
// must reference the same clientUserId that was set for the recipient when they
// were added to the envelope in step 2
$recipient_view_request->setClientUserId('12345');
// used to indicate on the certificate of completion how the user authenticated
$recipient_view_request->setAuthenticationMethod("email");
// generate the recipient view! (aka embedded signing URL)
$signingView = $envelopeApi->createRecipientView($accountId, $_GET['enevelope'], $recipient_view_request);
$signurl= $signingView->getUrl();
}
header('Location: '.$signurl);
Are you getting error in retrieving recipientURL for signer 2? I can see you have created signer2 with clientuserId as 123456 in STEP2, but in STEP3, you are trying to get url with clientUserId with 12345.
In STEP 2, you have
$signer2->setClientUserId('123456');
In STEP3, you are passing
// were added to the envelope in step 2
$recipient_view_request->setClientUserId('12345');
If you set the correct clientUserId for signer2 then I think issue will be resolved for you.

how to get the document url to add custom fields using docusign api

I am trying to integrate docusign embedded signing into my hybrid app and i am loading the signing url in an iframe in my app, but is there any way to add some more custom fields on the fly using that signing url and make it in an unlocked state so that i can drag them where i want, and then make those fields locked at the time of sending to the sender for signing, also how to get the url of that document after he has signed it so that i can view it later.
Since i am a newbie in this please help me.
This is my code to get the signing url
<?php
$min=100;
$max=300;
$random = rand($min,$max);
$recipientId=rand();
require_once('vendor/autoload.php');
//require_once('./docusign-php-client/autoload.php');
// DocuSign account credentials & Integrator Key
$username = "testmail#mail.com";
$password = "test1234";
$integrator_key = "[integrator-key]";
$host = "https://demo.docusign.net/restapi";
// create a new DocuSign configuration and assign host and header(s)
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
/////////////////////////////////////////////////////////////////////////
// STEP 1: Login() API
/////////////////////////////////////////////////////////////////////////
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
// we will first make the Login() call which exists in the AuthenticationApi...
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
// optional login parameters
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
// call the login() API
$loginInformation = $authenticationApi->login($options);
// parse the login results
if(isset($loginInformation) && count($loginInformation) > 0)
{
// note: defaulting to first account found, user might be a
// member of multiple accounts
$loginAccount = $loginInformation->getLoginAccounts()[0];
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
echo "<b>Account ID</b> = $accountId</br>";
}
}
}
/////////////////////////////////////////////////////////////////////////
// STEP 2: Create & Send Envelope with Embedded Recipient
/////////////////////////////////////////////////////////////////////////
// set recipient information
$recipientName = "username";
$recipientEmail = "Test#email.com";
// configure the document we want signed
$documentFileName = "/abcd_test_01.pdf";
$documentName = "abcd_test.pdf";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName)));
$document->setName($documentName);
$document->setDocumentId("1");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setXPosition($random);
$signHere->setYPosition($random);
$signHere->setDocumentId("1");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId($recipientId); // must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Please sign this doc");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
echo "<b>Envelope Details: </b><pre>".$envelop_summary ."</pre></br>";
/////////////////////////////////////////////////////////////////////////
// STEP 3: Request Recipient View (aka signing URL)
/////////////////////////////////////////////////////////////////////////
// instantiate a RecipientViewRequest object
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest();
// set where the recipient is re-directed once they are done signing
$recipient_view_request->setReturnUrl("https://www.docusign.com/develcenter");
// configure the embedded signer
$recipient_view_request->setUserName($recipientName);
$recipient_view_request->setEmail($recipientEmail);
// must reference the same clientUserId that was set for the recipient when they
// were added to the envelope in step 2
$recipient_view_request->setClientUserId($recipientId);
// used to indicate on the certificate of completion how the user authenticated
$recipient_view_request->setAuthenticationMethod("email");
// generate the recipient view! (aka embedded signing URL)
$signingView = $envelopeApi->createRecipientView($accountId, $envelop_summary->getEnvelopeId(), $recipient_view_request);
echo "</br> Signing URL = <a href='" . $signingView->getUrl() . "' target='_blank'>".$signingView->getUrl()."</a></br>";
//MEthod for embedded sending view
$return_url="https://www.docusign.com/devcenter";
$senderView = $envelopeApi->createSenderView($accountId, $envelopeId,
$return_url);
var_dump($senderView->getUrl());
If you want to place additional fields on the document as a sender, you should use the Embedded Sending (or Sender View)
The Embedded Sending view of an envelope allows users to edit the tabs, documents, recipients, and other settings of draft envelopes before sending them out for approval. Similar to Embedded Signing, your app or website can generate a sending URL and integrate directly into your workflow using a Redirect, Webview, or an iFrame.
See here for the code sample.
Q : How to get the url of that document after he has signed it so that i can view it later.
See this answer.

Is it possible to create a Docusign template using HTML from the REST API?

I just created my developer account with DocuSign and apparently I need to know if I can use an HTML template for the documents that I need to attach to an envelope. I'm planning to use the REST API for this. But I would like to know if it's possible, all I can see from your documentations are PDFs and the template generators.
My goal is to generate the template(HTML) on the fly from my application and send that as a template to the API.
Any help would be really appreciated.
Thanks in advance.
Finally, I was able to achieve this using the PHP SDK. If you guys are interested to know here is how.
// set recipient information
$recipientName = "";
$recipientEmail = "";
// configure the document we want signed
$documentFileName = "/../document.html";
$documentName = "document.html";
// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($this->getApiClient());
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName)));
$document->setName($documentName);
$document->setFileExtension('html');
$document->setDocumentId("2");
// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setXPosition("100");
$signHere->setYPosition("100");
$signHere->setDocumentId("2");
$signHere->setPageNumber("1");
$signHere->setRecipientId("1");
// add the signature tab to the envelope's list of tabs
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setSignHereTabs(array($signHere));
// add a signer to the envelope
$signer = new \DocuSign\eSign\Model\Signer();
$signer->setEmail($recipientEmail);
$signer->setName($recipientName);
$signer->setRecipientId("1");
$signer->setTabs($tabs);
$signer->setClientUserId("1234"); // must set this to embed the recipient!
// Add a recipient to sign the document
$recipients = new DocuSign\eSign\Model\Recipients();
$recipients->setSigners(array($signer));
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Please sign this doc");
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
$envelop_definition->setRecipients($recipients);
$envelop_definition->setDocuments(array($document));
// create and send the envelope! (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null);
echo "$envelop_summary\n";
After I dig deeper on their documentation. Here is the source.

Resources