How to add custom information to your document?

To add custom information in a document to filter documents based on that information, you can utilize BoldSign's labels property. This allows the sender to attach additional metadata to the document without affecting the signing experience for the recipients.

Follow these steps to add custom information to the document:

1. Send a document with a tag

When sending a document with a label, you need to include the labels property in the document metadata.

Here are example codes that you can use for this purpose:

Code snippet

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 'Labels= {Your label}' \
     -F 'Message=' \
     -F 'Signers={
        "name": "Hanky",
        "emailAddress": "hankyWhites@cubeflakes.com",
        "signerType": "Signer",
        "formFields": [
           {
                "id": "string",
                "name": "string",
                "fieldType": "Signature",
                "pageNumber": 1,
                "bounds": {
                  "x": 50,
                  "y": 50,
                  "width": 1,
                  "height": 1
                   },
      "isRequired": true
    }
  ],
  "locale": "EN"
}' \
  -F 'Files={your file}' \
  -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<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: "David",
  signerEmail: "david@cubeflakes.com",
  formFields: formFieldCollections,
  locale: Locales.EN);


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

var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   Labels = new List<string>() { "label1", "label2" },
   Signers = documentSigners,
   Files = filesToUpload
};
var documentCreated = documentClient.SendDocument(sendForSign);
import requests
import json

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

signer_data = {
    "name": "Hanky",
    "emailAddress": "hankyWhites@cubeflakes.com",
    "signerType": "Signer",
    "formFields": [
        {
            "id": "string",
            "name": "string",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
                "x": 50,
                "y": 50,
                "width": 1,
                "height": 1
            },
            "isRequired": True
        }
    ],
    "locale": "EN"
}

payload = {
    'Labels': '{Your label}',
    'Message': '',
    'Signers': json.dumps(signer_data),
    'Title': '{title}'
}

files = [
    ('Files', (
        'doc-2.pdf',
        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('Labels', '{Your label}');
data.append('Message', '');
data.append('Signers', '{\r\n        "name": "Hanky",\r\n        "emailAddress": "hankyWhites@cubeflakes.com",\r\n        "signerType": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "string",\r\n                "name": "string",\r\n                "fieldType": "Signature",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 50,\r\n                  "y": 50,\r\n                  "width": 1,\r\n                  "height": 1\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);
});

In the above example, replace Labels with the actual value of the tag that you want to apply to the document. Execute the above command while ensuring to provide the necessary fields such as Files, Title, and Signers. By doing so, the desired tag will be applied to the created document.

2. Add tag to the existing document

To add tags to existing documents, refer to the instructions in the article Add tags to the existing document.

3. List the documents with the label property

To list documents with specific labels, use the provided code snippets:

Code snippet

curl -X 'GET' \ 'https://api.boldsign.com/v1/document/list?Page=1&Labels={Your label}' \
     -H 'accept: application/json' \
     -H 'X-API-KEY: {your-api-key}'
var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);
var documents = documentClient.ListDocuments(1, 10, labels: new List<string> { "your label" });
import requests

url = "https://api.boldsign.com/v1/document/list?Page=1&Labels={Your label}'"

payload={}
headers = {
  'accept': 'application/json',
  'X-API-KEY': '{your-api-key}}'
}

response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
const axios = require('axios');
const response = await axios.get('https://api.boldsign.com/v1/document/list', {
    params: {
        'PageSize': '10',
        'Page': '1'
    },
    headers: {
        'accept': 'application/json',
        'X-API-KEY': '{your API key}'
    }
});

In the above example, replace Labels with the actual value of the tag of the document that you want to list the document. Upon executing the above code, the documents with the specified tag will be listed.