Quickstart
This guide will quickly get you up and running with Complero using Java.
Requirements
- Java Development Kit (JDK) 11 or higher
- Maven 3.6 or higher
- A Complero (test) API token (Contact sales here)
Setting up your project
Create your Maven project (see Maven quick start guide here).
- Command
- Output
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false && \
cd my-app/
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.408 s
[INFO] Finished at: 2025-08-18T15:31:01+08:00
[INFO] ------------------------------------------------------------------------
To add the SDK to the project generate it from the Swagger specification.
Add the generator to your project specification by changing the pom.xml to the following:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.test.skip>true</maven.test.skip>
<openapi-generator.version>7.7.0</openapi-generator.version>
<openapi-generator.input>https://api.complero.com/redocusaurus/swagger.yaml</openapi-generator.input>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${openapi-generator.input}</inputSpec>
<generatorName>java</generatorName>
<output>${project.build.directory}/generated-sources/openapi</output>
<apiPackage>com.complero.api</apiPackage>
<modelPackage>com.complero.api.models</modelPackage>
<invokerPackage>com.complero.invoker</invokerPackage>
<configOptions>
<groupId>com.complero</groupId>
<artifactId>cpl-sdk</artifactId>
<artifactVersion>1.0-SNAPSHOT</artifactVersion>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Generate the packages:
- Command
- Output
mvn clean install
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.751 s
[INFO] Finished at: 2025-08-18T15:57:56+08:00
[INFO] ------------------------------------------------------------------------
Let's also add the following work directories:
- Mac
- Linux
- Windows
mkdir -p src/main/java/com/complero/examples/
mkdir -p src/main/java/com/complero/examples/
mkdir src\main\java\com\complero\examples\
Hello Complero
Now let's ping the Complero API to check if the network works by adding the following file to your project:
src/main/java/com/complero/examples/QuickStartPing.java
package com.complero.examples;
import com.complero.invoker.*;
import com.complero.api.DefaultApi;
public class QuickStartPing {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
DefaultApi defaultApi = new DefaultApi(apiClient);
try {
defaultApi.ping();
System.out.println("Succesfully connected to Complero!");
} catch (ApiException e) {
System.out.println(e.getMessage());
System.out.println(e.getResponseBody());
}
}
}
Let's run the application:
- Command
- Output
mvn clean install exec:java -Dexec.mainClass="com.complero.examples.QuickStartPing"
...
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator-ignore
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator/VERSION
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ my-app ---
[INFO] skip non existing resourceDirectory /home/johndoe/my-app/src/main/resources
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ my-app ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 47 source files with javac [debug release 17] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ my-app ---
[INFO] Not copying test resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ my-app ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- surefire:3.2.5:test (default-test) @ my-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ my-app ---
[INFO] Building jar: /home/johndoe/my-app/target/my-app-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- install:3.1.2:install (default-install) @ my-app ---
[INFO] Installing /home/johndoe/my-app/pom.xml to /home/johndoe/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
[INFO] Installing /home/johndoe/my-app/target/my-app-1.0-SNAPSHOT.jar to /home/johndoe/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- exec:3.5.1:java (default-cli) @ my-app ---
Succesfully connected to Complero!
[WARNING] thread Thread[#61,OkHttp api.complero.com,5,com.complero.examples.QuickStartPing] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[#61,OkHttp api.complero.com,5,com.complero.examples.QuickStartPing] will linger despite being asked to die via interruption
[WARNING] thread Thread[#62,OkHttp TaskRunner,5,com.complero.examples.QuickStartPing] will linger despite being asked to die via interruption
[WARNING] thread Thread[#63,Okio Watchdog,5,com.complero.examples.QuickStartPing] will linger despite being asked to die via interruption
[WARNING] thread Thread[#64,OkHttp TaskRunner,5,com.complero.examples.QuickStartPing] will linger despite being asked to die via interruption
[WARNING] thread Thread[#65,OkHttp TaskRunner,5,com.complero.examples.QuickStartPing] will linger despite being asked to die via interruption
[WARNING] NOTE: 5 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.299 s
[INFO] Finished at: 2025-08-29T17:49:51+08:00
[INFO] ------------------------------------------------------------------------
Upload First Contact
Now let's authenticate with the Complero API and upload our first contact.
Set your Complero API key as an environment variable:
- Command
export COMPLERO_API_KEY="<your_api_key_here>"
Add the following file to the project:
src/main/java/com/complero/examples/QuickStartUpload.java
package com.complero.examples;
import com.complero.api.models.*;
import com.complero.invoker.*;
import com.complero.api.ContactsApi;
import com.complero.invoker.auth.ApiKeyAuth;
import com.complero.invoker.auth.Authentication;
import java.util.List;
import java.util.ArrayList;
public class QuickStartUpload {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
// Insert add credentials
String apiToken = System.getenv("API_KEY");
Authentication auth = apiClient.getAuthentications().get("ApiKeyAuth");
((ApiKeyAuth) auth).setApiKey("Bearer ".concat(apiToken));
ContactsApi contactsApi = new ContactsApi(apiClient);
ContactUpload ctc = new ContactUpload();
ctc.id("n1");
ctc.employeeId("1");
ctc.firstName("John");
ctc.lastName("Doe");
ctc.birthday("1991-05-05");
List<ContactUpload> contactList = new ArrayList<ContactUpload>();
contactList.add(ctc);
try {
contactsApi.bulkUploadContacts(contactList);
System.out.println("Succesfully uploaded contact to Complero!");
} catch (ApiException e) {
System.out.println(e.getMessage());
System.out.println(e.getResponseBody());
}
}
}
Let's run the application:
- Command
- Output
mvn clean install exec:java -Dexec.mainClass="com.complero.examples.QuickStartUpload"
`
...
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator-ignore
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator/VERSION
[INFO] writing file /home/johndoe/my-app/target/generated-sources/openapi/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ my-app ---
[INFO] skip non existing resourceDirectory /home/johndoe/my-app/src/main/resources
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ my-app ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 47 source files with javac [debug release 17] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ my-app ---
[INFO] Not copying test resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ my-app ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- surefire:3.2.5:test (default-test) @ my-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ my-app ---
[INFO] Building jar: /home/johndoe/my-app/target/my-app-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- install:3.1.2:install (default-install) @ my-app ---
[INFO] Installing /home/johndoe/my-app/pom.xml to /home/johndoe/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
[INFO] Installing /home/johndoe/my-app/target/my-app-1.0-SNAPSHOT.jar to /home/johndoe/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- exec:3.5.1:java (default-cli) @ my-app ---
Succesfully uploaded contact to Complero!
[WARNING] thread Thread[#61,OkHttp api.complero.com,5,com.complero.examples.QuickStartUpload] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[#61,OkHttp api.complero.com,5,com.complero.examples.QuickStartUpload] will linger despite being asked to die via interruption
[WARNING] thread Thread[#62,OkHttp TaskRunner,5,com.complero.examples.QuickStartUpload] will linger despite being asked to die via interruption
[WARNING] thread Thread[#63,Okio Watchdog,5,com.complero.examples.QuickStartUpload] will linger despite being asked to die via interruption
[WARNING] thread Thread[#64,OkHttp TaskRunner,5,com.complero.examples.QuickStartUpload] will linger despite being asked to die via interruption
[WARNING] thread Thread[#65,OkHttp TaskRunner,5,com.complero.examples.QuickStartUpload] will linger despite being asked to die via interruption
[WARNING] NOTE: 5 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.299 s
[INFO] Finished at: 2025-08-29T17:49:51+08:00
[INFO] ------------------------------------------------------------------------