1. Creating and Sending a Package

This guide shows you how to create and send your first document package.

This guide will cover how to: download the .NET SDK and Microsoft Visual Studio, create and configure a C# project, and create and send a document package (transaction in the new UI).

Before you can write your code, you will need to set up your environment to use the .NET SDK.

Downloading the .NET SDK

Before you can use the .NET SDK, you will need to download it. Below is the link where you can download the .NET SDK.

Download the .NET SDK

Downloading Microsoft Visual Studio

This guide uses Microsoft Visual Studio 2017. You can use something else, but everything in this guide will be described using Visual Studio. Below is a link to download where you can download it.

Download Microsoft Visual Studio Community 2017

Create and Send a Package

Now that you have the necessary tools, you can go ahead and get started.

Create and Configure Your C# Project

After opening Visual Studio, go to File -> New -> Project and choose Get Started-> Console App from the templates. Give your project a name. For example, “CreateAndSendPackage”.


Select OK. You will now see your solution/project in the Solution Explorer.

Next, add the .NET SDK as a reference by right clicking on References, in your project, in the Solutions Explorer. Choose “Add Reference…” In the dialog that pops up, choose “Browse”, select the “Browse…” button at the bottom, navigate to where you unzipped the .NET SDK, select the three .dll files, and choose Add.


Finally, right click on your project, select Add -> New Item…, select the Code section in the pop-up, choose Code File, name the file whatever you want (e.g. “CreateAndSendPackge.cs”), and select Add.


You will now see this file in your project in the Solution Explorer.

The Code

This segment of the guide will breakdown the code section by section. You can get the complete sample code from the Developer Community Code Share, here.

The first few lines define the libraries you will use.

using System;
using System.IO;
using Silanis.ESL.SDK;
using Silanis.ESL.SDK.Builder;

The next few lines define your connection settings for OneSpan Sign. Be sure to replace YOUR_API_KEY with your API key. You can find this value by logging into OneSpan Sign and going to the ACCOUNT tab.

private static String apiUrl = "https://sandbox.esignlive.com/api";
// USE https://apps.esignlive.com/api FOR PRODUCTION
private static String apiKey = "YOUR_API_KEY";

The first thing you do is connect to the OneSpan Sign client using the API URL and API key you defined above.

EslClient eslClient = new EslClient(apiKey, apiUrl);

In the next line, you create a FileStream and read in the file you are wanting to upload with your package. Make sure you replace the placeholder text with the location of your PDF file.

FileStream fs = File.OpenRead("PATH_TO_YOUR_PDF");

Next, the package is created.

DocumentPackage superDuperPackage = PackageBuilder
 	.NewPackageNamed("Test Package .NET")

Then, the signers are added to the package.

                      .WithFirstName("Signer First Name")
                      .WithLastName("Signer Last Name")
     	              .WithFirstName("Your First Name")
                      .WithLastName("Your Last Name"))

Next, the document is added, including signature boxes for required signers.

                    	.FromStream(fs, DocumentType.PDF)
                       	    .AtPosition(175, 165))
                       	    .AtPosition(550, 165))

With the package completely defined, you now build the package and send it.

PackageId packageId = eslClient.CreatePackageOneStep(superDuperPackage);

Running Your Code

Execute this code by selecting Start from the toolbar. After doing this, you should be able to log into OneSpan Sign account and view the package you just created.


Get the Code