Articles in this section
Category / Section

How to add metadata while sending document for signature?

Published:
6 mins read

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:

Code snippet

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: application/json' \
  -d '{
    "Message": "Test document",
    "Signers": [
        {
            "name": "Alex",
            "emailAddress": "alexgayle@cubeflakes.com",
            "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"
  }
  }'

C#


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

Python

import boldsign

configuration = boldsign.Configuration(api_key="Your_API_Key")

with boldsign.ApiClient(configuration) as api_client:
    document_api = boldsign.DocumentApi(api_client)

    form_fields = [
        boldsign.FormField(
            fieldType="Signature",
            pageNumber=1,
            bounds=boldsign.Rectangle(x=50, y=50, width=200, height=25),
            isRequired=True
        ),
    ]

    document_signer = boldsign.DocumentSigner(
        name="Alex",
        emailAddress="alexgayle@cubeflakes.com",
        signerType="Signer",
        formFields=form_fields,
    )

    file_path = "Your_File_Path"

    send_for_sign = boldsign.SendForSign(
        title="Agreement",
        files=[file_path],  # Add file path here
        signers=[document_signer],
        meta_data={
            "DocumentType": "new",
            "DocumentCategory": "Software"
        }
    )

    send_document_response = document_api.send_document(send_for_sign)

    print(send_document_response)

NodeJS

const axios = require('axios');

const url = "https://api.boldsign.com/v1/document/send";

const signerData = {
  "name": "Alex",
  "emailAddress": "alexgayle@cubeflakes.com",
  "signerType": "Signer",
  "formFields": [
    {
      "id": "string",
      "name": "string",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 50,
        "y": 50,
        "width": 200,
        "height": 25
      },
      "isRequired": true
    }
  ],
  "locale": "EN"
};

const payload = {
  'Message': 'Please sign this.',
  'Signers': [signerData],
  'Title': 'Agreement',
  'Files': [
    'data:application/pdf;base64,JVBERi0xLjcNCi...'
  ],
  
  'MetaData': {
    'DocumentType': 'new',
    'DocumentCategory': 'Software'
  }
};

const headers = {
  'Content-Type': 'application/json',
  'accept': 'application/json',
  'X-API-KEY': '{Your API Key}'
};

axios.post(url, payload, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error('Error:', error);
  });

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.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied