# iMessage Java & Kotlin SDK

Send and receive iMessages from the JVM with Blooio's official iMessage Java SDK. Published to Maven Central, works with Java 17+ and Kotlin, ships with a fluent builder API, Jackson-based typed models, and a Spring Boot–friendly webhook verifier you can drop into any controller.

## Install

One command to add the iMessage Java SDK to your project.

```kotlin
// Gradle (Kotlin DSL)
dependencies {
    implementation("com.blooio:blooio-sdk:latest.release")
}

// Maven
<dependency>
    <groupId>com.blooio</groupId>
    <artifactId>blooio-sdk</artifactId>
    <version>LATEST</version>
</dependency>
```

## Send your first iMessage

This is the smallest working example — authenticate with your Blooio API key, then call the send-message method on the client.

```java
import com.blooio.Blooio;
import com.blooio.model.SendMessageRequest;

public class Sender {
    public static void main(String[] args) throws Exception {
        Blooio blooio = Blooio.builder()
            .apiKey(System.getenv("BLOOIO_API_KEY"))
            .build();

blooio.chats().sendMessage(SendMessageRequest.builder()
            .phone("+15551234567")
            .body("Hey Alex — thanks for booking a demo. Reply with any questions.")
            .build());
    }
}
```

## Handle inbound iMessages and webhooks

Every inbound iMessage, delivery, read, and reaction event is POSTed to your webhook URL. Use the SDK's signature verifier to reject forged requests and deserialize the payload into typed objects.

```java
@RestController
@RequestMapping("/webhooks")
public class BlooioWebhookController {

private final WebhookVerifier verifier =
        new WebhookVerifier(System.getenv("BLOOIO_WEBHOOK_SECRET"));

@PostMapping(value = "/blooio", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<Void> handle(
        @RequestHeader("X-Blooio-Signature") String signature,
        @RequestBody byte[] body
    ) {
        try {
            BlooioEvent event = verifier.verify(body, signature);
            if ("message.received".equals(event.type())) {
                MessageReceived data = event.dataAs(MessageReceived.class);
                log.info("inbound iMessage: {}", data.body());
            }
        } catch (InvalidSignatureException e) {
            return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
        }
        return ResponseEntity.ok().build();
    }
}
```

## What the SDK gives you on top of raw REST

- Published to Maven Central — pull with Gradle, Maven, or sbt
- Java 17+ and Kotlin 1.9+ supported, Android compatible
- Fluent builders for every request object
- Jackson-based models with typed deserialization for webhook payloads
- Spring Boot–ready webhook controller example in the docs
- Automatic retries on 429/5xx with exponential backoff

## Java iMessage SDK FAQ

**How do I install the Blooio iMessage Java SDK?**
Add `com.blooio:blooio-sdk:latest.release` to your Gradle dependencies or the equivalent Maven coordinates. The SDK is published to Maven Central — no custom repository required.

**Does the iMessage Java SDK support Kotlin?**
Yes. The SDK is pure Java and is fully interoperable with Kotlin. Kotlin-specific coroutine helpers are available in a companion `blooio-sdk-kotlin` artifact.

**How do I verify Blooio webhook signatures in Java / Spring Boot?**
Use the `WebhookVerifier` class. Inject your webhook secret, call `verify(body, signature)`, and it returns a typed `BlooioEvent` or throws `InvalidSignatureException`. A full Spring Boot example lives in the repo README.

**Does the Java SDK work on Android?**
Yes. The SDK targets Java 17 bytecode and has no Android-incompatible dependencies. Use it from native Android apps or React Native modules that call into the JVM.

**Is the Java SDK open source?**
Yes, MIT-licensed and public on GitHub at github.com/Blooio/blooio-java-sdk.
