To get a signature from a sender in a web form using the Adobe Sign API, you can follow these general steps:
Here's some sample code to get you started:
HTML form:
<form id="myForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="document">Document:</label>
<input type="file" id="document" name="document"><br>
<div id="signatureContainer"></div>
<button type="submit" id="submitBtn">Submit</button>
</form>
// Load the Adobe Sign SDK script
var sdkUrl = 'https://secure.echosign.com/public/docs/1.0/AdobeSign.js';
$.getScript(sdkUrl, function() {
// Initialize the Adobe Sign API with your API credentials and access token
adobeSign.init({
clientId: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI',
scope: 'user_login:self+agreement_send:self',
accessToken: 'YOUR_ACCESS_TOKEN'
});
// Handle form submission
$('#myForm').on('submit', function(e) {
e.preventDefault();
// Get form data
var formData = new FormData(this);
var name = formData.get('name');
var email = formData.get('email');
var document = formData.get('document');
// Create a new agreement
var agreement = adobeSign.createAgreement({
documentURL: document,
senderEmail: email,
senderName: name,
signatureType: 'ESIGN',
signatureFlow: 'SENDER_SIGNATURE_REQUIRED',
name: 'My Agreement',
message: 'Please sign this agreement.'
});
// Generate a signing URL for the agreement
agreement.getSigningUrl().then(function(url) {
// Embed the signing URL in the web form
var signatureContainer = document.getElementById('signatureContainer');
signatureContainer.innerHTML = '<iframe src="' + url + '" width="500" height="300"></iframe>';
}).catch(function(err) {
console.error('Error generating signing URL:', err);
alert('Error generating signing URL: ' + err.message);
});
});
});
Note that you'll need to replace YOUR_CLIENT_ID, YOUR_REDIRECT_URI
, and YOUR_ACCESS_TOKEN
with your own values. You'll also need to adjust the document
variable to reference the uploaded file correctly, depending on how your form is set up. Additionally, you may need to adjust the options passed to the createAgreement()
method to fit your specific use case. The code above embeds the signing URL in an iframe with a width of 500px and a height of 300px, but you can adjust these values as needed to fit your web form.
use adobe sign api only for e signature without document
Yes, you can use the Adobe Sign API for e-signatures without a document. The API provides an endpoint called "Create Agreement from Template" that allows you to create an agreement from a pre-defined template without uploading a document.
Here's an example request in cURL:
curl --location --request POST 'https://api.echosign.com/api/rest/v6/agreements' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "My Agreement",
"message": "Please sign this agreement",
"fileInfos": [],
"templateId": "TEMPLATE_ID",
"recipientSetInfos": [
{
"recipientSetMemberInfos": [
{
"email": "john@example.com",
"fax": "",
"securityOption": "NONE"
}
],
"recipientSetRole": "SIGNER"
}
]
}'
In the above example, the fileInfos
array is empty, indicating that no document is being uploaded. Instead, the templateId
field is used to specify the ID of the pre-defined template to use. The recipient information is also specified in the recipientSetInfos
array.
Note that you'll need to replace ACCESS_TOKEN
and TEMPLATE_ID
with your own values. You'll also need to adjust the recipient information and other fields as necessary for your specific use case.