How to provide background color for the label fields when sending document for signature?

BoldSign allows you to set a background color for label fields by using the BackgroundHexColor API when sending a document for signature. This article provides a guide on how to set a background color for label fields when sending a document for signature using the BoldSign API.

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 'Signers={
  "name": "Richard",
  "emailAddress": "richard@boldsign.dev",
  "formFields": [
    {
      "id": "sign",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 100,
        "y": 100,
        "width": 200,
        "height": 20
      },
      "isRequired": true
    },
{
      "id": "label1",
      "fieldType": "Label",
      "pageNumber": 1,
      "bounds": {
        "x": 200,
        "y": 200,
        "width": 200,
        "height": 20
      },
      "isRequired": true,
       "value": "Sample",
      "backgroundHexColor": "#00FFFF"
    }
  ],
  "locale": "EN"
}' \
  -F 'Files=@{Your File Path}' \
  -F 'Title=Sample document' \

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 labelField = new FormField(
   id: "label",
   isRequired: true,
   value:"Sample",
   type: FieldType.Label,
   pageNumber: 1,
   bounds: new Rectangle(x: 200, y: 400, width: 100, height: 50));   

labelField.BackgroundHexColor = "#FF00FF";  

var formFieldCollections = new List<FormField>()
{
    signatureField,
    labelField
};

var signer = new DocumentSigner(
  signerName: "Richard",
  signerType: SignerType.Signer,
  signerEmail: "richard@boldsign.dev",
  formFields: formFieldCollections,
  locale: Locales.EN);

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

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

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

import requests
import json

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

signer_data = {
    "name": "Richard",
    "emailAddress": "richard@boldsign.dev",
    "signerType": "Signer",
    "formFields": [
        {
            "id": "Sign1",
            "name": "Sign1",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
                "x": 50,
                "y": 50,
                "width": 200,
                "height": 25
            },
            "isRequired": True
        },
        {
            "id": "Label1",
            "name": "Label1",
            "fieldType": "Label",
            "value":"Sample",
            "pageNumber": 1,
            "bounds": {
                "x": 150,
                "y": 250,
                "width": 200,
                "height": 25
            },
            "backgroundHexColor": "#00FFFF"
        }
    ],
    "locale": "EN"
}

payload = {
    'Message': 'Please sign this.',
    'Signers': json.dumps(signer_data),
    '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 fs = require('fs');
const FormData = require('form-data');

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

const signerData = {
    name: "Richard",
    emailAddress: "richard@boldsign.dev",
    signerType: "Signer",
    formFields: [
        {
            id: "Sign1",
            name: "Sign1",
            fieldType: "Signature",
            pageNumber: 1,
            bounds: {
                x: 50,
                y: 50,
                width: 200,
                height: 25
            },
            isRequired: true
        },
        {
            id: "Label1",
            name: "Label1",
            fieldType: "Label",
            value:"Sample",
            pageNumber: 1,
            bounds: {
                x: 150,
                y: 250,
                width: 200,
                height: 25
            },
            isRequired: true,
            backgroundHexColor: "#00FFFF"
        }
    ],
    locale: "EN"
};

const formData = new FormData();
formData.append('Message', 'Please sign this.');
formData.append('Signers', JSON.stringify(signerData));
formData.append('Title', 'Agreement');
formData.append('Files', fs.createReadStream('{Your file path}'), 'application/pdf');

const headers = {
  'accept': 'application/json',
  'X-API-KEY': '{Your API Key}',
  ...formData.getHeaders()
};

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

In the provided code examples, make sure to update the SignerEmail and SignerName properties with the email and name of the signer you wish to send the document to, and replace the filepath with the actual path to your PDF file. Once the code is executed, the document will be sent for signature with label fields, including background color.