Java without Spring
Use the JDK's built-in HttpClient when your application does not use Spring Boot. The main API pages show Java with Spring Boot.
Create a credential offer
This example needs Java 17 or later and no extra dependencies. Set LUTRAID_API, LUTRAID_KEY, ORG and ISSUER as shown in the environment setup, then replace the sample profile ID and claim values. Save it as LutraIdExample.java and run java LutraIdExample.java.
LutraIdExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class LutraIdExample {
static final String LUTRAID_API = System.getenv("LUTRAID_API");
static final String LUTRAID_KEY = System.getenv("LUTRAID_KEY");
static final String ORG = System.getenv("ORG");
static final String ISSUER = System.getenv("ISSUER");
static final HttpClient client = HttpClient.newHttpClient();
public static void main(String[] args) throws IOException, InterruptedException {
String body = """
{
"issuanceProfileId": "8f1b…",
"userPinRequired": true,
"credentialOfferMode": "auto",
"data": [
{
"documentTypeId": "pid-sd-jwt",
"credentialSubject": { "given_name": "Ana", "family_name": "Novak" }
}
]
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create(LUTRAID_API + "/v1/organizations/" + ORG
+ "/issuers/" + ISSUER + "/create-credential-offer"))
.header("X-API-Key", LUTRAID_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var res = client.send(request, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() / 100 != 2) {
throw new IOException("LutraID returned " + res.statusCode() + ": " + res.body());
}
// Parse credentialOfferId, credentialOffer and transactionCode from this JSON.
String offerJson = res.body();
System.out.println(offerJson);
}
}
The response remains a JSON string. Use your application's JSON library to read credentialOfferId, credentialOffer and transactionCode; there is no JSON parser in the JDK. When request values come from your application, use that library to serialize them so quotes and backslashes are escaped correctly.
Other requests
The same client can issue a GET with HttpRequest.newBuilder().uri(...).header("X-API-Key", LUTRAID_KEY).GET().build(), followed by client.send(request, HttpResponse.BodyHandlers.ofString()) and the same HTTP status check. See Verify a credential and Status and diagnostics for paths and response fields.
The platform root CA endpoint is unauthenticated: omit the API key header. Its response is a JSON object; parse the certificate field to obtain the PEM rather than saving the JSON envelope as a certificate file.
For authorization-code offers, include .header("Idempotency-Key", key). Generate the key once per offer with java.util.UUID.randomUUID().toString() and reuse it with the same body on retries.