The BoldSign mobile app is now available. Visitthis link for more details and give it a try!

The BoldSign mobile app is now available. Visitthis link for more details and give it a try!

Request Demo
BoldSign Logo Small

Features

Explore the BoldSign features that make eSigning easier.

How to Send Documents for eSignature via API

How to Send Documents for eSignature via API

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

    
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": "alexgayle@cubeflakes.com",
  "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}' \

C#

    
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<IDocumentFile>
{
    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<FormField>()
{
    signatureField
};

var signer = new DocumentSigner(
              signerName: "Signer Name",
              signerType: SignerType.Signer,
              signerEmail: "alexgayle@cubeflakes.com",
              formFields: formFieldCollections,
              locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};
var sendForSign = new SendForSign()
            {
                Title = "Agreement",
                Signers = documentSigners,
                Files = filesToUpload,

            };
var documentCreated = documentClient.SendDocument(sendForSign);
            Console.WriteLine(documentCreated.DocumentId);

Python

    
import requests # type: ignore
import json
url = "https://api.boldsign.com/v1/document/send"
signer_data = {
    "name": "Test",
    "emailAddress": "alexgayle@cubeflakes.com",
    "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)

Node.js

    
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": "alexgayle@cubeflakes.com",\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

    
<?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": "alexgayle@cubeflakes.com",
        "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.

Picture of James Agini Muganya

James Agini Muganya

James Agini Muganya is a Technical Assistant at BoldSign. He creates content in various formats, including API tutorials, help articles, and comprehensive guides.

Share this blog

Picture of James Agini Muganya

James Agini Muganya

James Agini Muganya is a Technical Assistant at BoldSign. He creates content in various formats, including API tutorials, help articles, and comprehensive guides.

Subscribe RSS feed

Leave a Reply

Your email address will not be published. Required fields are marked *