Signatures

This following guide shows you how to add, update, and delete signatures on your documents.

The Code

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

To add a signature on a document, you will first need to create your Signature object using the OneSpan Sign SignatureBuilder, as shown below.

//Fullname signature style
Signature signature1 = SignatureBuilder.signatureFor("john.smith@mailinator.com")
				  .onPage(0)  
				  .atPosition(215, 510)
				  .withSize(200, 50)
				  .withId(new SignatureId("signature1"))
				  .build();

//Handwritten signature style
Signature signature2 = SignatureBuilder.captureFor("john.smith@mailinator.com")
				  .onPage(0)  
				  .atPosition(215, 510)
				  .withSize(200, 50)
				  .withId(new SignatureId("signature2"))
				  .build();
//Initials signature style
Signature signature3 = SignatureBuilder.initialsFor("john.smith@mailinator.com")
				  .onPage(0)  
				  .atPosition(215, 510)
				  .withSize(200, 50)
				  .withId(new SignatureId("signature3"))
				  .build(); 

DocumentPackage createdPackage = client.getPackageService().getPackage(packageId);

Once you have built your Signature object, you will need to retrieve your package using the OneSpan Sign client and then use the OneSpan Sign ApprovalService to add your signature on your document and pass the DocumentPackage, and Signature objects along with the document id String as parameters.

client.getApprovalService().addSignature(createdPackage, documentId, signature1);

Updating a signature is also done in a similar fashion.

Signature updatedSignature = SignatureBuilder.captureFor("john.smith@mailinator.com")
				  .onPage(0)  
				  .atPosition(215, 510)
				  .withSize(300, 50)
				  .withId(new SignatureId("signature1"))
				  .build();
		
List<Signature> signatures = new ArrayList();
signatures.add(updatedSignature);
		
DocumentPackage updatedPackage = client.getPackageService().getPackage(packageId);
client.getApprovalService().updateSignatures(updatedPackage, documentId, signatures);

It is important to note that when updating a signature, your new Signature object must have the same id as the signature you want to update. Finally, deleting a signature is also done with the ApprovalService. You will need to pass the PackageId, and SignatureId objects along with the document id String as parameters.

client.getApprovalService().deleteSignature(packageId, documentId, new SignatureId("signature1"));

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and head over to the document view of your package, you can view the added signature.

Capture

Get The Code

The Code

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

To add a signature on a document, you will first need to create your Signature object using the OneSpan Sign SignatureBuilder, as shown below.

//Fullname signature style
Signature signature1 = SignatureBuilder.SignatureFor("john.smith@mailinator.com")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(200, 50)
                      .WithId(new SignatureId("signature1"))
                      .Build();

//Handwritten signature style
Signature signature2 = SignatureBuilder.CaptureFor("john.smith@mailinator.com")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(200, 50)
                      .WithId(new SignatureId("signature2"))
                      .Build();

//Initials signature style
Signature signature3 = SignatureBuilder.InitialsFor("john.smith@mailinator.com")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(200, 50)
                      .WithId(new SignatureId("signature3"))
                      .Build();

DocumentPackage createdPackage = client.GetPackage(packageId);

Once you have built your Signature object, you will need to retrieve your package using the OneSpan Sign client and then use the OneSpan Sign ApprovalService to add your signature on your document and pass the DocumentPackage, and Signature objects along with the document id String as parameters.

client.ApprovalService.AddApproval(createdPackage, documentId, signature1);

Updating a signature is also done in a similar fashion.

Signature updatedSignature = SignatureBuilder.CaptureFor("john.smith@mailinator.com")
                      .OnPage(0)
                      .AtPosition(215, 510)
                      .WithSize(300, 50)
                      .WithId(new SignatureId("signature1"))
                      .Build();

IList<Signature> signatures = new List();
signatures.Add(updatedSignature);

DocumentPackage updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);

It is important to note that when updating a signature, your new Signature object must have the same id as the signature you want to update. Finally, deleting a signature is also done with the ApprovalService. You will need to pass the PackageId, and SignatureId objects along with the document id String as parameters.

client.ApprovalService.DeleteApproval(packageId, documentId, "signature1");

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and head over to the document view of your package, you can view the added signature.

Capture

Get The Code

The Code

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

The sample jsons below show you how to edit the “fields” object in order to add a signature (fullname, capture, and initials) on your document.

HTTP Request
POST /api/packages/{packageId}/documents/{documentId}/approvals

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

Request Payload

{
  "role": "Signer1",
  "id": "signature1",
  "fields": [
    {
      "top": 510,
      "left": 215,
      "width": 200,
      "height": 50,
      "page": 0,
      "type": "SIGNATURE",
      "subtype": "FULLNAME"
    }
  ]
}
{
  "role": "Signer1",
  "id": "signature1",
  "fields": [
    {
      "top": 510,
      "left": 215,
      "width": 200,
      "height": 50,
      "page": 0,
      "type": "SIGNATURE",
      "subtype": "CAPTURE"
    }
  ]
}
{
  "role": "Signer1",
  "id": "signature1",
  "fields": [
    {
      "top": 510,
      "left": 215,
      "width": 200,
      "height": 50,
      "page": 0,
      "type": "SIGNATURE",
      "subtype": "INITIALS"
    }
  ]
}

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

Response Payload

{
  "signed": null,
  "role": "Signer1",
  "accepted": null,
  "id": "signature1",
  "data": null,
  "fields": [
    {
      "top": 50,
      "left": 300,
      "height": 50,
      "page": 0,
      "type": "SIGNATURE",
      "validation": null,
      "binding": null,
      "width": 200,
      "subtype": "FULLNAME",
      "extract": false,
      "extractAnchor": null,
      "id": "tx1qz7485780",
      "data": null,
      "value": "",
      "name": ""
    }
  ],
  "name": ""
}

If you want an example of a basic document package creation for comparison, you can follow this guide.

To update a signature, you will need to make a PUT request to:

https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}/approvals/{signatureId}/

With the updated signature parameters:

{
  "role": "Signer1",
  "fields": [
    {
      "top": 510,
      "left": 215,
      "width": 300,
      "height": 50,
      "id": "signature1",
      "page": 0,
      "type": "SIGNATURE",
      "subtype": "CAPTURE"
    }
  ]
}

It is important to note that when updating a signature, your new signature object must have the same id as the signature you want to update. Finally, deleting a signature is done by making a DELETE request to:

https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}/approvals/{signatureId}/

Running Your Code

Once you’ve run your code, if you login to OneSpan Sign and head over to the document view of your package, you can view the added signature.

Capture

Get The Code

JSON Properties

Property Type Editable Required Default Sample Value(s)
role string Yes No n/a Signer1
id string Yes No n/a signature1
fields
top integer Yes No 0 510
left integer Yes No 0 215
width integer Yes No 200 200
height integer Yes No 50 50
page integer Yes No 0 0
type string Yes No n/a SIGNATURE / INPUT
subtype string Yes No n/a FULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST