Getting Started
Install the wacht crate, initialize a client, and make your first backend call.
Use the Rust SDK to connect backend services to Wacht with typed request builders, async execution, and framework integrations such as Axum.
Install
[dependencies]
wacht = "0.1.0-beta.7"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }The axum feature is on by default, so the dependency above already pulls in the Axum middleware. Disable it with default-features = false if you only want the backend client:
[dependencies]
wacht = { version = "0.1.0-beta.7", default-features = false }Environment variables
Set the values used by WachtClient::from_env():
WACHT_API_KEYWACHT_PUBLISHABLE_KEY(preferred) orWACHT_FRONTEND_HOST- optional:
WACHT_PUBLIC_SIGNING_KEY
Create a client and call the API
from_env() reads WACHT_API_KEY and the frontend host, then fetches the deployment's public signing material so Axum auth works without extra setup. It fails if WACHT_API_KEY is missing or the host is unreachable. Every list call returns a PaginatedResponse<T> whose items live on .data.
use wacht::{Result, WachtClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = WachtClient::from_env().await?;
let users = client.users().fetch_users().send().await?;
println!("fetched {} users", users.data.len());
Ok(())
}Explicit configuration
Build a WachtConfig by hand when you can't rely on environment variables. The first argument is the backend API key; the second is the deployment frontend host, which the SDK uses to derive the JWKS issuer for token verification. WachtClient::new errors only if the API key contains bytes that can't go in an HTTP header.
use wacht::{Result, WachtClient, WachtConfig};
#[tokio::main]
async fn main() -> Result<()> {
let config = WachtConfig::new(
"wk_live_xxx",
"https://your-deployment.fapi.trywacht.xyz",
);
let client = WachtClient::new(config)?;
let health = client.health().check().send().await?;
println!("status={}", health.status);
Ok(())
}Request pattern
Every backend method returns a builder; nothing hits the network until you call .send().await. List builders expose .limit(), .offset(), .search(), .sort_key(), and .sort_order(). Listing methods are named fetch_* (for example fetch_organizations, fetch_users, fetch_workspaces), so reach for fetch_ rather than list_ when you want a page of resources.
let result = client
.organizations()
.fetch_organizations()
.limit(20)
.offset(0)
.send()
.await?;
println!("page of {} of {} organizations", result.data.len(), result.total);For the full Rust method surface, see User Management, Organizations and Workspaces, API Auth and OAuth, Webhooks, and AI Runtime and Configuration.