How to Add Metadata When Sending a Document

The metadata can be used to store additional information about the document in the form of key-value pairs. In the context of digital documents, metadata is essential for defining and categorizing various aspects of the document. BoldSign allows you to add metadata for the document while sending document for e-signature. You can add meta data for the document by using MetaData property. Here is an example demonstrating how to add metadata while sending a document for e-signature using the BoldSign API:

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY:{Your API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
    "Message": "Test document",
    "Signers": [
        {
            "name": "Alex",
            "emailAddress": "[email protected]",
            "signerType": "Signer",
            "formFields": [
                {
                    "id": "sign1",
                    "name": "sign1",
                    "fieldType": "Signature",
                    "pageNumber": 1,
                    "bounds": {
                        "x": 50,
                        "y": 50,
                        "width": 125,
                        "height": 25
                    },
                    "isRequired": true
                }
              ],
            "locale": "EN"
        }
    ],
   
   "Files": [
        "data:application/pdf;base64,JVBERi0xLjcKJcfs..."
    ],
    "Title": "Sampledocument",
    "MetaData": {
    "DocumentType": "new",
    "DocumentCategory": "Software"
  }
  }'

using BoldSign.Api;
using BoldSign.Model;

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: "Alex",
    signerType: SignerType.Signer,
    signerEmail: "[email protected]",
    formFields: formFieldCollections,
    locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};

var metaData = new Dictionary<string, string>()
{
    ["DocumentType"] = "new",
    ["DocumentCategory"] = "software",
};

var sendForSign = new SendForSign()
{
    Message = "please sign this",
    Title = "Agreement",
    Signers = documentSigners,
    Files = filesToUpload,
    MetaData = metaData

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

configuration = boldsign.Configuration(host = "https://api.boldsign.com", api_key = "YOUR_API_KEY")

with boldsign.ApiClient(configuration) as api_client:
    
    document_api = boldsign.DocumentApi(api_client)
    
    send_for_sign = boldsign.SendForSign(
        title = "Document SDK API",
        document_title = "SDK Document Test case",
        description = "Testing document from SDK integration test case", 
        files = ["YOUR_FILE_PATH"],
        signers = [
            boldsign.DocumentSigner(
                name = "Hanky",
                emailAddress = "[email protected]",
                signerOrder = 1,
                signerType = "Signer",
                formFields = [
                    boldsign.FormField(
                        name = "Sign",
                        fieldType = "Signature",
                        font = "Helvetica",
                        pageNumber = 1,
                        isRequired = True,
                        bounds = boldsign.Rectangle(x = 50, y = 50, width = 100, height = 150)
                    )
                ],
                privateMessage = "This is private message for signer"
            )
        ],
        metaData = {
            "DocumentType": "new",
            "DocumentCategory": "software"
        }
    )
    
    document_created = document_api.send_document(send_for_sign)
<?php require_once "vendor/autoload.php";

use BoldSign\Configuration;
use BoldSign\Api\DocumentApi;
use BoldSign\Model\DocumentSigner;
use BoldSign\Model\SendForSign;
use BoldSign\Model\FormField;
use BoldSign\Model\Rectangle;

$config = new Configuration();
$config->setHost("https://api.boldsign.com");
$config->setApiKey('YOUR_API_KEY');
$document_api = new DocumentApi($config);

// Define MetaData as an associative array
$metaData = [
    "DocumentType" => "new",
    "DocumentCategory" => "Software"
];

$form_field = new FormField();
$form_field->setName('TextBox');
$form_field->setFieldType('TextBox');
$form_field->setPageNumber(1);
$form_field->setIsRequired(true);
$bounds = new Rectangle();
$bounds->setX(50);
$bounds->setY(50);
$bounds->setWidth(100);
$bounds->setHeight(150);
$form_field->setBounds($bounds);

$signer = new DocumentSigner();
$signer->setName("Alex");
$signer->setEmailAddress("[email protected]");
$signer->setSignerType("Signer");
$signer->setFormFields([$form_field]);

$send_for_sign = new SendForSign();
$send_for_sign->setTitle("Agreement");
$send_for_sign->setMessage("Please sign this.");
$send_for_sign->setFiles(['YOUR_FILE_PATH']);
$send_for_sign->setSigners([$signer]);

// Assign MetaData to the request
$send_for_sign->setMetaData($metaData);

$result = $document_api->sendDocument($send_for_sign);

ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.boldsign.com");
client.setApiKey("YOUR_API_KEY");
DocumentApi documentApi = new DocumentApi(client);

// Define MetaData
Map<String, String> metaData = new HashMap<>();
metaData.put("DocumentType", "new");
metaData.put("DocumentCategory", "Software");

FormField signatureField = new FormField();
signatureField.setId("sign");
signatureField.setName("string");
signatureField.setFieldType(FormField.FieldTypeEnum.SIGNATURE);
signatureField.setPageNumber(1);
Rectangle bounds = new Rectangle();
bounds.setX(130f);
bounds.setY(130f);
bounds.setWidth(81f);
bounds.setHeight(31f);
signatureField.setBounds(bounds);

// Document Signer
DocumentSigner signer = new DocumentSigner();
signer.setName("Alex");
signer.setEmailAddress("[email protected]");
signer.setSignerType(DocumentSigner.SignerTypeEnum.SIGNER);
signer.setFormFields(Arrays.asList(signatureField));

// Send For Sign Request
SendForSign sendForSign = new SendForSign();
sendForSign.setTitle("Agreement");
sendForSign.setMessage("Please sign this.");
sendForSign.setFiles(Arrays.asList(new File("YOUR_FILE_PATH")));
sendForSign.setSigners(Arrays.asList(signer));

// Assign MetaData to the request
sendForSign.setMetaData(metaData);

DocumentCreated response = documentApi.sendDocument(sendForSign);
import { DocumentApi, DocumentSigner, SendForSign, FormField, Rectangle } from "boldsign";
import * as fs from 'fs';

const documentApi = new DocumentApi("https://api.boldsign.com");
documentApi.setApiKey('YOUR_API_KEY');

const formField = new FormField();
formField.fieldType = FormField.FieldTypeEnum.Signature;
formField.pageNumber = 1;
formField.isRequired = true;

const bounds = new Rectangle();
bounds.x = 50;
bounds.y = 50;
bounds.width = 200;
bounds.height = 25;
formField.bounds = bounds;

const signer = new DocumentSigner();
signer.name = 'Alex';
signer.emailAddress = '[email protected]';
signer.signerType = DocumentSigner.SignerTypeEnum.Signer;
signer.formFields = [formField];
signer.locale = DocumentSigner.LocaleEnum.En;

const sendForSign = new SendForSign();
sendForSign.title = 'Agreement';
sendForSign.message = 'Please sign this.';
sendForSign.signers = [signer];
sendForSign.files = [fs.createReadStream('YOUR_FILE_PATH')];
sendForSign.metaData = {
    'DocumentType': 'new',
    'DocumentCategory': 'Software'
};

const createdDocument = documentApi.sendDocument(sendForSign);

In the provided code examples, update the SignerEmail and SignerName properties with the email and name of the signer you wish to send the document to. By following the code snippets provided, you can send documents with the meta data using BoldSign API.