Add to existing project

Take a Kotlin service that already posts webhooks by hand and move one ad-hoc HTTP call onto a generated, type-safe Repost sender in about 15 minutes.

You already have a service that posts webhooks to your customers with a hand-built JSON body and some HTTP client. This guide replaces one of those calls with a generated, type-safe sender: no rewrite, no big bang. Set aside about 15 minutes.

You start from something like this, scattered wherever an event happens:

// The ad-hoc send you have today.
val body = """{"type":"order.created","data":{"id":"${order.id}"}}"""
httpClient.post(customer.webhookUrl) { setBody(body) }

The runtime is published to Maven Central under sh.repost and is server-side only: it holds a publish credential.

The published runtime is version 1.0.18, the Gradle plugin id sh.repost.sdk is 1.0.18, and the schema engine is 0.9.0. Java projects should follow the Java guide instead.

1
Apply the plugin and BOM

Apply the sh.repost.sdk plugin, import repost-bom so every Repost artifact stays on one version, and depend on repost-client-kotlin.

plugins {
    kotlin("jvm") version "2.1.21"
    id("sh.repost.sdk") version "1.0.18"
}
 
// A Kotlin-only project turns off the Java generator.
repostSdk.generators.named("javaSdk") { enabled.set(false) }
 
dependencies {
    implementation(platform("sh.repost:repost-bom:1.0.18"))
    implementation("sh.repost:repost-client-kotlin")
}
pluginManagement {
    repositories { gradlePluginPortal() }
}
 
dependencyResolutionManagement {
    repositories { mavenCentral() }
}

The plugin adds no transitive HTTP, JSON, or logging libraries: only kotlinx-coroutines, for the suspend API.

2
Initialize a schema in your repo

From the repository root:

repost schema init --language kotlin --output ./src/main/kotlin

This scaffolds a repost/ directory. Model the event you already send with a Kotlin generator block:

generator kotlinSdk {
  language       = "kotlin"
  output         = "../build/generated/sources/repost/kotlinSdk/kotlin"
  resourceOutput = "../build/generated/resources/repost/kotlinSdk"
  packageName    = "com.example.repost"
  clientName     = "RepostClient"
}
 
model Order {
  id String
}
 
type Order {
  created
}
 
event OrderCreated {
  type      @type(Order.created)
  data      Order
  timestamp DateTime
}

Add one field per key you send today. Code generation explains the four extra generator fields.

3
Generate the client

The plugin binds repostGenerate before compileKotlin, so a normal build already has your client. To run generation on its own:

./gradlew repostGenerate
4
Connect an environment

Create an environment in the dashboard, copy its publish API key into your environment, then deploy your schema:

repost auth login
repost schema migrate deploy

Replace the ad-hoc call

Swap the raw HTTP post for the generated sender. Repost fans the event out to the customer's registered endpoints, so you no longer track webhookUrl yourself. RepostClient is AutoCloseable, so use { } scopes it; the no-arg constructor reads the credential and endpoint from the environment. Build a model inline with the DSL, or pass a prebuilt one:

val result = repost.webhooks.order.created(customerId = "customer-123") {
    id = "order-123"
}
println(result.id)
 
val prebuilt = Order { id = "order-456" }
println(repost.webhooks.order.created("customer-123", prebuilt).id)

A successful send returns a SendResult whose deliveryState is ACCEPTED; any failure throws a RepostException subclass. close() (via use) returns every owned thread and connection to baseline.

Verify delivery

Trigger the code path that fires the event, then open the dashboard. The send appears in the event stream with its msg_... id and per-endpoint delivery status. Once you trust it, delete the old HTTP call and repeat for the next event type.

Continue