Document Management

This guide will show you how to manage documents in your OneSpan Sign packages.

One of the most fundamental and basic operations in OneSpan Sign is that of uploading documents to a package (transaction in the new UI). This guide will cover how to upload a document, update its metadata, and delete a document after creating a package.

The Code

To add a document to an existing package, first create the Document object.

Document document = DocumentBuilder.newDocumentWithName("Example Document")
	.fromFile("DOC_FILE_PATH")
        //.fromStream( documentStream, DocumentType.PDF );
	.withId("document1")
	.withDescription("Sample Document Description")
	.build();

Next, grab the DocumentPackage you wish to add the document to and use the OneSpan Sign client to upload the document.

DocumentPackage documentPackage = eslClient.getPackage(packageId);

eslClient.uploadDocument(document, documentPackage);

Similarly, to update an existing document’s metadata, create a Document object with the updates you want to make.

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 use the OneSpan Sign client to update the document metadata.

eslClient.getPackageService().updateDocumentMetadata(documentPackage, document);

Finally, to delete a document, simply call the deleteDocument function with the packageId and documentId string.

eslClient.getPackageService().deleteDocument(packageId, document.getId().toString());

Running Your Code

After running your code, if you login to OneSpan Sign and navigate to your package, you should be able to see your document added to your package.

doc

Get The Code

One of the most fundamental and basic operations in OneSpan Sign is that of uploading documents to a package. This guide will cover how to upload a document, update its metadata, and delete a document after creating a package.

The Code

To add a document to an existing package, first create the Document object.

Document document = DocumentBuilder.NewDocumentNamed("Example Document")
	.FromFile("DOC_FILE_PATH")
        //.fromStream( documentStream, DocumentType.PDF );
	.WithId("document1")
	.WithDescription("Sample Document Description")
	.Build();

Next, grab the DocumentPackage you wish to add the document to and use the OneSpan Sign client to upload the document.

DocumentPackage documentPackage = eslClient.GetPackage(packageId);

eslClient.UploadDocument(document, documentPackage);

Similarly, to update an existing document’s metadata, create a Document object with the updates you want to make.

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 use the OneSpan Sign client to update the document metadata.

eslClient.PackageService.UpdateDocumentMetadata(documentPackage, document);

Finally, to delete a document, simply call the DeleteDocument function with the packageId and documentId string.

eslClient.PackageService.DeleteDocument(packageId, document.Id.ToString());

Running Your Code

After running your code, if you login to OneSpan Sign and navigate to your package, you should be able to see your document added to your package.

doc

Get The Code

One of the most fundamental and basic operations in OneSpan Sign is that of uploading documents to a package. This guide will cover how to upload a document, update its metadata, and delete a document after creating a package.

The Code

To upload a document after creating a package, you will need to make a multipart-form POST request to:

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

HTTP Headers
Accept: text/html
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"

{
  "name": "Example Document",
  "description": "Example Description",
  "id": "Document1"
}

------WebKitFormBoundary1bNO60n7FqP5WO4t--

For a complete description of each field, take a look at the JSON Properties 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
}

Similarly, to update a document’s metadata, you will also need to create your JSON with the updated document information:

{
  "name": "Example Document",
  "description": "Example Description"
}

And make a PUT https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}.

Note that the call above will only update the fields you defined in your new JSON payload.

To delete a document, you make a DELETE request to the following URI:

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

Running Your Code

After running your code, if you login to OneSpan Sign and navigate to your package, you should be able to see your document added to your package.

doc

Get The Code

JSON Properties

Property Type Editable Required Default Sample Value(s)
name string Yes No n/a Example Document
description string Yes No n/a Example Description
id string Yes No n/a Document1