How to facilitate the integration of Zapsign with SDK in Java in 3 steps

Table of Contents

If you've come this far, you must have already known Zapsign and your wonderful documentation, but you must have thought: is there an easier way to integrate ZapSign with SDK in Java? The answer to that question is yes!

Continue reading this article to find out how it works and how to put it into practice!

What is an SDK and how can it help?

When integrating with Zapsign, you must create a JSON with the necessary data and make a request to our api. But, what should be in that JSON? How should I send this request?

The answer is in the Software Development Kit (or software development kit), that is, a set of tools developed to assist developers in creating applications.

Our SDK will make all these questions simpler, as we provide you with everything you need to use our application in a clear and simple way.

Right, but how to do it?

To get started, we first need a Java application Maven. When using IntelliJ, just follow the File / New / Project command and create this project with Maven Archetype, as shown in the screenshot below.

java sdk

With the project done, we need to include the reliance on Zapsign in the project's .pom:



com.zapsign
zapsign_sdk
1.0-3

Remember to always add the most current version.

With that, you are ready to use all the functionalities.

Step by step for Java SDK integration

Let's say you have a PDF contract in the cloud and you want to send it to two people to sign. How to translate this to our SDK? Check out the following steps to find out.

1. Build the document

We've tried to give the most intuitive names to each feature. So, if you want to build a document via PDF upload, the class used is DocFromPdf.

java sdk

Here we are building a document in production mode (sandbox = false), with the name “My Contract”, language “pt-br” and the following link to the PDF:

"https://zapsign.s3.amazonaws.com/2022/1/pdf/63d19807-cbfa-4b51-8571-215ad0f4eb98/ca42e7be-c932-482c-b70b-92ad7aea04be.pdf".

But, every contract needs subscribers, correct? For this, we will construct objects of the class Sign and we'll keep it in a list.

java sdk

With that, we were able to create two signatories: a simpler one, with just the name, and another with more data.

For all signer options, take a look at our documentation. In the end, we added these subscribers to a list and included them in the creation of the document.

So far, we have all the necessary data to create the document in Zapsign, but we need to know which account we are going to create this document with.

2. Configure authentication

We need your api token from your Zapsign account. So get in zapsign.com.br, login to your account, enter settings and select the Integration sub-item.

Remember that only administrators and account owners have access to settings.

java sdk

Let's save this token in our code to use it later:

java sdk

With this token, we already know what your account is. But, we still need to send this document to our API.

3. Send document data for signature

In this last step, we need to make a request when sending everything we've created. For this, we have already prepared the class DocRequests which contains all the methods regarding creating, removing, editing and listing documents.

For our specific case, we will use the method createDocFromUploadPdf, adding your account token and the document created earlier.

java sdk

This method will already create the document in your account and return all the data in a called class DocResponse. In this example we convert this class into JSON, through the JsonConverter, just to print to the screen. But, you can use the class however you want.

This response contains important data, such as the document's unique identifier in Zapsign and signer data.

What are the next steps?

Now that you've understood the three steps required to get started with the integration, let's now look at what you should do next.

What to do with the answer?

Many customers have the need to send their own email to subscribers. For this, we can use the following idea:

java sdk

Within the response, we can loop through all the signers by using a for on the docResponse.getSigners() and send an email from your own application. Then we just pass the link to the signature, which is saved inside the signer.getSign_url().

This is just one of the many examples we can do with data in our application. Now it's time to let your imagination run wild.

Webhooks

Okay, we managed to make a document. But, we need to know when a signer signed the document, right?

So, the Zapsign application has three webhooks ready to use: one when creating documents, another when signing signatories and the last one when a document is deleted.

java sdk

We have a specific part to explain how configure webhook in our documentation.

Other Requests

In addition to creating a document via PDF in the cloud, it is possible to perform several functionalities. All of them are listed and exemplified in our SDK documentation.

Code sample

package org.example.tests.docs;

import body.doc.DocFromPdf;
import body.signer.Signer;
import docs.DocRequests;
import response.DocResponse;
import services.JsonConverter;

import java.io.IOException;
import java.util.ArrayList;
public class CreateDocFromUploadPdf {
public static void main(String[] args) throws IOException, InterruptedException {
String apiToken = "0a4d6893-f431-4d83-af80-...";

Signer signer1 = Signer.builder()
.name("My First Signer")
.build();

Signer signer2 = Signer.builder()
.name("My Second Signer")
.email("[email protected]")
.lock_email(true)
.lock_phone(true)
.phone_country("55")
.phone_number("99999999999")
.auth_mode("signatureScreen")
.send_automatic_email(false)
.send_automatic_whatsapp(false)
.build();

arraylist signers = new ArrayList<>();
signers.add(signer1);
signers.add(signer2);

DocFromPdf docFromPdf = DocFromPdf.docFromPdfBuilder()
.sandbox(false)
.name("My Contract")
.brand_primary_color("#000000")
.lang("pt-br")
.signers(signers)
.url_pdf("https://zapsign.s3.amazonaws.com/2022/1/pdf/63d19807-cbfa-4b51-8571-215ad0f4eb98/ca42e7be-c932-482c-b70b-92ad7aea04be.pdf")
.build();

try {
DocResponse docResponse = new DocRequests(apiToken).createDocFromUploadPdf(docFromPdf);
String jsonDocResponse = new JsonConverter().docResponseToJson(docResponse);
System.out.println(jsonDocResponse);
}
catch(Exception exceptionError) {
System.out.println(exceptionError.getMessage());
}
}
}

Final considerations

An integration between two applications tends to be a laborious task, but I hope our SDK makes your job easier. If you need any help or want to comment on how you're using this tool, leave a comment here.

Did you like the integration, but still don't know Zapsign? Let's settle this then! To see what Zapsign has to offer your company, request a tour on our platform with one of our attendants!

Leave a comment

Start your free trial today!

Try our digital signature tool for free.
The first 5 documents
are free!

Share this article

Do you want to stay informed?

Subscribe to our blog

Related articles