Document attributes are customized data related to a document in a transaction. The data in this section of the document information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. Also refer to Package Attributes for package level customized data.

The Code

The following code sample illustrates the simplest way of creating a package with customized document attributes. The samples illustrate how to create customized attributes with the keys "Department", and "Employee". The customized attribute data is constructed as a map.
DocumentPackage superDuperPackage = newPackageNamed(getPackageName())
        .describedAs("This is a package created using the OneSpan Sign SDK")
        .withSigner(newSignerWithEmail(email1)
                   .withCustomId("role1")
                   .withFirstName("John1")
                   .withLastName("Smith1"))
        .withDocument(newDocumentWithName(DOCUMENT_NAME)
                   .fromStream(documentInputStream1, DocumentType.PDF)
                   .withSignature(signatureFor(email1)
                          .onPage(0)
                          .atPosition(100, 100))
        .withData(newDocumentAttributes()
                   .addAttribute("Department", "1806")
                   .addAttribute("Employee", "135526")))
        .build();
If you want to retrieve your attributes at a later stage, you can do so as shown below:
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());
}

Running Your Code

Below is a screenshot of the console output you can expect once you run the sample code above:

java

Get the Code

Document attributes are customized data related to a document in a transaction. The data in this section of the document information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. Also refer to Package Attributes for package level customized data.

The Code

The following code sample illustrates the simplest way of creating a package with customized document attributes. The samples illustrate 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();
If you want to retrieve your attributes at a later stage, you can do so as shown below:
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);
}

Running Your Code

Below is a screenshot of the console output you can expect once you run the sample code above:

java

Get the Code

Document attributes are customized data related to a document in a transaction. The data in this section of the document information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. Also refer to Package Attributes for package level customized data.

The Code

The following JSON sample illustrates the simplest way of creating a package with customized document attributes. The samples illustrate how to create customized attributes with the keys "Department", and "Employee".

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, take a look at the Request Payload section 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} And looping through the "data" field property.

Running Your Code

Below is a screenshot of the console output you can expect once you run the sample code above:

java

Get the Code

Request Payload

PropertyTypeEditableRequiredDefaultSample Value(s)
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