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

The Code

You can download the complete example code from the Developer Community Code Share. The sample code below shows you how to edit your DocumentPackage object in order to add package attributes.
DocumentPackage superDuperPackage1 = newPackageNamed( "Policy " + new SimpleDateFormat( "HH:mm:ss" ).format( new Date() ) )
        	     .describedAs( "This is a package created using the e-SignLive SDK" )
        	     .expiresAt( new Date() )
        	     .withEmailMessage( "This message should be delivered to all signers" )
        	     .withSigner( newSignerWithEmail( "[email protected]" )
        	          .withCustomId( "Client1" )
        	          .withFirstName( "John" )
        	          .withLastName( "Smith" )
        	          .withTitle( "Managing Director" )
        	          .withCompany( "Acme Inc." ) )
        	     .withDocument( newDocumentWithName( "First Document" )
        	          .fromStream( new java.io.FileInputStream(DOCUMENT_PATH), DocumentType.PDF )
        	          .withSignature( signatureFor( "[email protected]" )
        	               .onPage( 0 )
        	               .withField( FieldBuilder.checkBox()
        	                    .onPage( 0 )
        	                    .atPosition( 400, 200 )
        	                    .withValue( "x" ) )
        	               .atPosition( 100, 100 ) ) )
        	     .withAttributes(newDocumentPackageAttributes()
        	               .withAttribute( "First Name", "Bill" )
        	               .withAttribute("Last Name", "Johnson")
        	               .withAttribute("Signing Order", "1")
        	               .build())
        	          .build();
Attributes are set on a package level. To retrieve your attributes, you will first need to retrieve your package. Then, with your DocumentPackage object, you use the getAttributes() and getContents() methods to retrieve your attributes. As mentioned previously, attributes will be returned to you as a map.
DocumentPackage retrievedPackage = eslClient.getPackage( packageId );
		
Map<String, Object> attributes = retrievedPackage.getAttributes().getContents();
for (Map.Entry<String, Object> entry : attributes.entrySet())
{
      System.out.println( entry.getKey() + ": " + entry.getValue() );
}

Running Your Code

Below is a screenshot of the console output you can expect once you've run your code.
Custom package data is used for customized data related to the package. The data in this section of the package information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. The data is organized as a map. Also refer to Document Attributes Guide for document level customized data.

The Code

You can download the complete example code from the Developer Community Code Share. The sample code below shows you how to edit your DocumentPackage object in order to add package attributes.
DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Policy " + DateTime.Now)
                 .DescribedAs("This is a package created using the e-SignLive SDK")
                      .ExpiresOn(DateTime.Now.AddMonths(1))
                      .WithEmailMessage("This message should be delivered to all signers")
                      .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                           .WithCustomId("Client1")
                           .WithFirstName("John")
                           .WithLastName("Smith")
                           .WithTitle("Managing Director")
                           .WithCompany("Acme Inc."))
                      .WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
                           .FromFile(@"C:/Users/hhaidary/Desktop/pdf/doc1.pdf")
                           .WithSignature(SignatureBuilder.SignatureFor("[email protected]")
                           .OnPage(0)
                           .WithField(FieldBuilder.CheckBox()
                           .OnPage(0)
                           .AtPosition(400, 200)
                           .WithValue("x"))
                           .AtPosition(100, 100)))
                      .WithAttributes(new DocumentPackageAttributesBuilder()
                           .WithAttribute("First Name", "Bill")
                           .WithAttribute("Last Name", "Johnson")
                           .WithAttribute("Signing Order", "1")
                           .Build())
                      .Build();
Attributes are set on a package level. To retrieve your attributes, you will first need to retrieve your package. Then, with your DocumentPackage object, you use the getAttributes() and getContents() methods to retrieve your attributes. As mentioned previously, attributes will be returned to you as a map.
DocumentPackage retrievedPackage = eslClient.GetPackage(packageId);
IDictionary<string, Object> attributes = retrievedPackage.Attributes.Contents;
foreach (KeyValuePair<string, Object> entry in attributes)
{
     Debug.WriteLine(entry.Key + ": " + entry.Value);
}

Running Your Code

Below is a screenshot of the console output you can expect once you've run your code.
Custom package data is used for customized data related to the package. The data in this section of the package 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 Document Attributes Guide for document level customized data.

The Code

You can download the complete example code from the Developer Community Code Share. The sample request below shows you how to edit your DocumentPackage object in order to add package attributes.

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": [
    {
      "approvals": [
        {
          "id": "ExampleSignatureId",
          "role": "Signer1",
          "fields": [
            {
              "page": 0,
              "top": 200,
              "subtype": "LABEL",
              "height": 50,
              "left": 100,
              "width": 200,
              "id": "myLabelField",
              "type": "INPUT",
              "value": "Example label field value"
            },
            {
              "page": 0,
              "top": 100,
              "subtype": "FULLNAME",
              "height": 50,
              "left": 100,
              "width": 200,
              "type": "SIGNATURE",
              "name": "ExampleSignatureId"
            }
          ],
          "name": ""
        }
      ],
      "id": "sample-contract",
      "name": "Test Document"
    }
  ],
  "status": "DRAFT",
  "type": "PACKAGE",
  "roles": [
    {
      "id": "Signer1",
      "type": "SIGNER",
      "signers": [
        {
          "email": "[email protected]",
          "firstName": "John",
          "lastName": "Smith",
          "id": "Signer1"
        }
      ],
      "name": "Signer1"
    }
  ],
  "name": "Example Package",
  "data": {
    "First Name": "Bill",
    "Last Name": "Johnson",
    "Signing Order": "1"
  }
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--

For a complete description of each field, take a look at the Request Payload section below.

Response Payload

{
    "id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="
}
Attributes are set on a package level. Therefore, you will need to get your package JSON in order to retrieve your package attributes.

Running Your Code

Below is a screenshot of the console output you can expect once you've run your code.

3

Get The Code

Request Payload

PropertyTypeEditableRequiredDefaultSample Value(s)
statusstringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
typestringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
namestringYesYesn/aDocument Attributes Example
documents
namestringYesNon/asample doc
idstringYesNon/asample-contract
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/aSigner1
idstringYesNon/aExampleSignatureId
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
data
First NamestringYesNon/aBill
Last NamestringYesNon/aJohnson
Signing OrderstringYesNon/a1
Custom package data is used for customized data related to the package. The data in this section of the package information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. The data is organized as a map.

The Code

To notice, functions in this guide are extended from the APEX SDK and can be gotten through this Code Share. The first step is to create a package. If you need a comparison to the basic package creation or if this is the first time creating a package with the Apex SDK, see this guide. Once you retrieved your package ID, you use below encapsulated function and pass the package ID and attributes in a Map as parameters.
public void addAttributes(String packageId, Map<String, Object> attributes)
Accordingly, if you want to grab all your attributes set on the package level, below function returns to you a map containing all attributes by passing in the same package ID.
public Map<String, Object> getAttributes(String packageId)
Running Your Code Below is a screenshot of the console output you can expect once you’ve run your code.

Capture

Get The Code