Java Migration Guide

View as Markdown

Migrating the Java SDK from hellosign-java-sdk to dropbox-sign

Welcome! Dropbox Sign's new Java SDK is generated from our officially maintained OpenAPI spec. In this release, we've made important updates that introduce new functionality and create feature parity between the Dropbox Sign API and the Java SDK. However, some of these changes are considered "breaking" in the sense that they'll require you to update your existing code in order to continue using the SDK.

In this migration guide, we'll cover core concepts in the new SDK, highlight differences from legacy versions, and provide example code showing how past implementations map to the new version's syntax. We'll link out to supporting documents that offer more context behind the breaking changes and why we made them. We apologize for any inconvenience these changes may cause, but are confident the new features will add value to your integration.

Remember that we are here to help if you have any questions or need assistance along the way. Thank you for using Dropbox Sign's Java SDK. We hope you enjoy the improvements!

Architecture and Tooling

As mentioned above, the new Java SDK (dropbox-sign) is generated from our OpenAPI Spec. Some of the architectural changes impact the tools and locations you use to interact with the SDK.

SDK Resources

  • Download -- using this new maven repo. New Java SDK versions will now be published here.
  • Development -- active development against the Java SDK happens here: hellosign-openapi/sdks/java.
  • SDK GitHub Repo -- dropbox-sign-java is updated based on changes to hellosign-openapi/sdks/java, but no active development work happens there.
  • Reference Docs -- the automatically generated Reference Docs are a great way to explore the SDK.
  • Examples -- our full suite of ready to use examples will help you get started quickly.
  • Engagement -- use the OpenAPI repo to submit Issues or Pull Requests for the Java SDK.

Core Concepts and Patterns

This section contains the core concepts and patterns of the new SDK and highlights differences from the legacy SDK.

Installation

The installation process remains the same as it was in the Legacy SDK, and can be completed by either utilizing either Maven or Gradle.

1<dependency>
2 <groupId>com.dropbox.sign</groupId>
3 <artifactId>dropbox-sign</artifactId>
4 <version>2.x.x-</version>
5</dependency>

Importing the SDK

1import com.hellosign.sdk;

The New SDK organizes methods and classes across multiple namespaces; each with a specific purpose.

NamespacePurpose
com.dropbox.sign.api.*A collection of functions to interact with the API endpoints
com.dropbox.sign.ApiClientA collection of classes that focus mainly on set-up, configuration, and exceptions
com.dropbox.sign.model.*A collection of models for all endpoint classes and sub classes

Authentication

This section covers how to authenticate and configure your API Key or OAuth token when using the New SDK (dropbox-sign).

  • Legacy SDK (hellosign-java-sdk@5.2.3 and earlier): An instance of HelloSignClient had to be initialize with your API key (or OAuth Token).

  • New SDK (dropbox-sign): HelloSignClient no longer needs to be instantiated with your API Key. The API Key (or OAuth Token) can be set up by configuring an HTTP basic authorization.

1HelloSignClient client = new HelloSignClient(apiKey);

Endpoints Grouped into Classes

The new SDK divides endpoints across unique Classes:


Using Models to Pass Parameters

Models are used to define the structure and value of the parameters being passed. The fully assembled model is passed to the API endpoint method.

New SDK Using Models to Pass Parameters

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6import com.dropbox.sign.model.SubOAuth.ScopesEnum;
7
8import java.io.File;
9import java.util.Collections;
10import java.util.List;
11
12public class Example {
13 public static void main(String[] args) {
14 var apiClient = Configuration.getDefaultApiClient()
15 .setApiKey("YOUR_API_KEY");
16
17 var apiAppApi = new ApiAppApi(apiClient);
18
19 var oauth = new SubOAuth()
20 .callbackUrl("https://example.com/oauth")
21 .scopes(List.of(ScopesEnum.BASIC_ACCOUNT_INFO, ScopesEnum.REQUEST_SIGNATURE));
22
23 var whiteLabelingOptions = new SubWhiteLabelingOptions()
24 .primaryButtonColor("#00b3e6")
25 .primaryButtonTextColor("#ffffff");
26
27 var customLogoFile = new File("CustomLogoFile.png");
28
29 var data = new ApiAppCreateRequest()
30 .name("My Production App")
31 .domains(Collections.singletonList("example.com"))
32 .oauth(oauth)
33 .whiteLabelingOptions(whiteLabelingOptions)
34 .customLogoFile(customLogoFile);
35
36 try {
37 ApiAppGetResponse result = apiAppApi.apiAppCreate(data);
38 System.out.println(result);
39 } catch (ApiException e) {
40 System.err.println("Exception when calling AccountApi#accountCreate");
41 System.err.println("Status code: " + e.getCode());
42 System.err.println("Reason: " + e.getResponseBody());
43 System.err.println("Response headers: " + e.getResponseHeaders());
44 e.printStackTrace();
45 }
46 }
47}

Path and Query Parameters

In the legacy SDK you would pass Path and Query parameters alongside any POST data to the API endpoint:

Legacy SDK - Path and Query Parameters

1HelloSignClient client = new HelloSignClient("API_KEY");
2String signatureRequestId = "fa5c8a0b0f492d768749333ad6fcc214c111e967";
3String emailAddress = "john@example.com";
4SignatureRequest request = client.requestEmailReminder(signatureRequestId, emailAddress);

The new SDK now requires POST data be an object when calling any API endpoint. Path and Query parameters must be passed individually to these methods.

New SDK - Path and Query Parameters

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7public class Example {
8 public static void main(String[] args) {
9 var apiClient = Configuration.getDefaultApiClient()
10 .setApiKey("YOUR_API_KEY");
11
12 var signatureRequestApi = new SignatureRequestApi(apiClient);
13
14 var signatureRequestId = "2f9781e1a8e2045224d808c153c2e1d3df6f8f2f";
15
16 var data = new SignatureRequestRemindRequest()
17 .emailAddress("john@example.com");
18
19 try {
20 SignatureRequestGetResponse result = signatureRequestApi.signatureRequestRemind(signatureRequestId, data);
21 System.out.println(result);
22 } catch (ApiException e) {
23 System.err.println("Exception when calling AccountApi#accountCreate");
24 System.err.println("Status code: " + e.getCode());
25 System.err.println("Reason: " + e.getResponseBody());
26 System.err.println("Response headers: " + e.getResponseHeaders());
27 e.printStackTrace();
28 }
29 }
30}

Error Handling and Warnings

The New SDK handles errors and warnings differently. See the table below for a breakdown of the changes:

Error Handling

Errors are an instance of com.dropbox.sign.ApiException with its getErrorResponse() method returning an instance of com.dropbox.sign.model.ErrorResponse class and should be handled using Try/Catch blocks.

New SDK - Error Handling
1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7public class Example {
8 public static void main(String[] args) {
9 var apiClient = Configuration.getDefaultApiClient()
10 .setApiKey("YOUR_API_KEY");
11
12 var accountApi = new AccountApi(apiClient);
13
14 try {
15 AccountGetResponse result = accountApi.accountGet(null, "jack@example.com");
16 System.out.println(result);
17 } catch (ApiException e) {
18 System.err.println("Exception when calling AccountApi#accountCreate");
19 System.err.println("Status code: " + e.getCode());
20 System.err.println("Reason: " + e.getResponseBody());
21 System.err.println("Response headers: " + e.getResponseHeaders());
22 e.printStackTrace();
23 }
24 }
25}

Warnings

Warnings are a list of com.dropbox.sign.model.WarningResponse.

New SDK - Warnings

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7import java.util.Objects;
8
9public class Example {
10 public static void main(String[] args) {
11 var apiClient = Configuration.getDefaultApiClient()
12 .setApiKey("YOUR_API_KEY");
13
14 var accountApi = new AccountApi(apiClient);
15
16 var data = new AccountCreateRequest()
17 .emailAddress("newuser@dropboxsign.com");
18
19 try {
20 AccountCreateResponse result = accountApi.accountCreate(data);
21 System.out.println(result);
22
23 // warning loop
24 Objects.requireNonNull(result.getWarnings()).forEach(warning -> {
25 System.err.println("Warning Name: " + warning.getWarningName());
26 System.err.println("Warning Message: " + warning.getWarningMsg());
27 });
28 } catch (ApiException e) {
29 System.err.println("Exception when calling AccountApi#accountCreate");
30 System.err.println("Status code: " + e.getCode());
31 System.err.println("Reason: " + e.getResponseBody());
32 System.err.println("Response headers: " + e.getResponseHeaders());
33 e.printStackTrace();
34 }
35 }
36}

Instantiating Objects From Data

There are two ways to instantiate an object.

  • You can use new with setter methods
  • You can use the init() static method
1var signer1 = new SubSignatureRequestSigner()
2 .emailAddress("jack@example.com")
3 .name("Jack")
4 .order(0);
5
6var attachment1 = new SubAttachment()
7 .name("Attachment 1")
8 .instructions("Please download this file")
9 .signerIndex(0)
10 .required(true);
Note

init() creates a full object using all the data you pass, including nested data to instantiate nested objects. Any parameters that you do not pass data for will be set to their default value (including null).


Event Callback Helper

A callback helper class is included in the New SDK repo to assist in verifying callbacks. The helper simplifies:

  1. Checking event authenticity with built in event hash check
  2. Displaying event types (account callback vs. app callback)
  3. Displaying event messages

The EventCallbackHelper and EventCallbackRequest classes facilitate parsing of event data and assist in validating that a callback originated from Dropbox Sign.

We will send event callback payloads to you as a multipart/form-data request with a single json formfield that contains your event callback as a JSON string.

Example Event Callback Request From US to YOU

$curl -X POST 'https://example.com/YOUR_EVENT_CALLBACK_URL' \
> -F 'json={"event":{"event_type":"account_confirmed","event_time":"1669926463","event_hash":"ff8b03439122f9160500c3fb855bdee5a9ccba5fff27d3b258745d8f3074832f","event_metadata":{"related_signature_id":null,"reported_for_account_id":"6421d70b9bd45059fa207d03ab8d1b96515b472c","reported_for_app_id":null,"event_message":null}}}'

Example JSON Payload

1{
2 "event": {
3 "event_type": "account_confirmed",
4 "event_time": "1669926463",
5 "event_hash": "ff8b03439122f9160500c3fb855bdee5a9ccba5fff27d3b258745d8f3074832f",
6 "event_metadata": {
7 "related_signature_id": null,
8 "reported_for_account_id": "6421d70b9bd45059fa207d03ab8d1b96515b472c",
9 "reported_for_app_id": null,
10 "event_message": null
11 }
12 }
13}

How to use the EventCallbackHelper

1import com.dropbox.sign.EventCallbackHelper;
2import com.dropbox.sign.model.EventCallbackRequest;
3
4public class Example {
5 public static void main(String[] args) throws Exception {
6 // use your API key
7 var apiKey = "324e3b0840f065eb51f3fd63231d0d33daa35d4ed10d27718839e81737065782";
8
9 // callbackData represents data we send to you
10 var callbackData = request.getParameter("json");
11
12 var callbackEvent = EventCallbackRequest.init(callbackData);
13
14 // verify that a callback came from HelloSign.com
15 if (EventCallbackHelper.isValid(apiKey, callbackEvent)) {
16 // one of "account_callback" or "api_app_callback"
17 var callbackType = EventCallbackHelper.getCallbackType(callbackEvent);
18
19 // do your magic below!
20 }
21 }
22}

Differences from Legacy SDK

This section highlights larger changes to be aware of when migrating to the new SDK.

Form Fields per Document

The Form Fields per Document parameter has changed from a two dimensional array, to a one dimensional array—allowing you to designate which file you to add the field to using document_index. You can learn more about this change here: Form Fields per Document.

1FormField signature1 = new FormField();
2field.setX(100);
3field.setY(100);
4field.setType(FieldType.valueOf("signature"));
5field.setSigner(1);
6field.setPage(1);
7field.setApiId("1234");
8field.setHeight(10);
9field.setWidth(20);
10field.setIsRequired(true);
11SignatureRequest request = new SignatureRequest();
12Document doc = new Document();
13doc.addFormField(signature1);

Instantiating the Correct Field Class

There are several different types of form fields you can define, identified by the value of the type field and a few ways to instantiate the correct object when making an API request.

The different classes for each type are:

You can use ::init() on the base request class

1var data = SignatureRequestSendRequest.init(new HashMap<>() {{
2 put("title", "NDA with Acme Co.");
3 put("subject", "The NDA we talked about");
4 put("message", "Please sign this NDA and then we can discuss more.");
5 put("signers", List.of(
6 new HashMap<>() {{
7 put("email_address", "jill@example.com");
8 put("name", "Jill");
9 put("order", 1);
10 }}
11 ));
12 put("form_fields_per_document", List.of(
13 new HashMap<>() {{
14 put("type", "signature");
15 put("document_index", 0);
16 put("api_id", "4688957689");
17 put("name", "signature1");
18 put("x", 5);
19 put("y", 7);
20 put("width", 60);
21 put("height", 30);
22 put("required", true);
23 put("signer", 0);
24 put("page", 1);
25 }}
26 ));
27}});

You can use ::init() on the field class

1var formField1 = SubFormFieldsPerDocumentSignature.init(new HashMap<>() {{
2 put("document_index", 0);
3 put("api_id", "4688957689");
4 put("name", "signature1");
5 put("x", 5);
6 put("y", 7);
7 put("width", 60);
8 put("height", 30);
9 put("required", true);
10 put("signer", 0);
11 put("page", 1);
12}});
13
14var data = new SignatureRequestSendRequest();
15data.addFormFieldsPerDocumentItem(formField1);

You can instantiate the class directly

1var formField1 = new SubFormFieldsPerDocumentSignature();
2formField1.setDocumentIndex(0);
3formField1.setApiId("4688957689");
4formField1.setName("signature1");
5formField1.setX(5);
6formField1.setY(7);
7formField1.setWidth(60);
8formField1.setHeight(30);
9formField1.setRequired(true);
10formField1.setSigner(0);
11formField1.setPage(1);

Form Fields per Document Examples using the new SDK:

1var formField1 = SubFormFieldsPerDocumentSignature.init(new HashMap<>() {{
2 put("document_index", 0);
3 put("api_id", "4688957689");
4 put("name", "signature1");
5 put("x", 5);
6 put("y", 7);
7 put("width", 60);
8 put("height", 30);
9 put("required", true);
10 put("signer", 0);
11 put("page", 1);
12}});

“role” Value in signers Object

In the Legacy SDK when making a Signature Request using a Template the signers property was an object with the role name as the key. In the new SDK the role value has been moved into the signer object itself.

For example for the /signature_request/send_with_template endpoint the signers property could be represented as:

1{
2 "signers": {
3 "Client": {
4 "name": "George",
5 "email_address": "george@example.com"
6 },
7 "Manager": {
8 "name": "Bob",
9 "email_address": "bob@example.com"
10 }
11 }
12}

Using the new SDK you would now send this data as follows:

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7import java.util.HashMap;
8import java.util.List;
9
10public class Example {
11 public static void main(String[] args) throws Exception {
12 var apiClient = Configuration.getDefaultApiClient()
13 .setApiKey("YOUR_API_KEY");
14
15 var signatureRequestApi = new SignatureRequestApi(apiClient);
16
17 var data = new SignatureRequestSendWithTemplateRequest()
18 .templateIds(List.of("c26b8a16784a872da37ea946b9ddec7c1e11dff6"))
19 .subject("Purchase Order")
20 .message("Glad we could come to an agreement.")
21 .signers(List.of(
22 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
23 put("role", "Client");
24 put("name", "George");
25 put("email_address", "george@example.com");
26 }}),
27 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
28 put("role", "Manager");
29 put("name", "Bob");
30 put("email_address", "bob@example.com");
31 }})
32 ));
33
34 try {
35 SignatureRequestGetResponse result = signatureRequestApi.signatureRequestSendWithTemplate(data);
36 System.out.println(result);
37 } catch (ApiException e) {
38 System.err.println("Exception when calling AccountApi#accountCreate");
39 System.err.println("Status code: " + e.getCode());
40 System.err.println("Reason: " + e.getResponseBody());
41 System.err.println("Response headers: " + e.getResponseHeaders());
42 e.printStackTrace();
43 }
44 }
45}

“role” Value in ccs Property

In the Legacy SDK when making a Signature Request using a Template the ccs property was an object with the role name as the key. In the new SDK the role value has been moved into the cc object itself, alongside a new email_address property.

For example for the /signature_request/send_with_template endpoint the ccs property could be represented as:

1{
2 "ccs": {
3 "Client": "george@example.com",
4 "Manager": "bob@example.com"
5 }
6}

Using the new SDK you would now send this data as follows:

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7import java.util.HashMap;
8import java.util.List;
9
10public class Example {
11 public static void main(String[] args) throws Exception {
12 var apiClient = Configuration.getDefaultApiClient()
13 .setApiKey("YOUR_API_KEY");
14
15 var signatureRequestApi = new SignatureRequestApi(apiClient);
16
17 var data = new SignatureRequestSendWithTemplateRequest()
18 .templateIds(List.of("c26b8a16784a872da37ea946b9ddec7c1e11dff6"))
19 .subject("Purchase Order")
20 .message("Glad we could come to an agreement.")
21 .signers(List.of(
22 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
23 put("role", "Client");
24 put("name", "George");
25 put("email_address", "george@example.com");
26 }}),
27 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
28 put("role", "Manager");
29 put("name", "Bob");
30 put("email_address", "bob@example.com");
31 }})
32 ))
33 .ccs(List.of(
34 SubCC.init(new HashMap<>() {{
35 put("role", "Client");
36 put("email_address", "george@example.com");
37 }}),
38 SubCC.init(new HashMap<>() {{
39 put("role", "Manager");
40 put("email_address", "bob@example.com");
41 }})
42 ));
43
44 try {
45 SignatureRequestGetResponse result = signatureRequestApi.signatureRequestSendWithTemplate(data);
46 System.out.println(result);
47 } catch (ApiException e) {
48 System.err.println("Exception when calling AccountApi#accountCreate");
49 System.err.println("Status code: " + e.getCode());
50 System.err.println("Reason: " + e.getResponseBody());
51 System.err.println("Response headers: " + e.getResponseHeaders());
52 e.printStackTrace();
53 }
54 }
55}

“name” Value in custom_fields Property

In the Legacy SDK when making a Signature Request with the custom_fields property it was an object with the name as the key. In the new SDK the name value has been moved into the custom_field object itself.

For example for the /signature_request/send_with_template endpoint the custom_fields property could be represented as:

1{
2 "custom_fields": {
3 "company": {
4 "value": "ABC Corp",
5 "required": true
6 }
7 }
8}

Using the new SDK you would now send this data as follows:

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5import com.dropbox.sign.model.*;
6
7import java.util.HashMap;
8import java.util.List;
9
10public class Example {
11 public static void main(String[] args) throws Exception {
12 var apiClient = Configuration.getDefaultApiClient()
13 .setApiKey("YOUR_API_KEY");
14
15 var signatureRequestApi = new SignatureRequestApi(apiClient);
16
17 var data = new SignatureRequestSendWithTemplateRequest()
18 .templateIds(List.of("c26b8a16784a872da37ea946b9ddec7c1e11dff6"))
19 .subject("Purchase Order")
20 .message("Glad we could come to an agreement.")
21 .signers(List.of(
22 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
23 put("role", "Client");
24 put("name", "George");
25 put("email_address", "george@example.com");
26 }}),
27 SubSignatureRequestTemplateSigner.init(new HashMap<>() {{
28 put("role", "Manager");
29 put("name", "Bob");
30 put("email_address", "bob@example.com");
31 }})
32 ))
33 .customFields(List.of(
34 SubCustomField.init(new HashMap<>() {{
35 put("name", "company");
36 put("value", "ABC Corp");
37 put("required", true);
38 }})
39 ));
40
41 try {
42 SignatureRequestGetResponse result = signatureRequestApi.signatureRequestSendWithTemplate(data);
43 System.out.println(result);
44 } catch (ApiException e) {
45 System.err.println("Exception when calling AccountApi#accountCreate");
46 System.err.println("Status code: " + e.getCode());
47 System.err.println("Reason: " + e.getResponseBody());
48 System.err.println("Response headers: " + e.getResponseHeaders());
49 e.printStackTrace();
50 }
51 }
52}

template_id to template_ids

The template_id parameter has been removed. You must now use template_ids.

Legacy SDK versionNew SDK Version
Template ID (template_id) is passed as a singular string:

template_id : “1234567890”
Template ID is passed as an array of strings (template_ids):

template_ids:[“1234567890”]

file to files

The file parameter has been renamed to files. Usage remains the same.

Use .files([...]);


file_url to file_urls

The file_url parameter has been renamed to file_urls. Usage remains the same.

Use .fileUrls([...]);


Interacting with Files

The new SDK version introduces some new patterns around uploading and downloading files. You can read about them more in depth here: Interacting with Files.

Uploading Files

  • ** Legacy SDK (hellosign-java-sdk@5.2.3 and earlier):** Files could be uploaded via the Document Class.
  • ** New SDK (dropbox-sign): ** The Document Class has been removed. The three methods to upload files via the New SDK and their examples are:
  • addFilesItem method
  • file method
  • setFile method
1//Using the Document Class
2Document doc1 = new Document();
3doc1.setFile(new File("/NDA.pdf"));
New SDK - setFiles method
1// This method accepts an Array of Files
2
3var file1 = new File("Documents/NDA.pdf");
4var file2 = new File("Documents/NDA2.pdf");
5
6var data = new SignatureRequestSendWithTemplateRequest()
7 .templateIds(List.of("b7fee29dd746ebab9d8cdfcb7cdbdd0c5a2bc67a"))
8 .subject("Purchase Order")
9 .message("Glad we could come to an agreement.")
10 .signers(List.of(signer1))
11 .ccs(List.of(cc1))
12 .customFields(List.of(customField1))
13 .signingOptions(signingOptions)
14 .testMode(true);
15data.setFiles(List.of(file1, file2));

All methods above utilize the built-in java.io.File Class to handle files.

Using the set File method

Because the setFile method return type is void, this method must be chained together with the Object, as shown on the example above.


Downloading Files

We now provide three different options to download files, for either signature requests and template files. Different endpoints provide the following options:

  • Return files as PDF or ZIP
  • Return a URL to the file (PDF only)
  • Return a data_uri base64 encoded file (PDFs only)

Examples for each endpoint in the New SDK (dropbox-sign) can be found in the table below:

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5
6import java.io.File;
7
8public class Example {
9 public static void main(String[] args) {
10 var apiClient = Configuration.getDefaultApiClient()
11 .setApiKey("YOUR_API_KEY");
12
13 var signatureRequestApi = new SignatureRequestApi(apiClient);
14
15 var signatureRequestId = "fa5c8a0b0f492d768749333ad6fcc214c111e967";
16
17 try {
18 File result = signatureRequestApi.signatureRequestFiles(signatureRequestId, "pdf");
19 result.renameTo(new File("file_response.pdf"));
20 } catch (ApiException e) {
21 System.err.println("Exception when calling AccountApi#accountCreate");
22 System.err.println("Status code: " + e.getCode());
23 System.err.println("Reason: " + e.getResponseBody());
24 System.err.println("Response headers: " + e.getResponseHeaders());
25 e.printStackTrace();
26 }
27 }
28}

Downloading Templates

1import com.dropbox.sign.ApiException;
2import com.dropbox.sign.Configuration;
3import com.dropbox.sign.api.*;
4import com.dropbox.sign.auth.*;
5
6import java.io.File;
7
8public class Example {
9 public static void main(String[] args) {
10 var apiClient = Configuration.getDefaultApiClient()
11 .setApiKey("YOUR_API_KEY");
12
13 var templateApi = new TemplateApi(apiClient);
14
15 var templateId = "f57db65d3f933b5316d398057a36176831451a35";
16
17 try {
18 File result = templateApi.templateFiles(templateId, "pdf");
19 result.renameTo(new File("file_response.pdf"));
20 } catch (ApiException e) {
21 System.err.println("Exception when calling AccountApi#accountCreate");
22 System.err.println("Status code: " + e.getCode());
23 System.err.println("Reason: " + e.getResponseBody());
24 System.err.println("Response headers: " + e.getResponseHeaders());
25 e.printStackTrace();
26 }
27 }
28}

Endpoint mapping

This section shows you how endpoints in the legacy SDK map to the new SDK. It doesn’t cover all endpoints, but gives you an idea of mapping implementations between the two SDKs. Please reach out if you think we’re missing an important example.

Send Non-Embedded Signature Request

1SignatureRequest request = new SignatureRequest();
2request.setSubject("NDA");
3request.setMessage("Hi Jack, Please sign this NDA and let's discuss.");
4request.addSigner("jack@example.com", "Jack");
5request.addFile(new File("path_to/myfile.pdf"));
6SignatureRequest response = client.sendSignatureRequest(request);
7System.out.println(response.toString());

Create Embedded Signature Request

1SignatureRequest request = new SignatureRequest();
2request.setTitle("NDA with Acme Co.");
3request.setSubject("The NDA we talked about");
4request.setMessage("Please sign this NDA and then we can discuss more.");
5request.addSigner("jack@example.com", "Jack");
6request.addSigner("jill@example.com", "Jill");
7request.addCC("lawyer@dropboxsign.com");
8request.addCC("lawyer@example.com");
9request.addFile(new File("nda.pdf"));
10request.addFile(new File("AppendixA.pdf"));
11request.setTestMode(true);
12
13String clientId = "b6b8e7deaf8f0b95c029dca049356d4a2cf9710a";
14EmbeddedRequest embedReq = new EmbeddedRequest(clientId, request);
15
16HelloSignClient client = new HelloSignClient("API Key");
17SignatureRequest newRequest = (SignatureRequest) client.createEmbeddedRequest(embedReq);

Send Non-embedded signature request with Template

1TemplateSignatureRequest request = new TemplateSignatureRequest();
2request.setTemplateId("c26b8a16784a872da37ea946b9ddec7c1e11dff6");
3request.setSubject("Purchase Order");
4request.setMessage("Glad we could come to an agreement.");
5request.setSigner("Client", "george@example.com", "George");
6request.setCC("Accounting", "accounting@dropboxsign.com");
7request.setCustomFieldValue("Cost", "$20,000");
8request.setTestMode(true);
9
10HelloSignClient client = new HelloSignClient("API_KEY");
11SignatureRequest newRequest = client.sendTemplateSignatureRequest(request);

Download Files

1HelloSignClient client = new HelloSignClient("API_KEY");
2String signatureRequestId = "2f9781e1a8e2045224d808c153c2e1d3df6f8f2f";
3File zippedFiles = client.getFiles(signatureRequestId, SignatureRequest.SIGREQ_FORMAT_ZIP);

Get Signature Request

1HelloSignClient client = new HelloSignClient("API_KEY");
2String signatureRequestId = "fa5c8a0b0f492d768749333ad6fcc214c111e967";
3SignatureRequest request = client.getSignatureRequest(signatureRequestId);

List Signature Request

1HelloSignClient client = new HelloSignClient("API_KEY");
2SignatureRequestList list = client.getSignatureRequests(1);

Create Embedded Unclaimed Draft

1SignatureRequest sigReq = new SignatureRequest();
2sigReq.setTestMode(true);
3sigReq.addFile(new File("NDA.pdf"));
4
5UnclaimedDraft draft = new UnclaimedDraft(sigReq, UnclaimedDraftType.request_signature);
6draft.setIsForEmbeddedSigning(false);
7draft.setRequesterEmail("jack@dropboxsign.com");
8
9String clientId = "ca1209bc08912a8a881234def21352ab";
10EmbeddedRequest embedReq = new EmbeddedRequest(clientId, draft);
11
12HelloSignClient client = new HelloSignClient("API_KEY");
13UnclaimedDraft responseDraft = (UnclaimedDraft) client.createEmbeddedRequest(embedReq);

Create Embedded Template - With Merge Fields

1TemplateDraft draft = new TemplateDraft();
2draft.setTestMode(true);
3draft.setTitle("NDA Template");
4draft.addSignerRole("Client");
5draft.addCCRole("Lawyer");
6draft.addFile(getTestFile("nda.pdf"));
7
8EmbeddedRequest eReq = new EmbeddedRequest(clientId, draft);
9HelloSignClient client = new HelloSignClient("API_KEY");
10TemplateDraft t = client.createEmbeddedTemplateDraft(eReq);

Create API APP

1ApiApp app = new ApiApp();
2
3WhiteLabelingOptions wl= new WhiteLabelingOptions();
4wl.setPrimaryButtonHoverColor("#4B1414");
5wl.setHeaderBackgroundColor("#171616");
6
7app.setWhiteLabelingOptions(wl);
8app.setDomain("www.example.com");
9app.setName("Test API App");
10app.getClientId();
11
12client.createApiApp(app);

Supporting Legacy SDKs

Following the official release of the new SDK version, we'll be preparing to deprecate all legacy versions of the Java SDK for one year after launch. That means, once fully launched, we'll only support critical vulnerabilities and bug fixes for legacy SDK versions 5.2.3 for 12 months. After that, legacy versions are considered officially deprecated and are no longer supported. You can find more information in our SDK Versioning Policy.

We encourage you to start migrating (or planning to migrate) to the new SDK as soon as possible. Please don't hesitate to reach out if you have questions or need assistance.


Feedback and Assistance

We know that dealing with "breaking" changes is inconvenient for those of you currently using the legacy SDK, but believe the new SDK offers a better experience while providing access to more features. If you need help or get stuck, please reach out to API support: Submit a Ticket

We warmly welcome your feedback, feature requests, and bug reports in our OpenAPI repo. All of the engineering work on the Java SDK happens in the Java folder of the repo.