Java SDK
To download the full code sample see our Code Share site.
This topic includes the following:
How to upload a document
How to replace an existing document
How to update the metadata in a document
How to delete a document after you have created a package
Uploading Documents
To add a document to an existing package, you must first create the Document object. The following code will create a Document object:
Document document = DocumentBuilder.newDocumentWithName("Example Document")
.fromFile("DOC_FILE_PATH")
//.fromStream( documentStream, DocumentType.PDF );
.withId("document1")
.withDescription("Sample Document Description")
.build();Once the Document object has been created, find the PackageId you wish to add the document to and then use the OneSpan Sign client to upload that document. The following code will do this:
eslClient.uploadDocument(document, packageId);You can also upload multiple documents within one call. To do this, build multiple Document objects locally and pass them as variable arguments or as a list into the following code:
eslClient.uploadDocuments(packageId, doc1, doc2, doc3);
eslClient.uploadDocuments(packageId, Arrays.asList(doc1, doc2, doc3));OneSpan Sign supports the following document types:
Adobe's Portable Document Format (*.pdf) — PDFs on which OneSpan Sign can act generally have at least these permissions enabled: (1) Changing the Document; (2) Signing; (3) Filling of form fields.
Microsoft Word (*.doc or *.docx)
Open Office (*.odt)
Text (*.txt)
Rich Text Format (*.rtf)
In addition, the OneSpan Sign Print Driver supports any document that can be printed from a Windows-based application (e.g., Microsoft Word, Microsoft Excel, Microsoft PowerPoint).
File Size Constraints
The maximum size of a single document is 16 MB. Smaller documents yield better performance — we recommend under 5 MB per document.
The maximum total size of all documents in a transaction is 39MB. However, the maximum size may vary, depending on the size of your overall payload. Should you receive an error message when your total document size is 39MB try reducing the overall size to between 35MB and 39MB.
If your organization uses Salesforce or Microsoft SharePoint connectors, the file size maximum is 5 MB per document.
If your organization uses Salesforce connectors, the maximum number of documents that can be added to a transaction is ten (10).
If you enable email delivery while configuring a recipient, attachments larger than 5 MB are not supported.
File Name Constraints
Document file names should not contain any of the following comma-separated characters: *, /, \, :, <, >, |, ?, ".
General File Constraints
We recommend that you do not use PDF documents that make use of XML Forms Architecture. For more information, see XFA Support.
Do not upload password-protected or corrupted documents. These will generate an error.
OneSpan strongly recommends that you scan a PDF for syntax errors (e.g., by using Adobe's Preflight tool), and resolve any errors before you add the document to a transaction.
PDFs with the NeedAppearances flag set to true are not currently supported.
Replacing an Existing Document
Replacing an existing document in a transaction can also be done using the Upload function. This is useful, for example, if you would like to replace the document but still keep the layout of the fields and signatures.
To do this, build a Document object that carries the same Document ID as the document you want to replace, and then use the OneSpan Sign client to upload it. The following code will do this:
Document document = DocumentBuilder.newDocumentWithName("Document1")
.fromFile("path_to_your_file")
.withId("keep_the_same_document_id")
.build();
eslClient.uploadDocument(document, new PackageId("the_package_id"));Similarly, you can replace multiple documents within a call.
Document document = DocumentBuilder.newDocumentWithName("Updated Document1")
.fromFile("path_to_your_file ")
.withId("1dda69f88b10f2e0e6bd846aae9fca0a961aba793bf655b0")
.build();
Document document2 = DocumentBuilder.newDocumentWithName("Updated Document2")
.fromFile("path_to_your_file ")
.withId("c4a6128b646f50c650779d652e5951097663a1de16c4ce72")
.build();
eslClient.uploadDocuments(new PackageId("package_id"),Arrays.asList(document,document2)); Updating Document Metadata
To update the metadata for a document, simply create a Document object with the updates you want to make. For example:
Document document = DocumentBuilder.newDocumentWithName("Example Document")
.withName("Updated document name")
.withDescription("Updated document description")
.build();Then, grab the DocumentPackage you wish to change this document in and then use the OneSpan Sign client to update the document metadata. The following code will do this:
eslClient.getPackageService().updateDocumentMetadata(documentPackage, document);Deleting a Document
To delete a document, call the deleteDocument function with the packageId and documentId string:
eslClient.getPackageService().deleteDocument(packageId, document.getId().toString());Results
After running your code, if you login to OneSpan Sign and navigate to your transaction, you will be able to log into your OneSpan Sign account and view the documents you just added.
.NET SDK
To download the full code sample see our Code Share site.
This topic includes the following:
How to upload a document
How to replace an existing document
How to update the metadata in a document
How to delete a document after you have created a package
Uploading Documents
To add a document to an existing package, you must first create the Document object. The following code will create a Document object:
Document document = DocumentBuilder.NewDocumentNamed("Example Document")
.FromFile("DOC_FILE_PATH")
//.fromStream( documentStream, DocumentType.PDF );
.WithId("document1")
.WithDescription("Sample Document Description")
.Build();Once the Document object has been created, find the PackageId you wish to add the document to and then use the OneSpan Sign client to upload that document. The following code will do this:
eslClient.UploadDocument(document, packageId);You can also upload multiple documents within one call. To do this, build multiple Document objects locally and pass them as variable arguments or as a list into the following code:
eslClient.UploadDocuments(packageId, doc1, doc2, doc3);
eslClient.UploadDocuments(packageId, new List<Document>(){doc1,doc2,doc3}); OneSpan Sign supports the following document types:
Adobe's Portable Document Format (*.pdf) — PDFs on which OneSpan Sign can act generally have at least these permissions enabled: (1) Changing the Document; (2) Signing; (3) Filling of form fields.
Microsoft Word (*.doc or *.docx)
Open Office (*.odt)
Text (*.txt)
Rich Text Format (*.rtf)
In addition, the OneSpan Sign Print Driver supports any document that can be printed from a Windows-based application (e.g., Microsoft Word, Microsoft Excel, Microsoft PowerPoint).
File Size Constraints
The maximum size of a single document is 16 MB. Smaller documents yield better performance — we recommend under 5 MB per document.
The maximum total size of all documents in a transaction is 39MB. However, the maximum size may vary, depending on the size of your overall payload. Should you receive an error message when your total document size is 39MB try reducing the overall size to between 35MB and 39MB.
If your organization uses Salesforce or Microsoft SharePoint connectors, the file size maximum is 5 MB per document.
If your organization uses Salesforce connectors, the maximum number of documents that can be added to a transaction is ten (10).
If you enable email delivery while configuring a recipient, attachments larger than 5 MB are not supported.
File Name Constraints
Document file names should not contain any of the following comma-separated characters: *, /, \, :, <, >, |, ?, ".
General File Constraints
We recommend that you do not use PDF documents that make use of XML Forms Architecture. For more information, see XFA Support.
Do not upload password-protected or corrupted documents. These will generate an error.
OneSpan strongly recommends that you scan a PDF for syntax errors (e.g., by using Adobe's Preflight tool), and resolve any errors before you add the document to a transaction.
PDFs with the NeedAppearances flag set to true are not currently supported.
Replacing an Existing Document
Replacing an existing document in a transaction can also be done using the Upload function. This is useful, for example, if you would like to replace the document, but still keep the layout of the fields and signatures.
To do this, build a Document object that carries the same Document ID as the document you want to replace, and then use the OneSpan Sign client to upload it. The following code will do this:
Document document = DocumentBuilder.NewDocumentWithName("Document1")
.FromFile("path_to_your_file")
.WithId("keep_the_same_document_id")
.Build();
eslClient.UploadDocument(document, new PackageId("the_package_id"));Similarly, you can replace multiple documents within a call.
Document document = DocumentBuilder.NewDocumentWithName("Updated Document1")
.FromFile("path_to_your_file ")
.WithId("1dda69f88b10f2e0e6bd846aae9fca0a961aba793bf655b0")
.Build();
Document document2 = DocumentBuilder.NewDocumentWithName("Updated Document2")
.FromFile("path_to_your_file ")
.WithId("c4a6128b646f50c650779d652e5951097663a1de16c4ce72")
.Build();
eslClient.UploadDocuments(new PackageId("package_id"), new List<Document>(){document,document2}); Updating Document Metadata
To update the metadata for a document, simply create a Document object with the updates you want to make. For example:
Document document = DocumentBuilder.NewDocumentNamed("Example Document")
.WithName("Updated document name")
.WithDescription("Updated document description")
.Build();Then, grab the DocumentPackage you wish to change this document in and then use the OneSpan Sign client to update the document metadata. The following code will do this:
eslClient.PackageService.UpdateDocumentMetadata(documentPackage, document);Deleting a Document
To delete a document, call the deleteDocument function with the packageId and documentId string:
eslClient.PackageService.DeleteDocument(packageId, document.Id.ToString());Results
After running your code, if you login to OneSpan Sign and navigate to your transaction, you will be able to log into your OneSpan Sign account and view the documents you just added.
REST API
To download the full code sample see our Code Share site.
This topic includes the following:
How to upload a document
How to replace an existing document
How to update the metadata in a document
How to delete a document after you have created a package
Uploading Documents
Uploading a Single Document
To upload a document after creating a package, you will need to make a multipart-form POST request.
HTTP Request
POST /api/packages/{packageId}/documentsHTTP Headers
Accept: text/html
Content-Type: multipart/form-data
Authorization: Basic api_keyRequest 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"
{
"name": "Example Document",
"description": "Example Description",
"id": "Document1"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--For a complete description of each field, seethe Request Payload section below.
Response Payload
{
"status": "",
"description": "Example Description",
"id": "Document1",
"data": {
"ese_document_texttag_extract_needed": "false"
},
"approvals": [
{
"id": "k1r2qMRtCsI5",
"role": "48d0c024-0609-4255-9087-941a66f80738",
"data": null,
"signed": null,
"accepted": null,
"fields": [],
"name": ""
}
],
"pages": [
{
"id": "",
"top": 0,
"height": 1030,
"width": 796,
"left": 0,
"index": 0,
"version": 0
}
],
"external": null,
"extract": false,
"signedHash": null,
"signerVerificationToken": null,
"index": 1,
"fields": [],
"name": "Example Document",
"size": 185808
}Uploading Multiple Documents
To upload multiple documents in one call, you would use the same API url but modify the request body in the following way:
HTTP Request
POST /api/packages/{packageId}/documentsHTTP Headers
Accept: text/html
Content-Type: multipart/form-data
Authorization: Basic api_keyRequest Payload
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc1.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc2.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
[
{
"name": "Document1",
"description": "Example Description",
"id": "Document1"
},
{
"name": "Document2",
"description": "Example Description",
"id": "Document2"
}
]
------WebKitFormBoundary1bNO60n7FqP5WO4t--OneSpan Sign supports the following document types:
Adobe's Portable Document Format (*.pdf) — PDFs on which OneSpan Sign can act generally have at least these permissions enabled: (1) Changing the Document; (2) Signing; (3) Filling of form fields.
Microsoft Word (*.doc or *.docx)
Open Office (*.odt)
Text (*.txt)
Rich Text Format (*.rtf)
In addition, the OneSpan Sign Print Driver supports any document that can be printed from a Windows-based application (e.g., Microsoft Word, Microsoft Excel, Microsoft PowerPoint).
File Size Constraints
The maximum size of a single document is 16 MB. Smaller documents yield better performance — we recommend under 5 MB per document.
The maximum total size of all documents in a transaction is 39MB. However, the maximum size may vary, depending on the size of your overall payload. Should you receive an error message when your total document size is 39MB try reducing the overall size to between 35MB and 39MB.
If your organization uses Salesforce or Microsoft SharePoint connectors, the file size maximum is 5 MB per document.
If your organization uses Salesforce connectors, the maximum number of documents that can be added to a transaction is ten (10).
If you enable email delivery while configuring a recipient, attachments larger than 5 MB are not supported.
File Name Constraints
Document file names should not contain any of the following comma-separated characters: *, /, \, :, <, >, |, ?, ".
General File Constraints
We recommend that you do not use PDF documents that make use of XML Forms Architecture. For more information, see XFA Support.
Do not upload password-protected or corrupted documents. These will generate an error.
OneSpan strongly recommends that you scan a PDF for syntax errors (e.g., by using Adobe's Preflight tool), and resolve any errors before you add the document to a transaction.
PDFs with the NeedAppearances flag set to true are not currently supported.
Replacing an Existing Document
Replacing an existing document in a transaction can also be done using the upload document API. This is useful, for example, if you would like to replace the document, but still keep the layout of the fields and signatures.
To do so, make a multipart-form POST request where the document JSON payload carries the same document ID as the original document:
HTTP Request
POST /api/packages/{packageId}/documentsHTTP Headers
Accept: text/html
Content-Type: multipart/form-data
Authorization: Basic api_key Request Payload
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc1.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
{
"name": "Replaced Document",
"id": "keep_the_document_id_same"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--
Similarly, you can replace multiple documents, using the following request:
Request Payload
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc1.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="doc2.pdf"
Content-Type: application/pdf
%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj....
------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"
[
{
"name": "Replaced Document1",
"id": "keep_the_document1_id_same"
},
{
"name": "Replaced Document2",
"id": "keep_the_document2_id_same"
}
]------WebKitFormBoundary1bNO60n7FqP5WO4t--
Updating Document Metadata
To update the metadata for a document, you will need to create your JSON using the updated document metadata:
{
"name": "Example Document",
"description": "Example Description"
}Then use the following command:
PUT https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}The call above will only update the document level attributes you defined in your new JSON payload and not any other embedded attributes that can be updated.
Deleting a Document
To delete a document, make a DELETE request to the following URI:
https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}Results
After running your code, if you login to OneSpan Sign and navigate to your transaction, you will be able to log into your OneSpan Sign account and view the documents you just added.
Request Payload Table
Property | Type | Editable | Required | Default | Sample Values |
|---|---|---|---|---|---|
name | string | Yes | No | n/a | Example Document |
description | string | Yes | No | n/a | Example Description |
id | string | Yes | No | n/a | Document1 |
APEX SDK
To download the full code sample see our Code Share site.
This topic includes the following:
How to upload a document
How to replace an existing document
How to update the metadata in a document
How to delete a document after you have created a package
Uploading Documents
To add a document to an existing package, you must first create the Document object. The following code will create a Document object:
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
Map<String,Blob> doc = new Map<String,Blob>();
doc.put('Sample Document', sr.Body);
ESignLiveAPIObjects.Document document = new ESignLiveAPIObjects.Document();
document.name = 'Sample Contract';
document.id = 'document1';Once the Document object has been created, find the PackageId you wish to add the document to and then use the OneSpan Sign client to upload that document. The following code will do this:
String documentResponse = sdk.createDocuments(packageId, document, doc);
document = (ESignLiveAPIObjects.Document)JSON.deserialize(documentResponse, ESignLiveAPIObjects.Document.class);OneSpan Sign supports the following document types:
Adobe's Portable Document Format (*.pdf) — PDFs on which OneSpan Sign can act generally have at least these permissions enabled: (1) Changing the Document; (2) Signing; (3) Filling of form fields.
Microsoft Word (*.doc or *.docx)
Open Office (*.odt)
Text (*.txt)
Rich Text Format (*.rtf)
In addition, the OneSpan Sign Print Driver supports any document that can be printed from a Windows-based application (e.g., Microsoft Word, Microsoft Excel, Microsoft PowerPoint).
File Size Constraints
The maximum size of a single document is 16 MB. Smaller documents yield better performance — we recommend under 5 MB per document.
The maximum total size of all documents in a transaction is 39MB. However, the maximum size may vary, depending on the size of your overall payload. Should you receive an error message when your total document size is 39MB try reducing the overall size to between 35MB and 39MB.
If your organization uses Salesforce or Microsoft SharePoint connectors, the file size maximum is 5 MB per document.
If your organization uses Salesforce connectors, the maximum number of documents that can be added to a transaction is ten (10).
If you enable email delivery while configuring a recipient, attachments larger than 5 MB are not supported.
File Name Constraints
Document file names should not contain any of the following comma-separated characters: *, /, \, :, <, >, |, ?, ".
General File Constraints
We recommend that you do not use PDF documents that make use of XML Forms Architecture. For more information, see XFA Support.
Do not upload password-protected or corrupted documents. These will generate an error.
OneSpan strongly recommends that you scan a PDF for syntax errors (e.g., by using Adobe's Preflight tool), and resolve any errors before you add the document to a transaction.
PDFs with the NeedAppearances flag set to true are not currently supported.
Replacing an Existing Document
Replacing an existing document in a transaction can also be done using the Upload function. This is useful, for example, if you would like to replace the document, but still keep the layout of the fields and signatures.
To do this, build a Document object that carries the same Document ID as the document you want to replace, and then use the OneSpan Sign client to upload it. The following code will do this:
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
Map<String,Blob> doc = new Map<String,Blob>();
doc.put('Sample Document', sr.Body);
ESignLiveAPIObjects.Document document = new ESignLiveAPIObjects.Document();
document.name = 'Updated Document';
document.id = ‘keep_the_document_id_same’;
String documentResponse = sdk.createDocuments(packageId, document, doc); Updating Document Metadata
To update the metadata for a document, simply create a Document object with the updates you want to make. For example:
ESignLiveAPIObjects.Document document_updated = new ESignLiveAPIObjects.Document();
document_updated.name = 'updated document name';
document_updated.description = 'updated document description';Then, use below function to update the document metadata by passing in the package ID, document ID and updated Document object.
sdk.updateDocument(packageId, document.id, document_updated);Deleting a Document
To delete a document, call the deleteDocument function with the packageId and documentId string:
sdk.deleteDocument(packageId, document.id);Results
After running your code, if you login to OneSpan Sign and navigate to your transaction, you will be able to log into your OneSpan Sign account and view the documents you just added.