--- title: "Creating a Transaction from a Template" slug: "creating-a-transaction-from-a-template" description: "Streamline your e-signature process with Templates and Layouts, automating document signing and enhancing workflow efficiency. Learn how to create transactions easily." updated: 2026-09-17T18:00:33Z published: 2026-09-17T18:00:33Z canonical: "docs.onespan.com/creating-a-transaction-from-a-template" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.onespan.com/llms.txt > Use this file to discover all available pages before exploring further. # Creating a Transaction from a Template ## Java SDK To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/create-package-template-replacing-placeholder-example-java-sdk/) 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](/v1/docs/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: ```java 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](/v1/docs/managing-signature-placeholders) are replaced with a signer. Finally, use the OneSpan Sign TemplateService to create your transaction from your template. ```java 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](https://community.onespan.com/documentation/onespan-sign/codeshare/create-package-template-replacing-placeholders-net-sdk/) 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](/v1/docs/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: ```csharp 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](/v1/docs/managing-signature-placeholders) are replaced with a signer. Finally, use the OneSpan Sign TemplateService to create your transaction from your template. ```csharp 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](https://community.onespan.com/documentation/onespan-sign/codeshare/create-package-template-replacing-placeholders-rest-api/) 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](/v1/docs/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: ```http 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](/v1/docs/managing-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 ```http POST /api/packages/{templateId}/clone ``` > The following properties are not cloned from the template to the new transaction: > > - `deliverDocumentsByEmail` > - `reassign` > > These properties are not inherited from the template and must be explicitly defined in the Request Payload. We recommend that you do not use the same name for the cloned template. Using the same name will overwrite (delete) the original template. #### HTTP Headers ```http Accept: application/json        Content-Type: application/json        Authorization: Basic api_key ``` #### Request Payload ```json {        "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 ```json {        "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](https://community.onespan.com/documentation/onespan-sign/codeshare/create-package-from-template-with-replacing-placeholder-example-apex-sdk/) 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](/v1/docs/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](/v1/docs/managing-signature-placeholders) are replaced with a signer. ```plaintext 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{signer1};            role1.id = placeholder1Id;            // Use role id to match placeholder            pkg.roles = new List{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.