To download the full code sample see our Code Share site.

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

 DocumentPackage pkg = eslClient.getPackageService().getPackage(packageId);
Document doc = pkg.getDocument(DOCUMENT_NAME);
Map < String, Object > attributes = doc.getData();
for (Map.Entry < String, Object > entry: attributes.entrySet()) {
	System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());
} 

Retrieving your Attributes

To retrieve these attributes, use the following code:

 DocumentPackage pkg = eslClient.getPackageService().getPackage(packageId);   Document doc = pkg.getDocument(DOCUMENT_NAME);   Map<String, Object> attributes = doc.getData();   for (Map.Entry<String, Object> entry : attributes.entrySet()){   System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());   } 

Results

Here is an example of what you can expect to see once you have run your code.

java

To download the full code sample see our Code Share site.

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

 DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName).DescribedAs("This is a package created using the OneSpan Sign SDK").WithSigner(SignerBuilder.NewSignerWithEmail(email1).WithCustomId("Client1").WithFirstName("John").WithLastName("Smith").WithTitle("Managing Director").WithCompany("Acme Inc.")).WithDocument(DocumentBuilder.NewDocumentNamed(DOCUMENT_NAME).FromStream(fileStream1, DocumentType.PDF).WithSignature(SignatureBuilder.SignatureFor(email1).OnPage(0).AtPosition(100, 100)).WithData(DocumentAttributesBuilder.NewDocumentAttributes().AddAttribute("Department", "1806").AddAttribute("Employee", "135526"))).Build();

Retrieving your Attributes

To retrieve these attributes, use the following code:

DocumentPackage pkg = eslClient.GetPackage(packageId);
Document doc = pkg.GetDocument("sample doc");
IDictionary < string, object > attributes = doc.Data;
foreach(var attribute in attributes) {
	Debug.WriteLine("Key : " + attribute.Key + " Value : " + attribute.Value);
}

Results

Here is an example of what you can expect to see once you have run your code.

java

To download the full code sample see our Code Share site.

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

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"   {   "autocomplete": true,   "documents": [   {   "approvals": [   {   "fields": [   {   "extract": false,   "height": 50,   "left": 100,   "page": 0,   "subtype": "FULLNAME",   "top": 100,   "type": "SIGNATURE",   "width": 200   }   ],   "role": "Client1"   }   ],   "data": {   "Department": "1806",   "Employee": "135526"   },   "name": "sample doc"   }   ],   "name": "Document Attributes Example",   "roles": [   {   "id": "Client1",   "name": "Client1",   "signers": [   {   "company": "Acme Inc.",   "email": "[email protected]",   "firstName": "John",   "id": "Client1",   "lastName": "Smith",   "title": "Managing Director"   }   ]   }   ],   "trashed": false,   "type": "PACKAGE",   "visibility": "ACCOUNT"   }   ------WebKitFormBoundary1bNO60n7FqP5WO4t-- 

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

Response Payload

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

If you want to retrieve your attributes at a later stage, you can do so by simply retrieving your document JSON:

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

Then, loop through the data field property.

Results

Here is an example of what you can expect to see once you have run your code.

java

Request Payload Table

PropertyTypeEditableRequiredDefaultSample Values
statusstringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
autoCompletebooleanYesNotruetrue / false
typestringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
namestringYesYesn/aDocument Attributes Example
trashedbooleanYesNofalsetrue / false
visibilitystringYesNoACCOUNTACCOUNT / SENDER
documents
namestringYesNon/asample doc
approvals
fields
subtypestringYesNon/aFULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
typestringYesNon/aSIGNATURE / INPUT
extractbooleanYesNofalsetrue / false
heightintegerYesNo5050 / 100 / 150 ...
leftintegerYesNo050 / 100 / 150 ...
pageintegerYesNo00 / 1 / 2 ...
topintegerYesNo050 / 100 / 150 ...
widthintegerYesNo20050 / 100 / 150 ...
rolestringYesNon/aClient1
data
DepartmentstringYesNon/a1806
EmployeestringYesNon/a135526
roles
idstringYesNon/aClient1
namestringYesNon/aClient1
typestringYesNoSIGNERSIGNER / SENDER
signers
emailstringYesYesn/a[email protected]
firstNamestringYesYesn/aJohn
lastNamestringYesYesn/aSmith
phonestringYesNon/a514-555-8888
idstringYesNon/aClient1
companystringYesNon/aAcme Inc.
titlestringYesNon/aManaging Director