Create a Package From a Template

This following guide shows you how to create a package from a template.

Templates are a powerful tool that enable a sender to quickly create a new package (transaction in the new UI) by using a previous one as a blueprint. Once your template has been created, it can be used as an archetype in any subsequently created package.

The Code

The first step is to retrieve the ID of your template. You can either get this from the UI by browsing to your template and look at the address bar or by retrieving your templates using the eSignLive client. Once you have your id, you create a new PackageId object, as shown below:

PackageId templateId = new PackageId("ncE7Lf7h9EMvqEm7FMayLvJTJ68=");

If you haven’t created a template yet, you can follow this feature guide on how to create templates with the Java SDK. In my example, I will be updating the placeholder with a signer. Placeholders can be used if the identity of a signer will be determined at a later date, such as when creating a document package from a template. Placeholders can be assigned signatures just as if they were a regular signer. All placeholders need to have been replaced by real signers before a package can be sent for signing. Placeholders are identified by an ID instead of an email, since they have no email.

DocumentPackage newPackage = PackageBuilder.newPackageNamed(PACKAGE_NAME)
		.describedAs(PACKAGE_DESCRIPTION)
		.withEmailMessage(PACKAGE_EMAIL_MESSAGE)
		.withSigner(SignerBuilder.newSignerWithEmail(email2)
		          .withFirstName(PACKAGE_SIGNER_FIRST)
		          .withLastName(PACKAGE_SIGNER_LAST).replacing(new Placeholder(PLACEHOLDER_ID)))
		.build();

PackageId packageId = eslClient.getTemplateService().createPackageFromTemplate(templateId, newPackage);

Then, you will need to create your DocumentPackage object with any parameters you wish to update, as shown in the sample code above. Any parameter you don’t specify in the DocumentPackage object creation will be pulled from the template. Finally, you use the eSignLive TemplateService to create your package from your template.

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and browse to your DRAFT folder, you will find your newly created package, as shown in the screenshot below.

Capture

Get the Code

Templates are a powerful tool that enable a sender to quickly create a new package (transaction in the new UI) by using a previous one as a blueprint. Once your template has been created, it can be used as an archetype in any subsequently created package.

The Code

The first step is to retrieve the ID of your template. You can either get this from the UI by browsing to your template and look at the address bar or by retrieving your templates using the eSignLive client. Once you have your id, you create a new PackageId object, as shown below:

PackageId templateId = new PackageId("ncE7Lf7h9EMvqEm7FMayLvJTJ68=");

If you haven’t created a template yet, you can follow this feature guide on how to create templates with the .NET SDK. In my example, I will be updating the placeholder with a signer. Placeholders can be used if the identity of a signer will be determined at a later date, such as when creating a document package from a template. Placeholders can be assigned signatures just as if they were a regular signer. All placeholders need to have been replaced by real signers before a package can be sent for signing. Placeholders are identified by an ID instead of an email, since they have no email.

DocumentPackage newPackage = PackageBuilder.NewPackageNamed(PackageName)
                .DescribedAs(PACKAGE_DESCRIPTION)
                .WithEmailMessage(PACKAGE_EMAIL_MESSAGE)
                .WithSigner(SignerBuilder.NewSignerWithEmail(email2)
                        .WithFirstName(PACKAGE_SIGNER_FIRST)
                        .WithLastName(PACKAGE_SIGNER_LAST).Replacing(new Placeholder(PLACEHOLDER_ID)))
                 .Build();

packageId = eslClient.CreatePackageFromTemplate(templateId, newPackage);

Then, you will need to create your DocumentPackage object with any parameters you wish to update, as shown in the sample code above. Any parameter you don’t specify in the DocumentPackage object creation will be pulled from the template. Finally, you use the eSignLive client to create your package from your template.

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and browse to your DRAFT folder, you will find your newly created package, as shown in the screenshot below.

Capture

Get the Code

Templates are a powerful tool that enable a sender to quickly create a new package (transaction in the new UI) by using a previous one as a blueprint. Once your template has been created, it can be used as an archetype in any subsequently created package.

The Code

The first step is to retrieve the id of your template. You can either get this from the UI by browsing to your template and look at the address bar or by retrieving your templates by doing a GET https://sandbox.esignlive.com/api/packages?type=TEMPLATE request to retrieve your templates.

string templateId = "ncE7Lf7h9EMvqEm7FMayLvJTJ68=";

If you haven’t created a template yet, you can follow this feature guide on how to create templates with the REST API. In my example, I will be updating the placeholder with a signer. Placeholders can be used if the identity of a signer will be determined at a later date, such as when creating a document package from a template. Placeholders can be assigned signatures just as if they were a regular signer. All placeholders need to have been replaced by real signers before a package can be sent for signing. Placeholders are identified by an ID instead of an email, since they have no email.

Then, you will need to build your JSON with any parameters you wish to update, as shown above. Any parameter you don’t specify in the JSON payload will be pulled from the template. Finally, you will need to make a POST request to URI below in order to create your package from your template:

HTTP Request
POST /api/packages/{packageId}/clone

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

Request Payload

{
  "name":"Package created from template through REST API",
  "description":"Package created with the eSignLive REST API",
  "emailMessage":"This message should be delivered to all signers",
  "autocomplete":true,
  "type":"PACKAGE",
  "visibility":"ACCOUNT",
  "due":null,
  "language":"en",
  "status" : "DRAFT",
  "roles": [
    {
      "id": "PlaceholderId1",
      "type": "SIGNER",
      "signers": [
        {
          "id": "PlaceholderId1",
          "firstName": "Patty",
          "lastName": "Gallant",
          "email": "patty.galant@mailinator.com"
        }
      ],
      "name": "PlaceholderId1"
    }
  ]
}

For a complete description of each field, take a look at the JSON Properties section below.

Response Payload

{
    "id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="
}

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and browse to your DRAFT folder, you will find your newly created package, as shown in the screenshot below.

Capture

Get the Code

JSON Properties

Property Type Editable Required Default Sample Value(s)
status string Yes No DRAFT DRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
name string Yes No n/a Package created from template through REST API
description string Yes No n/a Package created with the eSignLive REST API
emailMessage string Yes No n/a This message should be delivered to all signers
autoComplete boolean Yes No true true / false
type string Yes No PACKAGE PACKAGE / TEMPLATE / LAYOUT
visibility string Yes No ACCOUNT ACCOUNT / SENDER
due string Yes No null 2017-08-26
language string Yes No en en / fr / es …
roles
id string Yes No n/a PlaceholderId1
name string Yes No n/a PlaceholderId1
type string Yes No SIGNER SIGNER / SENDER
signers
email string Yes Yes n/a patty.galant@mailinator.com
firstName string Yes Yes n/a Patty
lastName string Yes Yes n/a Galant
phone string Yes No n/a 514-555-8888
id string Yes No n/a PlaceholderId1
company string Yes No n/a Acme Inc.
title string Yes No n/a Managing Director