Creating a Transaction from a Template
  • 10 Oct 2024
  • 8 Minutes à lire
  • Sombre
    Lumière
  • PDF

Creating a Transaction from a Template

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

Java SDK.NET SDKREST APIAPEX SDK

Java SDK

To download the full code sample see our Code Share site.

Templates and Layouts fulfill the same goal of automating the e-signature process by shortening the time it takes to send documents that include several signature blocks and data fields. Templates are ideal to use at the transaction level – you can pre-define your signers, documents, signature locations and e-signature workflows to streamline the e-signature process. A Layout on the other hand, is a type of template that allows you to create pre-defined locations for your signature blocks and data fields within a document. It acts like a ‘marker’ where signature blocks and data fields will sit in the document. Layouts are helpful for users who frequently send forms that may be slightly different per recipient but signature blocks and data fields remain in the same location throughout the document. What’s more, you can use multiple Layouts per document, and apply them to individual pages within your transaction.

This topic explains how to create a transaction using an existing template. If you haven't yet created a template, see Creating a Template.

To begin, retrieve the Template ID of the template that you want to use for your transaction. Your Template ID can be found by browsing to the template in the UI and looking in the address bar, or by using the OneSpan Sign client.

Once you have retrieved your Template ID you can create a new PackageID. The following code will do this:

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

Then, create your DocumentPackage object with any parameters you wish to update, as shown in the sample code below. Any parameter that is not specified in the DocumentPackage object will use the parameters in the template. In this example, signature placeholders are replaced with a signer.

Finally, use the OneSpan Sign TemplateService to create your transaction from your template.

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);

Results

After running your code, you will see your newly created transaction on the OneSpan Sign Drafts page.

.NET SDK

To download the full code sample see our Code Share site.

Templates and Layouts fulfill the same goal of automating the e-signature process by shortening the time it takes to send documents that include several signature blocks and data fields. Templates are ideal to use at the transaction level – you can pre-define your signers, documents, signature locations and e-signature workflows to streamline the e-signature process. A Layout on the other hand, is a type of template that allows you to create pre-defined locations for your signature blocks and data fields within a document. It acts like a ‘marker’ where signature blocks and data fields will sit in the document. Layouts are helpful for users who frequently send forms that may be slightly different per recipient but signature blocks and data fields remain in the same location throughout the document. What’s more, you can use multiple Layouts per document, and apply them to individual pages within your transaction.

This topic explains how to create a transaction using an existing template. If you haven't yet created a template, see Creating a Template.

To begin, retrieve the Template ID of the template that you want to use for your transaction. Your Template ID can be found by browsing to the template in the UI and looking in the address bar, or by using the OneSpan Sign client.

Once you have retrieved your Template ID you can create a new PackageID. The following code will do this:

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

Then, create your DocumentPackage object with any parameters you wish to update, as shown in the sample code below. Any parameter that is not specified in the DocumentPackage object will use the parameters in the template. In this example, signature placeholders are replaced with a signer.

Finally, use the OneSpan Sign TemplateService to create your transaction from your template.

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);

Results

After running your code, you will see your newly created transaction on the OneSpan Sign Drafts page.

REST API

To download the full code sample see our Code Share site.

Templates and Layouts fulfill the same goal of automating the e-signature process by shortening the time it takes to send documents that include several signature blocks and data fields. Templates are ideal to use at the transaction level – you can pre-define your signers, documents, signature locations and e-signature workflows to streamline the e-signature process. A Layout on the other hand, is a type of template that allows you to create pre-defined locations for your signature blocks and data fields within a document. It acts like a ‘marker’ where signature blocks and data fields will sit in the document. Layouts are helpful for users who frequently send forms that may be slightly different per recipient but signature blocks and data fields remain in the same location throughout the document. What’s more, you can use multiple Layouts per document, and apply them to individual pages within your transaction.

This topic explains how to create a transaction using an existing template. If you haven't yet created a template, see Creating a Template.

To begin, retrieve the Template ID of the template that you want to use for your transaction. Your Template ID can be found by browsing to the template in the UI and looking in the address bar, or by using the following code:

 GET https://sandbox.esignlive.com/api/packages?type=TEMPLATE

Then, you will need to build your JSON with any parameters you wish to update, as shown in the sample code below. Any parameter that is not specified in the JSON payload will be pulled from the template. In this example, signature placeholders are replaced with a signer.

Finally, you will need to make a POST request to the URI below. This will create your transaction from your template:

HTTP Request

POST /api/packages/{templateId}/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 OneSpan Sign 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@example.com"
                }
            ],
            "name": "PlaceholderId1"
        }
    ]
}

For a complete description of each field, see the Request Payload table below.

Response Payload

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

Results

After running your code, you will see your newly created transaction on the OneSpan Sign Drafts page.

Request Payload Table

Property

Type

Editable

Required

Default

Sample Values

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@example.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

APEX SDK

To download the full code sample see our Code Share site.

Templates and Layouts fulfill the same goal of automating the e-signature process by shortening the time it takes to send documents that include several signature blocks and data fields. Templates are ideal to use at the transaction level – you can pre-define your signers, documents, signature locations and e-signature workflows to streamline the e-signature process. A Layout on the other hand, is a type of template that allows you to create pre-defined locations for your signature blocks and data fields within a document. It acts like a ‘marker’ where signature blocks and data fields will sit in the document. Layouts are helpful for users who frequently send forms that may be slightly different per recipient but signature blocks and data fields remain in the same location throughout the document. What’s more, you can use multiple Layouts per document, and apply them to individual pages within your transaction.

This topic explains how to create a transaction using an existing template. If you haven't yet created a template, see Creating a Template.

To begin, retrieve the Template ID of the template that you want to use for your transaction. Your Template ID can be found by browsing to the template in the UI and looking in the address bar, or by using the OneSpan Sign client.

Once you have retrieved your Template ID you can create a new PackageID. Create your DocumentPackage object with any parameters you wish to update, as shown in the sample code below. Any parameter that is not specified in the DocumentPackage object will use the parameters in the template. In this example, signature placeholders are replaced with a signer.

ESignLiveAPIObjects.Package_x pkg = new ESignLiveAPIObjects.Package_x();

// Set basic package info
pkg.name = 'Create Package From Template - ' + Datetime.now().format();
pkg.description = 'This is a package created from template.';
pkg.emailMessage = 'This is an email message.';

// Build actual Role in replacement of placeholder
String placeholder1Id = 'placeholder1';
ESignLiveAPIObjects.Role role1 = new ESignLiveAPIObjects.Role();
ESignLiveAPIObjects.Signer signer1 = new ESignLiveAPIObjects.Signer();

signer1.firstName = 'signer1_firstname';
signer1.lastName = 'signer1_lastname';
signer1.email = 'signer1@mailiantor.com';
signer1.id = placeholder1Id;

role1.signers = new List<ESignLiveAPIObjects.Signer>{signer1};
role1.id = placeholder1Id;

// Use role id to match placeholder
pkg.roles = new List<ESignLiveAPIObjects.Role>{role1};
pkg = sdk.helper.createPackageFromTemplate(pkg, 'E-_tmDsICwCkM2vqFuzVxF7NVQQ=');

System.debug('Package id: ' + pkg.id);

Results

After running your code, you will see your newly created transaction on the OneSpan Sign Drafts page.


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle