This example sends one event to LogZuno's ingestion API from Java. It is the exact file our snippet tests send to the API before the docs are published.
Requirements
Java 11 or later for java.net.http; the text block in the example needs Java 15 or later.
Send an event
// Java 11 or later, standard library only. Save as LogZunoEvent.java and run: java LogZunoEvent.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class LogZunoEvent {
public static void main(String[] args) throws Exception {
String endpoint = System.getenv().getOrDefault("LOGZUNO_ENDPOINT", "https://api.logzuno.app/v1");
String json = """
{"channel": "signups", "event": "User signed up", "user_id": "user-123",
"icon": "🎉", "notify": true, "tags": {"plan": "growth", "source": "website"}}
""";
HttpRequest request = HttpRequest.newBuilder(URI.create(endpoint + "/log"))
.timeout(Duration.ofSeconds(10))
.header("Authorization", "Bearer " + System.getenv("LOGZUNO_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}Save it as LogZunoEvent.java, export LOGZUNO_API_KEY and run java LogZunoEvent.java. LogZuno answers 202 and the event appears in your project's live feed within seconds. Keep the key in an environment variable or your secrets manager, not in source control.
Notes for Java
Build JSON properly. The example writes JSON by hand to stay dependency-free. In an application, build the body with the JSON library you already use (Jackson, Gson) so values are escaped correctly.
Don't block. Use HttpClient.sendAsync or a background executor so request threads never wait on analytics.
Share the client. HttpClient is thread-safe and pools connections: create it once.
What the request contains
The body is the same in every language: a channel and an event, and optionally user_id, group_id, description, icon, notify and tags. All fields, limits and response codes are in sending events and the ingestion API reference.