Skip to main content

Java SDK

Not published yet

The Java SDK exists as source code but is not yet published on Maven Central. It cannot be installed via a Maven/Gradle dependency today. The code below documents the API as it will look once the SDK is published — in the meantime, use the public API directly over HTTP (see the Spring Boot example using RestTemplate).

OkHttp client + Gson parsing. The SDK defines no model package: every method returns raw Map<String, Object>/List<Map<String, Object>>, not typed objects.

Installation (coming soon)​

<dependency>
<groupId>com.moncreneau</groupId>
<artifactId>moncreneau-java</artifactId>
<version>1.0.0</version>
</dependency>

Gradle:

implementation 'com.moncreneau:moncreneau-java:1.0.0'

Configuration​

import com.moncreneau.Moncreneau;

public class Main {
public static void main(String[] args) {
Moncreneau client = new Moncreneau("YOUR_API_KEY");
}
}

With a custom base URL and timeout:

import com.moncreneau.Moncreneau;

Moncreneau client = new Moncreneau("YOUR_API_KEY", "https://mc-prd.duckdns.org/api/v1", 30);

Spring Boot integration​

import com.moncreneau.Moncreneau;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MoncreneauConfig {

@Value("${moncreneau.api.key}")
private String apiKey;

@Bean
public Moncreneau moncreneauClient() {
return new Moncreneau(apiKey);
}
}
moncreneau.api.key=${MONCRENEAU_API_KEY}

List departments​

import com.moncreneau.Moncreneau;
import java.util.List;
import java.util.Map;

Moncreneau client = new Moncreneau("YOUR_API_KEY");

List<Map<String, Object>> departments = client.departments.list();

for (Map<String, Object> dept : departments) {
System.out.println(dept.get("id") + " - " + dept.get("name"));
}

Create an appointment​

import com.moncreneau.Moncreneau;
import com.moncreneau.exceptions.MoncreneauException;
import java.util.Map;

Moncreneau client = new Moncreneau("YOUR_API_KEY");

Map<String, Object> data = Map.of(
"departmentId", 5,
"dateTime", "2026-02-15T10:00:00",
"name", "Amadou Diallo"
);

try {
Map<String, Object> appointment = client.appointments.create(data);

System.out.println("✅ Appointment created!");
System.out.println("ID: " + appointment.get("id"));
System.out.println("QR Code: " + appointment.get("qrCode"));

} catch (MoncreneauException e) {
if ("INSUFFICIENT_CREDITS".equals(e.getErrorCode())) {
System.err.println("❌ Insufficient credits: " + e.getMessage());
} else {
System.err.println("❌ Error: " + e.getMessage());
}
}

Check slot availability​

The backend checks a single slot (dateTime), not a date range.

import com.moncreneau.Moncreneau;
import java.util.Map;

Moncreneau client = new Moncreneau("YOUR_API_KEY");

Map<String, Object> availability = client.departments.getAvailability("5", "2026-02-15T10:00:00");

if (Boolean.TRUE.equals(availability.get("available"))) {
System.out.println("✅ Slot available! Remaining slots: " + availability.get("remainingSlots"));
} else {
System.out.println("❌ Slot unavailable: " + availability.get("unavailabilityReason"));
}

Cancel an appointment​

import com.moncreneau.Moncreneau;

Moncreneau client = new Moncreneau("YOUR_API_KEY");

client.appointments.cancel("123");
System.out.println("✅ Appointment cancelled, 1 credit refunded");

Error handling​

There is only one exception class, com.moncreneau.exceptions.MoncreneauException (unchecked, RuntimeException) — the business error code is available via getErrorCode():

import com.moncreneau.exceptions.MoncreneauException;

try {
Map<String, Object> appointment = client.appointments.create(data);
} catch (MoncreneauException e) {
switch (e.getErrorCode()) {
case "INSUFFICIENT_CREDITS" -> System.err.println("Insufficient credits: " + e.getMessage());
case "VALIDATION_ERROR" -> System.err.println("Validation: " + e.getDetails());
case "INVALID_API_KEY" -> System.err.println("Invalid API key");
default -> System.err.println("Error " + e.getErrorCode() + " (HTTP " + e.getStatusCode() + "): " + e.getMessage());
}
}

Webhook verification​

verifyWebhookSignature is a static method on the Moncreneau class, not an instance method:

import com.moncreneau.Moncreneau;

boolean isValid = Moncreneau.verifyWebhookSignature(payload, signature, webhookSecret);

if (!isValid) {
// reject the request (401)
}

See Webhook Security for the signature format details.