Sign Documents

This guide shows you how you can sign all documents in one call.

With OneSpan Sign SDK 11, you can sign all signatures in a transaction (previously document package) in one single call, instead of navigating through documents successively, and signing each signature sequentially.

Note that this feature is only available in the version 11 of sandbox and production (i.e. https://sandbox.esignlive.com and https://apps.esignlive.com).

The Code

You can get the complete example code from the Developer Community Code Share, here.

In this simple example, there are two recipients (i.e. signers) in the transaction: the sender and a client. There are also two documents in the transaction. A signature for each recipient is required per document. Furthermore, text anchors is used to position the signatures on the documents. If you need more information on text anchors, you can read this previous guide. Below is a sample code on how you would setup your transaction:

                //Package
		PackageBuilder packageToBuild = PackageBuilder.newPackageNamed("Sign Documents Test");
		
		//Sender
		SignerBuilder signer1 = SignerBuilder.newSignerWithEmail("sender@example.com")
				.withFirstName("Haris")
				.withLastName("Haidary")
				.withCustomId("Sender");
		//Client
		SignerBuilder signer2 = SignerBuilder.newSignerWithEmail("client@example.com")
				.withFirstName("John")
				.withLastName("Smith")
				.withCustomId("Signer");
		
		//Sender signature on first document
		SignatureBuilder signature1 = SignatureBuilder.signatureFor("sender@example.com")
				.withPositionAnchor(TextAnchorBuilder.newTextAnchor("Signature of the Contractor")
                        .atPosition(TextAnchorPosition.TOPLEFT)
                        .withSize(150, 40)
                        .withOffset(0, -50)
                        .withCharacter(0)
                        .withOccurence(0));
		
		//Client signature on first document
		SignatureBuilder signature2 = SignatureBuilder.signatureFor("client@example.com")
				.withPositionAnchor(TextAnchorBuilder.newTextAnchor("Signature of the Client")
                        .atPosition(TextAnchorPosition.TOPLEFT)
                        .withSize(150, 40)
                        .withOffset(0, -50)
                        .withCharacter(0)
                        .withOccurence(0));

                //First document
		DocumentBuilder document1 = DocumentBuilder.newDocumentWithName("Cleaning Contract")
				.fromFile("DOC_FILE_PATH")
				.withSignature(signature1)
				.withSignature(signature2);

                //Build package
		DocumentPackage packageToSend = packageToBuild.withSigner(signer1).withSigner(signer2).withDocument(document1).withDocument(document2).build();
		//Create and send package
		PackageId packageId = client.createAndSendPackage(packageToSend);
		
		//sign all documents for sender
		client.signDocuments(packageId);

The last line in the sample code above will automatically sign all documents for the sender. It is important to note this feature will not work for capture signatures. If you need a comparison to the basic document object creation or if this your first time creating a transaction with the Java SDK, see this guide.

Running Your Code

You can now go ahead and run your code. Once you’ve done so, if you login to OneSpan Sign, you will see a checkmark next to the sender in your transaction view. This confirms that all signatures for the sender has been signed.

Web UI

Get the Code

With OneSpan Sign SDK 11, you can sign all signatures in a transaction (previously document package) in one single call, instead of navigating through documents successively, and signing each signature sequentially.

Note that this feature is only available in the version 11 of sandbox and production (i.e. https://sandbox.esignlive.com and https://apps.esignlive.com).

The Code

You can get the complete example code from the Developer Community Code Share, here.

In this simple example, there are two recipients (i.e. signers) in the transaction: the sender and a client. There are also two documents in the transaction. A signature for each recipient is required per document. Furthermore, text anchors is used to position the signatures on the documents. If you need more information on text anchors, you can read this previous guide. Below is a sample code on how you would setup your transaction:

        //Package
        PackageBuilder packageToBuild = PackageBuilder.NewPackageNamed("Sign Documents Test");

        //Sender
        SignerBuilder signer1 = SignerBuilder.NewSignerWithEmail("sender@example.com")
                .WithFirstName("Haris")
                .WithLastName("Haidary")
                .WithCustomId("Sender");
        //Client
        SignerBuilder signer2 = SignerBuilder.NewSignerWithEmail("client@example.com")
                .WithFirstName("John")
                .WithLastName("Smith")
                .WithCustomId("Signer");

        //Sender signature on first document
        SignatureBuilder signature1 = SignatureBuilder.SignatureFor("sender@example.com")
                .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("Signature of the Contractor")
                        .AtPosition(TextAnchorPosition.TOPLEFT)
                        .WithSize(150, 40)
                        .WithOffset(0, -50)
                        .WithCharacter(0)
                        .WithOccurrence(0));
	
        //Client signature on first document
        SignatureBuilder signature2 = SignatureBuilder.SignatureFor("client@example.com")
                .WithPositionAnchor(TextAnchorBuilder.NewTextAnchor("Signature of the Client")
                        .AtPosition(TextAnchorPosition.TOPLEFT)
                        .WithSize(150, 40)
                        .WithOffset(0, -50)
                        .WithCharacter(0)
                        .WithOccurrence(0));

 

        //First document
        DocumentBuilder document1 = DocumentBuilder.NewDocumentNamed("Cleaning Contract")
                .FromFile("DOC_FILE_PATH")
                .WithSignature(signature1)
                .WithSignature(signature2);

        //Build package
        DocumentPackage packageToSend = packageToBuild.WithSigner(signer1).WithSigner(signer2).WithDocument(document1).WithDocument(document2).Build();

        //Create and send package
        PackageId packageId = client.CreateAndSendPackage(packageToSend);
        
        //Sign all documents for sender
        client.SignDocuments(packageId);

The last line in the sample code above will automatically sign all documents for the sender. It is important to note this feature will not work for capture signatures. If you need a comparison to the basic document object creation or if this your first time creating a transaction with the .NET SDK, see this guide.

Running Your Code

You can now go ahead and run your code. Once you’ve done so, if you login to OneSpan Sign, you will see a checkmark next to the sender in your transaction view. This confirms that all signatures for the sender has been signed.

Web UI

Get the Code

With OneSpan Sign version 11, you can sign all signatures in a transaction for a sender in one single call, instead of navigating through documents successively, and signing each signature sequentially.

Note that this feature is only available in the version 11 of sandbox and production (i.e. https://sandbox.esignlive.com and https://apps.esignlive.com).

The Code

You can get the complete example code from the Developer Community Code Share, here.

In this simple example, there are two recipients (i.e. signers) in the transaction: the sender and a client. There are also two documents in the transaction. A signature for each recipient is required per document. Furthermore, text anchors is used to position the signatures on the documents. If you need more information on text anchors, you can read this previous guide. Below is a sample request on how you would setup your transaction:

HTTP Request
POST /api/packages

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

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"
Content-Type: application/pdf

%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj.... 

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
  "roles": [
    {
      "id": "Signer",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "John",
          "lastName": "Smith",
          "email": "signer@example.com"
        }
      ],
      "name": "Signer"
    },
    {
      "id": "Sender",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "Haris",
          "lastName": "Haidary",
          "email": "sender@example.com"
        }
      ],
      "name": "Sender"
    }
  ],
  "documents": [
    {
      "approvals": [
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "extract": false,
              "extractAnchor": {
                "text": "Signature of the Client",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPLEFT",
                "characterIndex": 0,
                "leftOffset": 0,
                "topOffset": -50
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            },
            {
              "value": null,
              "type": "INPUT",
              "binding": "{signer.name}",
              "extract": false,
              "extractAnchor": {
                "text": "(hereafter referred to as",
                "index": 0,
                "width": 150,
                "height": 20,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 0,
                "leftOffset": -175,
                "topOffset": -5
              },
              "left": 0,
              "subtype": "LABEL",
              "top": 0
            },
            {
              "value": null,
              "type": "INPUT",
              "binding": "{approval.signed}",
              "extract": false,
              "extractAnchor": {
                "text": "Date",
                "index": 0,
                "width": 75,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 4,
                "leftOffset": 10,
                "topOffset": -30
              },
              "left": 0,
              "subtype": "LABEL",
              "top": 0
            }
          ],
          "role": "Signer"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "extract": false,
              "extractAnchor": {
                "text": "Signature of the Contractor",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPLEFT",
                "characterIndex": 0,
                "leftOffset": 0,
                "topOffset": -50
              },
              "subtype": "FULLNAME"
            }
          ],
          "role": "Sender"
        }
      ],
      "id": "contract",
      "name": "Sample Contract"
    }
  ],
  "name": "Sign Documents Test",
  "type": "PACKAGE",
  "language": "en",
  "autoComplete": true,
  "status": "SENT"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--

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

Response Payload

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

Once you have sent your transaction, you make a POST request to:

HTTP Request
POST /api/packages/{packageId}/documents/signed_documents

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

{
  "documents": [
    {
      "id": "contract",
      "name": "Sample Contract"
    }
  ]
}

This last request will automatically sign all documents for the sender. It is important to note this feature will not work for capture signatures. If you need a comparison to the basic document object creation or if this your first time creating a transaction with the REST API, see this guide.

Running Your Code

You can now go ahead and run your code. Once you’ve done so, if you login to OneSpan Sign, you will see a checkmark next to the sender in your transaction view. This confirms that all signatures for the sender has been signed.

Web UI

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
autoComplete boolean Yes No true true / false
type string Yes No PACKAGE PACKAGE / TEMPLATE / LAYOUT
name string Yes Yes n/a Text Anchor Extraction Example REST API
language string Yes Yes en en / fr / de …
documents
name string Yes No n/a Sample Contract
approvals
role string Yes No n/a client
fields
type string Yes Yes n/a SIGNATURE / INPUT
extract boolean Yes No false true / false
subtype string Yes Yes n/a FULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
binding string Yes No null null / {approval.signed} / {signer.title} / {signer.name} / {signer.company}
left integer Yes No 0 0 / 10 / 20 …
top integer Yes No 0 0 / 10 / 20 …
extractAnchor
text string Yes Yes n/a Signature of the Client
anchorPoint string Yes Yes n/a TOPLEFT / TOPRIGHT / BOTTOMLEFT / BOTTOMRIGHT
index integer Yes No 0 0 / 1 / 2 …
width integer Yes No 200 150
characterIndex integer Yes No 0 0
height integer Yes No 50 40
leftOffset integer Yes No 0 40
rightOffset integer Yes No 0 -10
roles
id string Yes No n/a client
index integer Yes No 0 1 / 2 / 3 …
name string Yes No n/a client
type string Yes No SIGNER SIGNER / SENDER
signers
email string Yes Yes n/a john.smith@example.com
firstName string Yes Yes n/a John
lastName string Yes Yes n/a Smith
id string Yes No n/a client