Sendery
Sendery

Language SDKs

Kotlin

Use the Java SDK to send Sendery templates from Kotlin.

Install
implementation("co.sendery:sendery-java:0.1.0")
Source code

Requirements

Kotlin/JVM with Java 17+. Add the Java SDK dependency to your Gradle dependencies block.

Set up

Publish a welcome template with name and action_url variables, and create a project API key. Store it as SENDERY_API_KEY on your server.

Shell
export SENDERY_API_KEY="your_project_api_key"

Send an email

Calls are blocking. In a coroutine, run the send inside withContext(Dispatchers.IO) using your application’s coroutine library.

Kotlin
import co.sendery.Sendery

fun main() {
    val sendery = Sendery(System.getenv("SENDERY_API_KEY"))
    val receipt = sendery.send("[email protected]", "welcome", mapOf(
        "name" to "Alex",
        "action_url" to "https://example.com/start"
    ))
    println(receipt.id())
}

Retrieve an email

Use the returned ID to check delivery status.

Kotlin
val message = sendery.get(receipt.id())
println(message.status())

Retry a send

Use a key such as welcome-123 for one email, and keep the payload unchanged on retries. retry(3) allows up to three additional attempts for temporary failures; send() alone makes one attempt. API failures throw co.sendery.SenderyException; inspect status(), code(), errors(), and retryAfter().

Kotlin
val email = sendery.prepare("[email protected]", "welcome", mapOf(
    "name" to "Alex", "action_url" to "https://example.com/start"
), null, "welcome-123")
val receipt = email.retry(3).send()