Document Workflow

This guide covers how to create and update a document workflow in your package.

The document workflow determines the order in which multiple documents are signed by a signer. The default workflow allows a signer to freely browse all documents and signing them in any order.

The Code

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

The sample code below shows you how to edit the document block in order to set a document workflow. In this example, there are two documents where the first document needs to be signed before the second.

.withDocument(newDocumentWithName("Second Document")
                        .fromFile("src/main/resources/document.pdf")
                        .atIndex(2)
                        .withSignature(signatureFor("john@email.com")
                                .onPage(0)
                                .atPosition(100, 100)))
.withDocument(newDocumentWithName("First Document")
                        .fromFile("src/main/resources/document.pdf")
                        .atIndex(1)
                        .withSignature(signatureFor("john@email.com")
                                .onPage(0)
                                .atPosition(100, 100)))

Next, the sample code below shows how to reorders the document workflow after creating the package. If you’ve already sent your package, you will need to change the status of your package to DRAFT before you can update the signer workflow.

DocumentPackage postOrderDocumentsPackage = eslClient.getPackage(packageId);
postOrderDocumentsPackage.getDocument("First Document").setIndex(2);
postOrderDocumentsPackage.getDocument("Second Document").setIndex(1);
 
eslClient.getPackageService().orderDocuments(postOrderDocumentsPackage);

If you need a comparison to the basic document object creation or if this is the first time creating a package with the Java SDK, see this guide.

Running Your Code

Once you’ve run your code, if you log into OneSpan Sign, you should find the appropriate document worflow in your OneSpan Sign document package, as seen below.

document_workflow

Get the Code

The document workflow determines the order in which multiple documents are signed by a signer. The default workflow allows a signer to freely browse all documents and signing them in any order.

The Code

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

The sample code below shows you how to edit the document block in order to set a document workflow. In this example, there are two documents where the first document needs to be signed before the second.

.WithDocument(DocumentBuilder.NewDocumentNamed("Second Document")
                            .FromFile("src/main/resources/document.pdf")
                            .AtIndex(2)
                            .WithSignature(SignatureBuilder.SignatureFor("john@email.com")
                                    .OnPage(0)
                                    .AtPosition(100, 100)))
.WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
                            .FromFile("src/main/resources/document.pdf")
                            .AtIndex(1)
                            .WithSignature(SignatureBuilder.SignatureFor("john@email.com")
                                    .OnPage(0)
                                    .AtPosition(100, 100)))

Next, the sample code below shows how to reorders the document workflow after creating the package. If you’ve already sent your package, you will need to change the status of your package to DRAFT before you can update the signer workflow.

 DocumentPackage savedPackage = eslClient.GetPackage(packageId);
savedPackage.GetDocument("First Document").Index = 2;
savedPackage.GetDocument("Second Document").Index = 1;

eslClient.PackageService.OrderDocuments(savedPackage);

If you need a comparison to the basic document object creation or if this is the first time creating a package with the .NET SDK, see this guide.

Running Your Code

Once you’ve run your code, if you log into OneSpan Sign, you should find the appropriate document worflow in your OneSpan Sign document package, as seen below.

document_workflow

Get the Code

The document workflow determines the order in which multiple documents are signed by a signer. The default workflow allows a signer to freely browse all documents and signing them in any order.

The Code

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

The sample JSON below shows you how to edit the documents object in order to set a document workflow. In this example, there are two documents where the first document needs to be signed before the second.

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"

{
  "documents": [
    {
      "id": "doc1",
      "index": 1,
      "name": "First Document"
    },
    {
      "id": "doc2",
      "index": 2,
      "name": "Second Document"
    }
  ],
  "name": "Document Workflow",
  "type": "PACKAGE",
  "status": "DRAFT"
}

------WebKitFormBoundary1bNO60n7FqP5WO4t--

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

Response Payload

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

Next, to update the document workflow, you will need to make a PUT request to:

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

With the following JSON payload:

[{
   "id":"doc1",
   "index":2
 },
 {
   "id":"doc2",
   "index":1
 }
}]

The sample JSON above shows how to reorders the document workflow after creating the package. If you’ve already sent your package, you will need to change the status of your package to DRAFT before you can update the role workflow.

If you need a comparison to the basic document object creation or if this is the first time creating a package with the REST API, see this guide.

Running Your Code

Once you’ve run your code, if you log into OneSpan Sign, you should find the appropriate document worflow in your OneSpan Sign package, as seen below.

document_workflow

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
type string Yes No PACKAGE PACKAGE / TEMPLATE / LAYOUT
name string Yes Yes n/a Document Attributes Example
documents
name string Yes No n/a sample doc
id string Yes No n/a doc1
index integer Yes No 0 0 / 1 / 2 …