How to edit a template using API
The Edit Template API in BoldSign allows you to modify the properties of existing and draft templates. This could include modifying the title, description, document message, document title, roles, or form fields associated with the template.
You 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, it is limited to top-level properties. When dealing with nested properties within top-level objects, you 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. Now, you can modify the required properties within the nested object and send the updated template object to the edit template API.
Use the following codes to initiate the template editing process:
Code snippet
curl -X 'PUT' \ 'https://api.boldsign.com/v1-beta/template/edit?templateId={Your Template Id}' \ -H 'accept: */*' \ -H 'X-API-KEY: Your API Key' \ -H 'Content-Type: application/json;odata.metadata=minimal;odata.streaming=true' \ -d '{ "title": "Title of the template", "roles": [ { "name": "Customer", "index": 1, "signerOrder": 1, "defaultSignerName": "Alex", "defaultSignerEmail": "alexgayle@boldsign.dev", "signerType": "Signer", "locale": "EN", "formFields": [ { "id": "string", "fieldType": "Signature", "pageNumber": 1, "bounds": { "x": 100, "y": 100, "width": 200, "height": 20 }, "isRequired": true } ] } ] }'
var apiClient = new ApiClient("https://api.boldsign.com", "{API-KEY}"); var templateClient = new TemplateClient(apiClient); var formFields = new List<FormField> { 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<TemplateRole> { 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);
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)
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 require 'vendor/autoload.php'; 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", "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"; }
In the example above, replace templateId
with the actual ID of the template you want to edit and provide values for the properties that you want to update. When the above codes are executed, you can successfully edit and save an existing template.