Templates are a powerful tool that enable a sender to quickly create a new document package by using a previous one as a blueprint. When a package has been saved as a template, it can be used as an archetype for any subsequently created package.

The Code

If you don't know how to create a template, you can follow this feature guide. Retrieving templates is done with the OneSpan Sign PackageService() and are returned to you as a Page object.
int i = 1;
ArrayList<String> templateIds = new ArrayList<String>();
		
Page<DocumentPackage> templates = eslClient.getPackageService().getTemplates(new PageRequest(i ,50));
		
for (DocumentPackage template : templates) {
	System.out.println(String.format("Template name: %s with id %s", template.getName(), template.getId()));
	templateIds.add(template.getId().toString());
}
To update a template, you first need to create a new PackageId object using the template id. Then, you can retrieve your template using this PackageId object and change any settings you wish. Once you've made the necessary changes, you use the TemplateService() to update your template.
PackageId templateId = new PackageId(templateIds.get(0));
		
DocumentPackage templateToUpdate = eslClient.getPackage(templateId);
		
templateToUpdate.setName("This template has been updated");
		
eslClient.getTemplateService().updateTemplate(templateToUpdate);
Finally, to delete a template, you use the PackageService().
eslClient.getPackageService().deletePackage(templateId);

Get the Code

Templates are a powerful tool that enable a sender to quickly create a new document package by using a previous one as a blueprint. When a package has been saved as a template, it can be used as an archetype for any subsequently created package.

The Code

If you don't know how to create a template, you can follow this feature guide. Retrieving templates is done with the OneSpan Sign PackageService() and are returned to you as a Page object.
int i = 1;
ArrayList templateIds = new ArrayList();
Page<DocumentPackage> templates = eslClient.PackageService.GetTemplates(new PageRequest(i, 50));
foreach (DocumentPackage template in templates)
{
      Debug.WriteLine(string.Format("Template name: {0} with id {1}", template.Name, template.Id));
      templateIds.Add(template.Id.ToString());
}
To update a template, you first need to create a new PackageId object using the template id. Then, you can retrieve your template using this PackageId object and change any settings you wish. Once you've made the necessary changes, you use the TemplateService() to update your template.
PackageId templateId = new PackageId(templateIds[0].ToString());
DocumentPackage templateToUpdate = eslClient.GetPackage(templateId);
templateToUpdate.Name = "This template has been updated";
eslClient.TemplateService.Update(templateToUpdate);
Finally, to delete a template, you use the PackageService().
eslClient.PackageService.DeletePackage(templateId);

Get the Code

Templates are a powerful tool that enable a sender to quickly create a new document package by using a previous one as a blueprint. When a package has been saved as a template, it can be used as an archetype for any subsequently created package.

The Code

If you don't know how to create a template, you can follow this feature guide. You can retrieve your templates like so:

HTTP Request

GET /api/packages?type=TEMPLATE&from=0&to=100

HTTP Headers

Accept: application/json Content-Type: application/json Authorization: Basic api_key

Response Payload

{
    "results": [
        {
            "roles": [
                {
                    "id": "a32f8b14-2771-4000-9ab6-19b8e9aae4bc",
                    "emailMessage": null,
                    "attachmentRequirements": [],
                    "locked": false,
                    "reassign": false,
                    "specialTypes": [],
                    "data": null,
                    "index": 2,
                    "type": "SIGNER",
                    "signers": [],
                    "name": "Placeholder2"
                },
                {
                    "id": "fad2c2d5-d75c-4bac-8707-3d9a555b8a07",
                    "emailMessage": null,
                    "attachmentRequirements": [],
                    "locked": false,
                    "reassign": false,
                    "specialTypes": [],
                    "data": null,
                    "index": 1,
                    "type": "SIGNER",
                    "signers": [],
                    "name": "Placeholder1"
                },
                {
                    "id": "YV68HNuhshUS",
                    "emailMessage": null,
                    "attachmentRequirements": [],
                    "locked": false,
                    "reassign": false,
                    "specialTypes": [],
                    "data": null,
                    "index": 0,
                    "type": "SENDER",
                    "signers": [
                        {
                            "group": null,
                            "language": "en",
                            "signature": {
                                "handdrawn": "AQAAADJI+a4cnf0t3Dlf0GqWJceCA+4AAwADAN8BAAADAAAAggPuAOgAAAACfyxAUkAlQCdAOUA6QDtAHEAtQBtACkAJQBVAFBIyfkA0QBVABkAYQCpAHEAtQC9ALkAtQDxAO0A6QEhAN0AlQCQyTjZAgEBwQIBAoFDSUOFQ8lDiUNJQ0lCiQHBAUCIXGVBSUCVQN1BJUDpQXVA9UE5QLlAuUDpQOVAkm1BhQLZAd0B7QFpAXUBPQTBAHkAdQAtAB2AmYBRgQmCAcJVwmHC5Mh42QFBAkECAQKBAsEDAQNBQ8VDyUPJQ81DTULRQg1ByUEGeIgQ6QDhAJ0AmQCZAFItwbHBtMhdBUCafUGJQcVCSUJFQoUDAQKBAsECBQHNAdEBEQDRABkAFYCdgR2BXYHhgd2CIYIVgdmBDYEJAUUBwQIFAkECwQLBA0EDAQLBAoEBwQGASG0xAc0BnQEhASkArQBxADEAKQAlABkAFMkVKUENQUVBBUGFQYVCRUKJQsVDCUNJQsUDQQKBAkEBwQFJAREAlIllVUHFQUVByUKFQslDSUNJQ9VDlUPZQ1lDWUKVQZVBEUCQyCxivr2BjYGRgdGB1YHZgZmBWYEdgRkAFQClAREBjQJNAk0CzQKNAs0CjQJNAQo9gRWBjYJNgs2DCYNRg1GCkYKRgY2Bkrg==",
                                "textual": null
                            },
                            "id": "ZQI8k6faVoM8",
                            "address": null,
                            "created": "2017-11-01T14:54:52Z",
                            "title": null,
                            "external": null,
                            "updated": "2017-11-01T14:54:52Z",
                            "phone": "",
                            "userCustomFields": [],
                            "company": "eSignLive",
                            "email": "[email protected]",
                            "firstName": "Haris",
                            "lastName": "Haidary",
                            "professionalIdentityFields": [],
                            "data": null,
                            "auth": {
                                "scheme": "NONE",
                                "challenges": []
                            },
                            "knowledgeBasedAuthentication": null,
                            "delivery": {
                                "email": true,
                                "download": true,
                                "provider": false
                            },
                            "name": "",
                            "specialTypes": []
                        }
                    ],
                    "name": "Owner"
                }
            ],
            "status": "DRAFT",
            "description": "",
            "language": "en",
            "id": "9VFZTf0vgi2rGEGHTozxZAXlm28=",
            "created": "2017-11-01T14:54:52Z",
            "autocomplete": true,
            "sender": {
                "status": "ACTIVE",
                "language": "en",
                "signature": {
                    "handdrawn": "AQAAADJI+a4cnf0t3Dlf0GqWJceCA+4AAwADAN8BAAADAAAAggPuAOgAAAACfyxAUkAlQCdAOUA6QDtAHEAtQBtACkAJQBVAFBIyfkA0QBVABkAYQCpAHEAtQC9ALkAtQDxAO0A6QEhAN0AlQCQyTjZAgEBwQIBAoFDSUOFQ8lDiUNJQ0lCiQHBAUCIXGVBSUCVQN1BJUDpQXVA9UE5QLlAuUDpQOVAkm1BhQLZAd0B7QFpAXUBPQTBAHkAdQAtAB2AmYBRgQmCAcJVwmHC5Mh42QFBAkECAQKBAsEDAQNBQ8VDyUPJQ81DTULRQg1ByUEGeIgQ6QDhAJ0AmQCZAFItwbHBtMhdBUCafUGJQcVCSUJFQoUDAQKBAsECBQHNAdEBEQDRABkAFYCdgR2BXYHhgd2CIYIVgdmBDYEJAUUBwQIFAkECwQLBA0EDAQLBAoEBwQGASG0xAc0BnQEhASkArQBxADEAKQAlABkAFMkVKUENQUVBBUGFQYVCRUKJQsVDCUNJQsUDQQKBAkEBwQFJAREAlIllVUHFQUVByUKFQslDSUNJQ9VDlUPZQ1lDWUKVQZVBEUCQyCxivr2BjYGRgdGB1YHZgZmBWYEdgRkAFQClAREBjQJNAk0CzQKNAs0CjQJNAQo9gRWBjYJNgs2DCYNRg1GCkYKRgY2Bkrg==",
                    "textual": null
                },
                "id": "ZQI8k6faVoM8",
                "address": {
                    "zipcode": "",
                    "address1": "",
                    "address2": "",
                    "city": "",
                    "country": "",
                    "state": ""
                },
                "created": "2016-05-05T19:30:13Z",
                "title": null,
                "external": null,
                "updated": "2016-05-05T19:30:13Z",
                "memberships": [],
                "phone": "+1 201-555-5555",
                "userCustomFields": [
                    {
                        "id": "policy_number_id",
                        "translations": [
                            {
                                "description": "Car Insurance Policy Number.",
                                "language": "en",
                                "id": "",
                                "data": null,
                                "name": "Policy Number"
                            }
                        ],
                        "data": null,
                        "value": "",
                        "name": ""
                    }
                ],
                "locked": null,
                "activated": null,
                "company": "eSignLive",
                "email": "[email protected]",
                "firstName": "Haris",
                "lastName": "Haidary",
                "professionalIdentityFields": [],
                "account": {
                    "owner": "ZQI8k6faVoM8",
                    "id": "3vD0Dc9Fh7wQ",
                    "created": "2016-05-05T19:30:13Z",
                    "providers": null,
                    "updated": "2016-05-05T19:30:13Z",
                    "company": {
                        "id": "jVWmyg4cyis8",
                        "address": {
                            "zipcode": null,
                            "address1": null,
                            "address2": null,
                            "city": null,
                            "country": null,
                            "state": null
                        },
                        "data": null,
                        "name": "eSignLive"
                    },
                    "customFields": [
                        {
                            "required": false,
                            "id": "policy_number_id",
                            "translations": [
                                {
                                    "description": "Car Insurance Policy Number.",
                                    "language": "en",
                                    "id": "",
                                    "data": null,
                                    "name": "Policy Number"
                                }
                            ],
                            "data": null,
                            "value": "123-456-789-0",
                            "name": ""
                        }
                    ],
                    "licenses": [
                        {
                            "status": "ACTIVE",
                            "created": "2016-05-05T19:30:13Z",
                            "paidUntil": "2020-05-05T00:00:00Z",
                            "transactions": [],
                            "plan": {
                                "group": "",
                                "description": "E-Sign Hundreds of Documents with Unlimited Signers",
                                "id": "sandbox",
                                "features": null,
                                "cycle": "YEAR",
                                "contract": "YEAR",
                                "freeCycles": null,
                                "quotas": [
                                    {
                                        "scope": "ACCOUNT",
                                        "cycle": null,
                                        "limit": 100,
                                        "target": "SENDER"
                                    },
                                    {
                                        "scope": "SENDER",
                                        "cycle": null,
                                        "limit": 500,
                                        "target": "DOCUMENT"
                                    },
                                    {
                                        "scope": "SENDER",
                                        "cycle": null,
                                        "limit": 500,
                                        "target": "STORAGE"
                                    }
                                ],
                                "original": null,
                                "data": null,
                                "price": {
                                    "amount": 0,
                                    "currency": {
                                        "id": "USD",
                                        "data": null,
                                        "name": "US Dollar"
                                    }
                                },
                                "name": "Sandbox"
                            }
                        }
                    ],
                    "logoUrl": "",
                    "data": null,
                    "name": "Haris Haidary"
                },
                "data": {
                    "serviceCredentials": "{}",
                    "showIntro": false
                },
                "type": "MANAGER",
                "name": "",
                "specialTypes": [],
                "hasDelegates": false
            },
            "documents": [
                {
                    "status": "",
                    "description": "",
                    "id": "b1bcf8fb96e7663fcf8d79b3d36ab03a409ffb5ac183ced6",
                    "approvals": [
                        {
                            "role": "a32f8b14-2771-4000-9ab6-19b8e9aae4bc",
                            "id": "f3L60CQtJ4w4",
                            "signed": null,
                            "accepted": null,
                            "data": null,
                            "fields": [
                                {
                                    "binding": null,
                                    "validation": null,
                                    "id": "FT055fW0IMEM",
                                    "page": 0,
                                    "subtype": "FULLNAME",
                                    "height": 52.0252180917263,
                                    "extract": false,
                                    "width": 234.98929138064383,
                                    "extractAnchor": null,
                                    "left": 241.80519113063812,
                                    "top": 605.0225778079033,
                                    "data": null,
                                    "type": "SIGNATURE",
                                    "value": "",
                                    "name": ""
                                }
                            ],
                            "name": ""
                        },
                        {
                            "role": "fad2c2d5-d75c-4bac-8707-3d9a555b8a07",
                            "id": "mEZ3ZWiNBYkE",
                            "signed": null,
                            "accepted": null,
                            "data": null,
                            "fields": [
                                {
                                    "binding": null,
                                    "validation": null,
                                    "id": "MGG8WGRTIEoJ",
                                    "page": 0,
                                    "subtype": "FULLNAME",
                                    "height": 51.99999809265137,
                                    "extract": false,
                                    "width": 234.9996913802624,
                                    "extractAnchor": null,
                                    "left": 221.99969185709955,
                                    "top": 514.000481146574,
                                    "data": null,
                                    "type": "SIGNATURE",
                                    "value": "",
                                    "name": ""
                                }
                            ],
                            "name": ""
                        }
                    ],
                    "pages": [
                        {
                            "id": "53659ae7eb53699b0e6027311a5b9db435984e896e1306cf_0_-1_1.png",
                            "height": 1030,
                            "left": 0,
                            "width": 796,
                            "top": 0,
                            "index": 0,
                            "version": 0
                        }
                    ],
                    "external": null,
                    "extract": false,
                    "data": {},
                    "signedHash": null,
                    "extractionTypes": [],
                    "signerVerificationToken": null,
                    "fields": [],
                    "index": 0,
                    "name": "sample_contract",
                    "size": 97332
                }
            ],
            "consent": null,
            "due": null,
            "emailMessage": "",
            "limits": null,
            "notarized": false,
            "settings": {
                "ceremony": {
                    "layout": {
                        "header": {
                            "feedback": true,
                            "breadcrumbs": true,
                            "globalActions": {
                                "confirm": true,
                                "download": true,
                                "hideEvidenceSummary": true,
                                "saveAsLayout": true
                            },
                            "globalNavigation": true,
                            "titleBar": null,
                            "sessionBar": true
                        },
                        "brandingBar": {
                            "logo": {
                                "link": "",
                                "src": "branding"
                            }
                        },
                        "iframe": false,
                        "footer": null,
                        "navigator": true
                    },
                    "inPerson": false,
                    "declineButton": true,
                    "declineReasons": [],
                    "disableDeclineOther": false,
                    "disableDownloadForUncompletedPackage": false,
                    "disableFirstInPersonAffidavit": false,
                    "disableInPersonAffidavit": false,
                    "disableOptOutOther": false,
                    "disableSecondInPersonAffidavit": false,
                    "documentToolbarOptions": null,
                    "events": {
                        "complete": {
                            "dialog": true,
                            "redirect": null
                        }
                    },
                    "handOver": null,
                    "hideCaptureText": false,
                    "hideLanguageDropdown": false,
                    "hidePackageOwnerInPerson": false,
                    "hideWatermark": false,
                    "maxAuthFailsAllowed": 3,
                    "optOutButton": true,
                    "optOutReasons": [],
                    "extractAcroFields": false,
                    "extractTextTags": false,
                    "style": null,
                    "enforceCaptureSignature": false
                }
            },
            "signedDocumentDelivery": null,
            "updated": "2017-11-01T14:55:35Z",
            "visibility": "SENDER",
            "data": {
                "senderVisible": false
            },
            "messages": [],
            "type": "TEMPLATE",
            "name": "Signing Order Sender",
            "notaryRoleId": null,
            "bulkSendable": true
        }
    ],
    "count": 11
}
To update a template, you first need to retrieve your template id. Then, you build your JSON payload with the parameters you wish to modify.

HTTP Request

PUT /api/packages/{templateId}

HTTP Headers

Accept: application/json Content-Type: application/json Authorization: Basic api_key

Request Payload

{
   "name": "Updating template name"
}
Finally, to delete a template, you make a DELETE request to:

HTTP Request

DELETE /api/packages/{templateId}

HTTP Headers

Accept: application/json Content-Type: application/json Authorization: Basic api_key

Get the Code

Request Payload

PropertyTypeEditableRequiredDefaultSample Value(s)
statusstringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
autoCompletebooleanYesNotruetrue / false
typestringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
namestringYesYesn/aDocument Attributes Example
trashedbooleanYesNofalsetrue / false
visibilitystringYesNoACCOUNTACCOUNT / SENDER
documents
namestringYesNon/asample doc
approvals
fields
subtypestringYesNon/aFULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
typestringYesNon/aSIGNATURE / INPUT
extractbooleanYesNofalsetrue / false
heightintegerYesNo5050 / 100 / 150 ...
leftintegerYesNo050 / 100 / 150 ...
pageintegerYesNo00 / 1 / 2 ...
topintegerYesNo050 / 100 / 150 ...
widthintegerYesNo20050 / 100 / 150 ...
rolestringYesNon/aClient1
data
DepartmentstringYesNon/a1806
EmployeestringYesNon/a135526
roles
idstringYesNon/aClient1
namestringYesNon/aClient1
typestringYesNoSIGNERSIGNER / SENDER
signers
emailstringYesYesn/a[email protected]
firstNamestringYesYesn/aJohn
lastNamestringYesYesn/aSmith
phonestringYesNon/a514-555-8888
idstringYesNon/aClient1
companystringYesNon/aAcme Inc.
titlestringYesNon/aManaging Director
Templates are a powerful tool that enable a sender to quickly create a new document package by using a previous one as a blueprint. When a package has been saved as a template, it can be used as an archetype for any subsequently created package.

The Code

If you don’t know how to create a template, you can follow this feature guide. Below sample code shows you how to loop through all your templates and returns you a list of template objects:
    	//Retrieving templates 
    	integer totalCount = getTemplateCount();
    	integer index = 1;
    	List<ESignLiveAPIObjects.package_x> templates = new List<ESignLiveAPIObjects.package_x>();
    	
    	System.debug('Total template count: ' + totalCount);
    	while(index < totalCount){
	    	templates.addAll(getTemplates(index,index+49));
	    	index += 50;
    	}
    	for(ESignLiveAPIObjects.package_x template: templates){
	    		System.debug('Template name: ' + template.name + ' with id: ' + template.id);
    	}
In the above code, there’re two encapsulated functions:
public integer getTemplateCount()
Which returns you the total amount of templates.
public List<ESignLiveAPIObjects.package_x> getTemplates(integer from_x, integer to)
Which returns you a list of template objects according to from and to index. Index starts from 1 and maximally returns you 100 results. To update a template, you first need to retrieve your template using template ID and change any settings you wish. Once you’ve made the necessary changes, you use the updatePackage () to update your template.
ESignLiveSDK sdk = new ESignLiveSDK();
ESignLiveAPIObjects.package_x template = sdk.getPackage('E-_tmDsICwCkM2vqFuzVxF7NVQQ=');
template.name = 'This template has been updated - ' + Datetime.now().format();
sdk.helper.updatePackage(template,'E-_tmDsICwCkM2vqFuzVxF7NVQQ=');
Finally, to delete a template, you use the deletePackage() function.
sdk.helper.deletePackage('E-_tmDsICwCkM2vqFuzVxF7NVQQ=');

Get the Code