• Blog

How to Send Documents for eSignature via API

how-to-send-documents-for-esignature-via-api
Table of Contents

Sign Docs 3x Faster

Send, sign, and manage documents securely and efficiently.

Introduction

Step into the world of streamlined document management with the BoldSign API. In this concise guide, we’ll look at how to use BoldSign for digital transactions, simplifying the process of sending documents out to collect signatures.

Asynchronous document processing

The process of document send is asynchronous. You will quickly get the document ID when you start, but the actual file might still be processing in the background. To check if the document was sent successfully, you need to listen to webhooks.

The system will trigger either a Sent event for success or a SendFailed event for failure. If it fails, you will get a SendFailed event with an error message. You need to fix this error to make sure the document is sent correctly next time.

Read more about webhooks.

Code snippets

For the rest of this article, we’ll look at how to send documents via the BoldSign API in various programming languages.


curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {your API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Message=' \
  -F 'Signers={
  "name": "Test",
  "emailAddress": "[email protected]",
  "authenticationType": "None",
  "deliveryMode": "Email",
  "signerOrder": 0,
  "enableEmailOTP": true,
  "signerType": "Signer",
  "allowFieldConfiguration": true,
  "formFields": [
    {
      "id": "signature1",
      "name": "signature1",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 180,
        "y": 160,
        "width": 81,
        "height": 31
      },
      "isRequired": true
    }
  ]
}' \
  -F 'Files=@{your file path};type=application/pdf' \
  -F 'Title={Title}' \
    

var apiClient = new ApiClient("https://api.boldsign.com", "{Your API Key}");
var documentClient = new DocumentClient(apiClient);
var documentFilePath = new DocumentFilePath
            {
                ContentType = "application/pdf",
                FilePath = "{Your file path}",
            };
var filesToUpload = new List
{
    documentFilePath,
};
var signatureField = new FormField(
               id: "sign",
               isRequired: true,
               type: FieldType.Signature,
               pageNumber: 1,
               bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50));
var formFieldCollections = new List()
{
    signatureField
};
var signer = new DocumentSigner(
              signerName: "Signer Name",
              signerType: SignerType.Signer,
              signerEmail: "[email protected]",
              formFields: formFieldCollections,
              locale: Locales.EN);
var documentSigners = new List()
{
    signer
};
var sendForSign = new SendForSign()
            {
                Title = "Agreement",
                Signers = documentSigners,
                Files = filesToUpload,
            };
var documentCreated = documentClient.SendDocument(sendForSign);
            Console.WriteLine(documentCreated.DocumentId);
    

import requests # type: ignore
import json
url = "https://api.boldsign.com/v1/document/send"
signer_data = {
    "name": "Test",
    "emailAddress": "[email protected]",
    "signerType": "Signer",
    "formFields": [
        {
            "id": "signature1",
            "name": "signature1",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
                "x": 50,
                "y": 50,
                "width": 200,
                "height": 25
            },
            "isRequired": True
        }
    ],
    "locale": "EN"
}
payload = {
    'Title': 'Agreement',
}
files=[
  ('Files',('file',open('your file path,'rb'),'application/pdf'))
]
headers = {
  'accept': 'application/json',
  'X-API-KEY': 'Your API key'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
    

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('Message', '');
data.append('Signers', '{\r\n        "name": "Test",\r\n        "emailAddress": "[email protected]",\r\n        "signerType": "Signer", \r\n        "deliveryMode": "Email",\r\n        "formFields": [\r\n           {\r\n                "id": "signature1",\r\n                "name": "signature1",\r\n                "fieldType": "Signature",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 80,\r\n                  "y": 50,\r\n                  "width": 31,\r\n                  "height": 21\r\n                   },\r\n      "isRequired": true\r\n    }\r\n  ],\r\n  "locale": "EN"\r\n}');
data.append('Files', fs.createReadStream('your file path'));
data.append('Title', 'Title');
let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://api.boldsign.com/v1/document/send',
    headers: { 
      'accept': 'application/json', 
      'X-API-KEY': 'your API key', 
      ...data.getHeaders()
    },
    data : data
};
  
  axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
    

<?php
require_once "vendor/autoload.php";
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use \GuzzleHttp\Psr7\Utils;
$client = new GuzzleHttp\Client(['verify' => false]);
$headers = [
  'accept' => 'application/json',
  'X-API-KEY' => 'your API key'
];
$options = [
  'multipart' => [
    [
      'name' => 'Signers',
      'contents' => '{
        "name": "Test",
        "emailAddress": "[email protected]",
        "signerType": "Signer",
        "formFields": [
          {
            "id": "signature1",
            "name": "signature1",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
              "x": 50,
              "y": 50,
              "width": 61,
              "height": 21
            },
            "isRequired": true
          }
        ],
        "locale": "EN"
      }'
    ],
    [
      'name' => 'Files',
      'contents' => Utils::tryFopen('your file path', 'r'),
      'filename' => 'file name',
      'headers' => [
        'Content-Type' => 'application/pdf'
      ]
    ],
    [
      'name' => 'Title',
      'contents' => 'Title'
    ]
  ]
];
$request = new Request('POST', 'https://api.boldsign.com/v1/document/send', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
    

Conclusion

In conclusion, the BoldSign API offers simplicity and flexibility for the signature collection process. Whether users have a BoldSign account or not, they can conveniently sign documents.

By following these guidelines and incorporating the code examples provided, you can seamlessly integrate document sending functionalities directly into your applications. Begin your 30-day trial now to see firsthand how BoldSign streamlines and optimizes your eSignature processes.

Your feedback is important to us, so please feel free to share your thoughts in the comments section below. If you have any questions or require additional information about our services, please schedule a demo or contact our support team through our dedicated support portal.

Latest blog posts

Simplify Insurance Authorizations & Billing with Secure eSignatures

Simplify Insurance Authorizations & Billing with Secure eSignatures

Simplify insurance authorizations and billing with secure eSignatures. Speed up approvals, reduce errors, & ensure HIPAA compliance across healthcare workflows.

Webinar Show Notes: Embed eSignature Workflows in .NET App 

Webinar Show Notes: Embed eSignature Workflows in .NET App 

Embed eSignature workflows in your .NET app with BoldSign for a seamless, secure, and branded signing experience. Simplify sending, signing, and tracking.

BulkSend your documents to multiple recipients using BoldSign 

BulkSend your documents to multiple recipients using BoldSign 

Managing high-volume signature requests can be time-consuming, especially when each document needs to be personalized and securely delivered. That’s where the BoldSign bulk send feature becomes invaluable. Instead of manually preparing and sending individual signature requests, bulk send enables you to deliver customized copies of a document to multiple recipients in one streamlined process. Whether […]

Sign up for your free trial today!

  • tick-icon
    30-day free trial
  • tick-icon
    No credit card required
  • tick-icon
    30-day free trial
  • tick-icon
    No credit card required
signup-banner