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

Features

Explore the BoldSign features that make eSigning easier.

How to Edit Templates via API

How to Edit Templates via API

A template is useful when you frequently send the same contract for signature to many people with the same fields. However, after creating a template, you may sometimes need to make small changes or customize it for a specific purpose. 

The BoldSign API lets you make changes and customizations without manual intervention. Whether you need to update contract templates, modify form fields, or adjust layouts, using an API to edit templates can save time and ensure consistency across your documents.

Editing a Template Using a BoldSign API

The Edit Template API in BoldSign allows users to modify the properties of existing templates and draft templates. This could include modifying the title, description, document message, document title, roles, or form fields associated with the template.

Users can execute partial updates to a template by specifying only the fields they intend to modify. The API will solely modify the provided fields, leaving the remainder unchanged. However, this is limited to top-level properties. When dealing with nested properties within top-level objects, users must provide the complete object for modification.

When you need to update a nested property, you will need to use the Template Properties API, which will retrieve all the properties of the given template. Then, you can modify the required properties within the nested object and send the updated template object to the Edit Template API.

Read more about the Template Properties API

Following are code examples you can use to edit a template.

Curl

    
curl --location --request PUT 'https://api.boldsign.com/v1-beta/template/edit?templateId={Your Template ID }' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: {API-KEY}' \
--data-raw '{
"title": "{A new title}",
"roles": [
{
"name": "Manager",
"index": 1,
"defaultSignerName": "Alex",
"defaultSignerEmail": "starvritsabuhungi@boldsign.dev",
"signerType": "Signer",
"formFields": [
{
"id": "Signature1",
"type": "Signature",
"isRequired": true,
"bounds": {
"x": 600,
"y": 200,
"width": 100,
"height": 32
},
"pageNumber": 1
}
],
"enableEditRecipients": true,
"enableDeleteRecipients": true
}
]
}'
 

C#

    
var apiClient = new ApiClient("https://api.boldsign.com", "{API-KEY}");
var templateClient = new TemplateClient(apiClient);
var formFields = new List
{
    new FormField(
        id: "Sign",
        type: FieldType.Signature,
        pageNumber: 1,
        isRequired: true,
        bounds: new Rectangle(x: 150, y: 150, width: 200, height: 30)),
};
var templateRoles = new List
{
    new TemplateRole()
    {
        Name = "Manager",
        Index = 1,
        DefaultSignerName = "Alex",
        DefaultSignerEmail = "alexgayle@boldsign.dev",
        SignerType = SignerType.Signer,
        FormFields = formFields,
        AllowRoleEdit = true,
        AllowRoleDelete = true,
    },
};
var editTemplateRequest = new EditTemplateRequest("{templateId}")
{
    Title = "A new title for template",
    Roles = templateRoles,
};
await templateClient.EditTemplateAsync(editTemplateRequest);
 

Python

    
import requests
url = 'https://api.boldsign.com/v1-beta/template/edit?templateId={your templateid}'
headers = {
    'Content-Type': 'application/json',
    'X-API-KEY': '{API-KEY}'  
}
data = {
    "title": "{A new title for template}",
    "roles": [
        {
            "name": "Manager",
            "index": 1,
            "defaultSignerName": "Alex",
            "defaultSignerEmail": "alexgayle@boldsign.dev",
            "signerType": "Signer",
            "formFields": [
                {
                    "id": "Signature1",
                    "type": "Signature",
                    "isRequired": True,
                    "bounds": {
                        "x": 625.0,
                        "y": 293.0,
                        "width": 124.0,
                        "height": 32.0
                    },
                    "pageNumber": 1
                }
            ],
            "enableEditRecipients": True,
            "enableDeleteRecipients": True
        }
    ]
}
response = requests.put(url, headers=headers, json=data)
print(response.status_code)
 

Node.js

    
const axios = require('axios');
const url = 'https://api.boldsign.com/v1-beta/template/edit?templateId={your templateid}';
const headers = {
    'Content-Type': 'application/json',
    'X-API-KEY': '{API-KEY}'  
};
const data = {
    "title": "{A new title for template}",
    "roles": [
        {
            "name": "Manager",
            "index": 1,
            "defaultSignerName": "Alex",
            "defaultSignerEmail": "alexgayle@boldsign.dev",
            "signerType": "Signer",
            "formFields": [
                {
                    "id": "Signature1",
                    "type": "Signature",
                    "isRequired": true,
"bounds": {
                        "x": 625.0,
                        "y": 293.0,
                        "width": 124.0,
                        "height": 32.0
                    },
                    "pageNumber": 1
                }
            ],
            "enableEditRecipients": true,
            "enableDeleteRecipients": true
        }
    ]
};
axios.put(url, data, { headers: headers })
    .then(response => {
        console.log(response.status);
        console.log(response.data);
    })
    .catch(error => {
        console.error(error);
    });
 

PHP

    
<?php
require 'vendor/autoload.php'; // Include Guzzle HTTP library
use GuzzleHttp\Client;
$url = 'https://api.boldsign.com/v1-beta/template/edit?templateId={templateId}';
$headers = [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '{API-KEY}' // Replace {API-KEY} with your actual API key
];
$data = [
    "title" => "A new title for template",
    "EnableSigningOrder" => false,
    "roles" => [
        [
            "name" => "Manager",
            "index" => 1,
            "defaultSignerName" => "Alex",
            "defaultSignerEmail" => "alexgayle@cubeflakes.com",
            "signerOrder" => 1,
            "signerType" => "Signer",
            "formFields" => [
                [
                    "id" => "Signature1",
                    "type" => "Signature",
                    "isRequired" => true,
                    "bounds" => [
                        "x" => 625.0,
                        "y" => 293.0,
                        "width" => 124.0,
                        "height" => 32.0
                    ],
                    "pageNumber" => 1
                ]
            ],
            "enableEditRecipients" => true,
            "enableDeleteRecipients" => true
        ]
    ]
];
$client = new Client();
try {
    $response = $client->request('PUT', $url, [
        'headers' => $headers,
        'json' => $data
    ]);
    $statusCode = $response->getStatusCode();
    $responseData = $response->getBody()->getContents();
    echo 'HTTP Status: ' . $statusCode . "\n";
    echo 'Response: ' . $responseData . "\n";
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . "\n";
}
 

Conclusion

By incorporating the Edit Template API into your application, you can make real-time changes to your templates effortlessly, thus ensuring your documents are up-to-date. This not only saves time but also enhances the accuracy and uniformity of your documents.

If you are not yet a BoldSign customer, please start a 30-day free trial today to experience all its great features. We value your feedback, so please share your thoughts in the comments section. If you have any questions or need more information about our services, don’t hesitate to schedule a demo or reach out to our support team through our support portal.

Picture of Starvritsa Buhungi

Starvritsa Buhungi

Starvritsa is a Technical Assistant at BoldSign, channelling her passion into crafting top-tier content for users through meticulous documentation. She creates content across various formats, including API tutorials, help articles, and comprehensive guides.

Share this blog

Picture of Starvritsa Buhungi

Starvritsa Buhungi

Starvritsa is a Technical Assistant at BoldSign, channelling her passion into crafting top-tier content for users through meticulous documentation. She creates content across 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 *