---
title: "Creating a Document Work Flow"
slug: "creating-a-document-work-flow"
updated: 2025-07-02T18:27:34Z
published: 2025-07-02T18:27:34Z
canonical: "docs.onespan.com/creating-a-document-work-flow"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a Document Work Flow

[Java SDK](/v1/docs/creating-a-document-work-flow#java-sdk) [.NET SDK](/v1/docs/creating-a-document-work-flow#net-sdk) [REST API](/v1/docs/creating-a-document-work-flow#rest-api) [APEX SDK](/v1/docs/creating-a-document-work-flow#apex-sdk)

## Java SDK

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/document-workflow-example-java-sdk) site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

```java
.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)))
```

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

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

This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the Java SDK, see [](https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-java/)[Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#net-sdk).

### Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

## .NET SDK

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/document-workflow-example-net-sdk) site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

```csharp
.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)))
```

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

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

This example shows you how to edit the document object.

If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see [](https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-net/)[Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#net-sdk).

### Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

## REST API

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/enable-document-workflow-rest-api) site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

#### HTTP Request

```http
POST /api/packages
```

#### HTTP Headers

```http
Accept: application/json
Content-Type: multipart/form-data
Authorization: Basic api_key
```

#### Request Payload

```json
------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 work flow",
  "type": "PACKAGE",
  "status": "DRAFT"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--
```

For a complete description of each field, see the Request Payload section below.

**Response Payload**

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

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

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

With the following JSON payload:

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

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

<editor360-custom-block data-preprocessing="true" data-sanitizationtags="a"><p data-block-id="fcbfc013-3fd0-4c6d-8162-c54ec5fbefeb">This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the REST API, see <a href="https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-rest/" target="_blank" display="false" rel="noopener"></a><a href="/v1/docs/creating-and-sending-a-transaction#net-sdk" target="_self" translate="no" rel="noopener">Creating and Sending a Transaction</a>.</p></editor360-custom-block>

### Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.

**Request Payload Table**

| Property | Type | Editable | Required | Default | Sample Values |
| --- | --- | --- | --- | --- | --- |
| 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 ... |

## APEX SDK

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/enable-document-workflow-apex-sdk) site.

A document work flow determines the order in which multiple documents should be signed by a signer. The default work flow allows a signer to freely browse all documents and sign them in any order. This topic explains how to change that.

In this example, there are two documents to be signed, with the First Document needing to be signed before the Second Document.

```plaintext
	String document1Id = 'document1'; 
        StaticResource sr1 = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
        Map<String,Blob> doc1 = new Map<String,Blob>();
        doc1.put(document1Id, sr1.Body);
         
        ESignLiveAPIObjects.Document document1 = new ESignLiveAPIObjects.Document();
        document1.name = document1Id;
        document1.id = document1Id;
        document1.index = 1;
        sdk.createDocuments(packageId, document1, doc1);
    	
    	
    	String document2Id = 'document2';
    	StaticResource sr2 = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc2' LIMIT 1];
    	Map<String,Blob> doc2 = new Map<String,Blob>();
    	doc2.put(document2Id, sr2.Body);
    	
    	ESignLiveAPIObjects.Document document2 = new ESignLiveAPIObjects.Document();
        document2.name = document2Id;
        document2.id = document2Id;
        document2.index = 2;
        sdk.createDocuments(packageId, document2, doc2);
```

The sample code below shows you how to reorder the document work flow after you have created the package. If you've already sent your package to be signed, you will need to change its status to DRAFT before you can update the signer work flow.

```plaintext
    	//update docuemnt work flow in existing package
    	pkg = sdk.getPackage(packageId);
    	
    	document1 = getDocument(pkg,'document1');
    	document1.index = 2;
    	document2 = getDocument(pkg,'document2');
    	document2.index = 1;
    	
    	updateDocuments(packageId, pkg.documents);
```

This example shows you how to edit the document object. If you need a comparison to the basic document object creation procedure, or if this is the first time creating a package with the Apex SDK, see [Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#apex-sdk).

### Results

Once you have completed this procedure, you should find the appropriate document work flow in your OneSpan Sign transaction.
