The process of sending an eSignature envelope using a template has become significantly easier with the ability to include additional documents. Recently, we introduced this new support. In this blog, we will see how to include additional documents while sending an eSignature envelope using a template via an API. We will cover examples in different programming languages, demonstrating how to achieve this with both application/json and multipart/form-data content types.
Why Including Additional Documents Is Important
Including additional documents while sending an eSignature envelope allows users to include all necessary documents in one go, improving efficiency. Whether you need to attach supporting documents, addendums, or additional forms, this feature makes the process seamless.
Prerequisites
- API Key or OAuth Access Token: You need a BoldSign API key, or an access token obtained from an OAuth app. Refer to this documentation for more information about BoldSign API authentication.
- Template ID: The ID of the template you want to use to send an envelope.
- Files: The additional documents you want to attach.
Code Examples
Following are code examples in different programming languages. To send an envelope for signature, you need to construct a payload with all the necessary details. Include details such as the title, message, signer name, and signer email address. If you are using the application/json content type, the files should be updated in base64 format. The base64 format is data:application/{{fileType}};base64,{{content}}. When using the multipart/form-data content type to send an envelope, you should include the files as part of the payload in their original binary format.
Application/JSON
curl -X 'POST' \ 'https://api.boldsign.com/v1/template/send?templateId=YOUR_TEMPLATE_ID' \
-H 'accept: application/json' \
-H 'X-API-KEY: {YOUR_API_KEY}' \
-H 'Content-Type: application/json;odata.metadata=minimal;odata.streaming=true' \
-d '{
"title": "Invitation form",
"message": "Kindly review and sign this.",
"roles": [
{
"roleIndex": 1,
"signerName": "david",
"signerEmail": "[email protected]"
}
],
"files": [
"data:application/{{fileType}};base64,{{content}}"
]
}'
Multipart/form-data
curl -X 'POST' \
'https://api.boldsign.com/v1/template/send?templateId=b8085b47-63b3-47f8-8d5e-cb0acfe2d916' \
-H 'accept: application/json' \
-H 'X-API-KEY: {your API key}' \
-F 'files=@{your file path};type=application/pdf' \
-F 'title=Invitation form' \
-F 'message=Kindly review and sign this.' \
-F 'roles[0][roleIndex]=1' \
-F 'roles[0][signerName]=Richard' \
-F 'roles[0][signerEmail][email protected]'
var apiClient = new ApiClient("https://api.boldsign.com", "{YOUR_API_KEY}");
var templateClient = new TemplateClient(apiClient);
var documentFilePath = new DocumentFilePath
{
ContentType = "application/pdf",
FilePath = "YOUR_FILE_PATH"
};
var filesToUpload = new List<IDocumentFile>
{
documentFilePath,
};
var templateRole = new Roles(
roleSignerName:"david",
roleSignerEmailAddress:"[email protected]",
roleSignerIndex:1
);
var roles = new List<Roles>
{
templateRole,
};
var sendForSignFromTemplate = new SendForSignFromTemplate()
{
TemplateId = "YOUR_TEMPLATE_ID",
Files = filesToUpload,
};
var documentCreated = templateClient.SendUsingTemplate(sendForSignFromTemplate);
import boldsign
configuration = boldsign.Configuration(api_key = "YOUR_API_KEY")
with boldsign.ApiClient(configuration) as api_client:
template_api = boldsign.TemplateApi(api_client)
send_for_sign_from_template_form = boldsign.SendForSignFromTemplateForm(
title = "Invitation form",
message = "Kindly review and sign this",
files = ["YOUR_FILE_PATH"],
roles = [
boldsign.Role(
roleIndex = 1,
signerName = "david",
signerEmail = "[email protected]"
)
]
)
document_created = template_api.send_using_template(
template_id = "YOUR_TEMPLATE_ID",
send_for_sign_from_template_form = send_for_sign_from_template_form
)
<?php
require_once "vendor/autoload.php";
use BoldSign\Configuration;
use BoldSign\Api\TemplateApi;
use BoldSign\Model\{Role, SendForSignFromTemplateForm, FileInfo};
$config = new Configuration();
$config->setHost('https://api.boldsign.com');
$config->setApiKey('YOUR_API_KEY');
$template_api = new TemplateApi($config);
$role = new Role();
$role->setRoleIndex(1);
$role->setSignerName('david');
$role->setSignerEmail('[email protected]');
$send_for_sign_from_template = new SendForSignFromTemplateForm();
$send_for_sign_from_template->setRoles([$role]);
$files = new FileInfo();
$files = 'YOUR_FILE_PATH';
$send_for_sign_from_template->setFiles([$files]);
$document_created = $template_api->sendUsingTemplate($template_id = 'YOUR_TEMPLATE_ID', $send_for_sign_from_template);
?>
ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.boldsign.com");
client.setApiKey("YOUR_API_KEY");
TemplateApi templateApi = new TemplateApi(client);
Role role = new Role();
role.roleIndex(1);
role.setSignerName("david");
role.setSignerEmail("[email protected]");
SendForSignFromTemplateForm sendForSignFromTemplate = new SendForSignFromTemplateForm();
sendForSignFromTemplate.setRoles(Arrays.asList(role));
File file = new File("YOUR_FILE_PATH");
sendForSignFromTemplate.setFiles(Arrays.asList(file));
DocumentCreated documentCreated = templateApi.sendUsingTemplate("YOUR_TEMPLATE_ID", sendForSignFromTemplate);
import { TemplateApi, Role, SendForSignFromTemplateForm } from "boldsign";
import * as fs from 'fs';
async function main() {
const templateApi = new TemplateApi();
templateApi.setApiKey("YOUR_API_KEY");
const role = new Role();
role.roleIndex = 1;
role.signerName = "david";
role.signerEmail = "[email protected]";
const sendForSignFromTemplate = new SendForSignFromTemplateForm();
sendForSignFromTemplate.roles = [role];
const files = fs.createReadStream("YOUR_FILE_PATH");
sendForSignFromTemplate.files = [files];
const documentCreated = templateApi.sendUsingTemplate("YOUR_TEMPLATE_ID", sendForSignFromTemplate);
}
main();
Note: When sending an envelope using a template via the API, you must use either files or fileUrls parameter in a single request. Both parameters cannot be used together.
Customizing your request
In the previous examples, replace placeholders such as the API key, signer details, file paths, and template ID with your own values before sending the request. Beyond the minimal fields shown, the same request supports common production needs such as signing order, CC recipients, reminders, and branding. These options sit alongside your existing fields and signer information in the request body. For a complete list of configurable properties and examples, refer to the Template Send API documentation.
Conclusion
By following the examples provided in this blog, you can successfully include additional documents when sending an eSignature envelope using a template via an API. Whether you prefer using the application/json or multipart/form-data content type, the process is straightforward and can be implemented in various programming languages. This added flexibility ensures that your document workflows are efficient, accurate, and tailored to your specific needs.
To experience the benefits firsthand, start a 30-day free trial of BoldSign. We genuinely value your feedback and invite you to share your thoughts below. If you require any assistance or wish to explore our services further, don’t hesitate to schedule a demo or reach out to our dedicated support team via our support portal.