Quickstart

Generate a typed Python client from your schema and publish your first event with stable idempotency and delivery outcomes.

The Repost CLI turns your .repost schema into a typed Python package: keyword-only dataclasses, string enums, a webhooks.<type>.<member>() method tree, and descriptors used by the runtime. The repost-client runtime handles validation, serialization, HTTP, retries, idempotency, cancellation, and delivery outcomes. Python 3.10 or later is required.

The client is for trusted server-side code. It holds a publish credential, so do not ship it in desktop, mobile, browser, or other untrusted applications.

1
Install the CLI and runtime

Install the CLI and runtime:

curl -fsSL https://repost.sh/install | sh
2
Define the schema

repost schema init --language python --output ./repost_sdk creates a repost/ workspace, a .env file for your key, and this starter schema:

generator sdk {
  language = "python"
  output   = "../repost_sdk"
}
 
model User {
  id    String
  email String
}
 
type User {
  created
}
 
event UserCreated {
  type      @type(User.created)
  data      User
  timestamp DateTime
}

Python requires an explicit output. The path is relative to repost/schema.repost, and its final directory name becomes the importable package name, repost_sdk here.

3
Record the schema and generate
repost schema migrate dev --name init

This records the first migration and generates the Python package. Commit both directories. Code generation explains every generated file and the CI drift check.

4
Connect an environment

Create an environment in the dashboard, copy its publish API key into .env, then sign in and deploy the migration:

repost auth login
repost schema migrate deploy

Load .env through your framework or process manager. The runtime reads REPOST_SEND_API_KEY, then REPOST_TOKEN.

Your first send

from repost_sdk import RepostClient, User
 
with RepostClient() as repost:
    result = repost.webhooks.user.created(
        customer_id="customer_123",
        data=User(id="user_123", email="[email protected]"),
        idempotency_key="user_123:created",
    )
    print(result.id)  # msg_...

customer_id identifies the customer receiving the event. Generated methods and models catch unknown members, missing fields, and incompatible values in your editor and type checker. The runtime validates and serializes the model again before opening a connection.

The idempotency key is optional. When you omit it, the runtime generates one key and reuses it across that operation's attempts. Pass a business-stable key when your queue or process may repeat the logical send. Reliability explains how to handle ambiguous outcomes.

Create one client for a process or application container and close it during shutdown. A context manager is convenient for scripts and jobs; long-running applications should use their framework lifecycle. A complete generated example lives under examples/python in the repository.

Continue