Skip to main content

Java / Kotlin SDK

The notifizz-java package is the official JVM SDK for Notifizz, published on Maven Central. Use it from Java or Kotlin to track events, trigger workflows, generate authentication tokens, and send notifications.

Installation

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

NotifizzClient

Constructor

import com.notifizz.NotifizzClient;

NotifizzClient client = new NotifizzClient("YOUR_AUTH_SECRET_KEY", "YOUR_SDK_SECRET_KEY");
ParameterTypeDescription
authSecretKeyStringYour Auth Secret Key from the Notifizz dashboard.
sdkSecretKeyStringYour SDK Secret Key from the Notifizz dashboard.

Methods

client.track(props)

Creates a tracking context for an event. Returns a TrackContext that you chain workflows onto.
Map<String, Object> props = new HashMap<>();
props.put("eventName", "order_shipped");
props.put("sdkSecretKey", "YOUR_SDK_SECRET_KEY");
props.put("properties", Map.of(
    "orderId", "ORD-4521",
    "carrier", "FedEx"
));

TrackContext context = client.track(props);
context.workflow("shipping_notification", List.of(
    Map.of("id", "user_42", "email", "alice@example.com")
));
context.send();
Parameters (map keys):
KeyTypeRequiredDescription
eventNameStringYesThe event slug matching a workflow in the dashboard.
sdkSecretKeyStringYesYour SDK Secret Key.
propertiesMap<String, Object>YesArbitrary key-value data attached to the event.
Returns: TrackContext

context.workflow(campaignId, recipients)

Attaches a workflow and its recipients. Chainable — you can call it multiple times before send().
context
    .workflow("notify_author", List.of(
        Map.of("id", "author_1", "email", "author@example.com")
    ))
    .workflow("notify_team", List.of(
        Map.of("id", "team_1", "email", "lead@example.com"),
        Map.of("id", "team_2", "email", "manager@example.com")
    ));
ParameterTypeDescription
campaignIdStringThe workflow/campaign ID from the dashboard.
recipientsList<Map<String, Object>>List of recipient maps with at least id and email.
Returns: TrackContext (chainable)

context.send()

Sends the tracked event with all attached workflows.
context.send();
Unlike the Node.js SDK, events are not auto-sent in Java. You must call context.send() explicitly.

client.send(request)

Sends a notification directly to the Notification Center, bypassing the event/workflow system.
Map<String, Object> request = new HashMap<>();
request.put("notifId", "notif_template_123");
request.put("properties", Map.of(
    "recipients", List.of(
        Map.of("id", "user_42", "email", "alice@example.com")
    ),
    "title", "Your report is ready"
));

Map<String, Object> response = client.send(request);
KeyTypeRequiredDescription
notifIdStringYesThe notification template ID.
propertiesMap<String, Object>YesMust include a recipients list.
Returns: Map<String, Object> — the API response.

client.generateHashedToken(userId)

Generates an HMAC token for backend token authentication.
String token = client.generateHashedToken("user_42");
ParameterTypeDescription
userIdStringThe user’s unique identifier.
Returns: String — an SHA-256 HMAC hash.

client.config(opts)

Configures SDK behavior.
client.config(Map.of("autoSendDelayMs", 2000));
KeyTypeDefaultDescription
autoSendDelayMsint1000Delay in ms (used internally).

Kotlin example

The SDK works naturally with Kotlin:
val client = NotifizzClient("YOUR_AUTH_SECRET_KEY", "YOUR_SDK_SECRET_KEY")

client.track(mapOf(
    "eventName" to "user_signed_up",
    "sdkSecretKey" to "YOUR_SDK_SECRET_KEY",
    "properties" to mapOf("plan" to "pro")
)).workflow("welcome_campaign", listOf(
    mapOf("id" to "user_1", "email" to "alice@example.com")
)).send()

Next steps

Event Tracking overview

Compare all backend SDKs.

Notification Center

Set up the widget to display the notifications you’re sending.