How to add additional files while sending document from template?

BoldSign supports adding additional files when sending a document from a template using the API. Using Files property, you can add additional file.

The "v1/template/send" API endpoint now supports both multipart/form-data and application/json content types. This article will guide you on how to add additional files when sending a document from a template using the API.

Below are a few code examples demonstrating how to add additional files when sending a document from a template using the API.

Code snippet using multipart/form-data

curl -X 'POST' \
  'https://api.boldsign.com/v1/template/send?templateId=d6bad813-xxxx-xxxx-8c9e-e91a96c06392' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {Your API Key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'files=@{path to your file}' \
  -F 'title=Sample document' \
  -F 'message=Kindly review and sign this.' \
  -F 'roles[0][roleIndex]=1' \
  -F 'roles[0][signerName]=Richard' \
  -F 'roles[0][signerEmail]=richard@boldsign.dev' \
  -F 'roles[0][privateMessage]=Please check and sign the document.' \
  -F 'roles[0][signerType]=Signer' \
  -F 'roles[0][signerRole]=Manager' \
  -F 'roles[0][formFields][0][id]=SignField' \
  -F 'roles[0][formFields][0][fieldType]=Signature' \
  -F 'roles[0][formFields][0][pageNumber]=1' \
  -F 'roles[0][formFields][0][bounds][x]=100' \
  -F 'roles[0][formFields][0][bounds][y]=100' \
  -F 'roles[0][formFields][0][bounds][width]=100' \
  -F 'roles[0][formFields][0][bounds][height]=50' \
  -F 'roles[0][formFields][0][isRequired]=true' \
  -F 'roles[0][locale]=EN'

using BoldSign.Api;
using BoldSign.Model;
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:"Richard",
    roleSignerEmailAddress:"richard@boldsign.dev",
    roleSignerIndex:1,
    locale: Locales.EN);

var roles = new List<Roles>
{
    templateRole,
    
};

var sendForSignFromTemplate = new SendForSignFromTemplate()
{
    Files = filesToUpload,
    TemplateId = "cda4932f-xxxx-xxxx-8a5e-72ce7883e727",
    Roles = roles,
  
};

var documentCreated =  templateClient.SendUsingTemplate(sendForSignFromTemplate);
Console.WriteLine(documentCreated.DocumentId);

Code snippet using application/json

curl -X 'POST' \ 'https://api.boldsign.com/v1/template/send?templateId=cda4932f-xxxx-xxxx-8a5e-72ce7883e727' \
     -H 'accept: application/json' \
     -H 'X-API-KEY: {Your API Key}' \
     -H 'Content-Type: application/json;odata.metadata=minimal;odata.streaming=true' \
     -d '{
       "title": "Sample document",
       "message": "Kindly review and sign this.",
       "roles": [
    {
      "roleIndex": 1,
      "signerName": "Richard",
      "signerEmail": "richard@boldsign.dev",
      "privateMessage": "Please check and sign the document.",
      "signerType": "Signer",
      "signerRole": "Manager",
      "locale": "EN"
    }
  ],

   "files": [
        "data:application/{{fileType}};base64,{{content}}"
    ]
   }'

In the example above, replace templateId with the ID of the template you created earlier. Then, update the SignerEmail and SignerName properties with the email and name of the signer to whom you want to send the document, and add any additional files. Once you run the code, the document will be sent for signature with the additional files included.