The Repost CLI turns your .repost schema into a Go package with model structs, enum constants, and typed methods under client.Webhooks. The generated package uses github.com/repost-sh/repost-go for validation, serialization, retries, transport, and delivery outcomes. The client requires Go 1.25 or later and belongs only in trusted server-side code.
repost schema init --language go --output ../internal/repostclientThe command creates repost/schema.repost and .env. A Go generator always needs an explicit output because the generated package is committed with your application.
generator sdk {
language = "go"
output = "../internal/repostclient"
}
model Order {
id String
}
type Order {
created
}
event OrderCreated {
type @type(Order.created)
data Order
timestamp DateTime
}repost schema migrate dev --name initThis records the first migration and generates internal/repostclient. Commit the migration, schema, and generated package together.
Create an environment in the dashboard, then put its publish API key in the .env file created by schema init:
REPOST_SEND_API_KEY=send_...Sign in and deploy the migration before sending the new event type:
repost auth login
repost schema migrate deployLoad .env through your process manager or deployment platform. The Go runtime reads process environment variables; it does not load .env files itself.
Your first send#
package main
import (
"context"
"log"
repost "github.com/repost-sh/repost-go"
"example.com/yourapp/internal/repostclient"
)
func main() {
client, err := repostclient.NewClient(repost.ClientOptions{})
if err != nil {
log.Fatal(err)
}
defer client.Close()
result, err := client.Webhooks.Order.Created(context.Background(), repostclient.OrderCreatedInput{
CustomerID: "customer_123",
Data: repostclient.Order{ID: "order_1001"},
IdempotencyKey: "order_1001:created",
})
if err != nil {
log.Fatal(err)
}
log.Printf("accepted message %s", result.ID)
}CustomerID is the external ID of the customer receiving the event. The generated input requires the correct model type, and the runtime validates the value before opening a connection.
The idempotency key is optional. Without one, the runtime creates a key and reuses it for that operation's internal retries. Supply a stable business key when a queue redelivery, process restart, or application retry can repeat the same logical send. See Reliable sends before adding your own retry loop.
Create one client for each application process. It owns bounded connection pools and an observer dispatcher. Close it during graceful shutdown rather than constructing and closing a client in every request handler.