The TypeScript client is generated into node_modules, and the @repost/client package re-exports it, the same way Prisma's client works. Your application imports one stable package; generation fills it with types from your schema.
Node.js 20 or later is required.
pnpm add -g @repost/cli npm install @repost/client
repost schema initTypeScript is the default language, so no flags are needed. This scaffolds repost/schema.repost with a starter user.created event and a .env file with an empty REPOST_SEND_API_KEY:
generator sdk {
language = "typescript"
}
model User {
id String
email String
}
type User {
created
}
event UserCreated {
type @type(User.created)
data User
timestamp DateTime
}With no output in the generator block, generation targets node_modules/.repost/client, which @repost/client re-exports.
repost schema migrate dev --name initThis records your schema as a migration and generates the client. Until a first generate has run, importing @repost/client fails with:
@repost/client did not initialize yet. Please run "repost schema generate" and try to import it again.Create an environment in the dashboard, copy its publish API key into .env, and deploy your schema:
repost auth login
repost schema migrate deployLoad .env through your framework, your process manager, or Node's --env-file option.
Your first send#
import { createRepostClient, type User } from "@repost/client";
const repost = createRepostClient();
const user: User = {
id: "user_123",
email: "[email protected]",
};
const result = await repost.webhooks.user.created({
customerId: "customer_123",
data: user,
idempotencyKey: "user_123:created",
});
console.log(result.id); // msg_...createRepostClient() never throws; the API key resolves from REPOST_SEND_API_KEY at send time, so a missing key surfaces on the first send. customerId names the customer receiving the event. The idempotencyKey is optional; reusing it with the same payload is safe, and Reliability explains when to pass your own.
TypeScript rejects unknown events, missing fields, and incompatible values before the send ever reaches Repost.