Sdks

Embed
Preview of the card
<a href="https://forumulate.com/p/watchtower/docs/sdks"><img src="https://forumulate.com/api/public/orgs/watchtower/spaces/docs/pages/a1087e6a-acab-4f50-8553-3ec1b6ff5fd6/social-card.svg?v=3e7ae33eec8b" alt="Sdks" width="600" height="315"></a>

<!-- status: ga language: api -->

SDKs

The API is described by one OpenAPI 3.1 document generated from the server code: GET /openapi.json, snapshotted as apps/web/openapi.json. Client code is generated from that spec, so it cannot drift from the server.

Language

Source

Maintained in this repo

Go

go/wtapi, generated by C5 (oapi-codegen)

yes

TypeScript

apps/web/src/gen/api.ts, from pnpm run gen:api

yes

Rust

the API crates' own types

yes

Anything else

generate from openapi.json with any OpenAPI 3.1 generator

no

Only Rust, Go and TypeScript are maintained here. For other languages point a generator at the published spec; the contract is the spec, and a breaking change shows up as a diff of the snapshot.

Conventions every client sees

  • Public routes live under /v1. Errors are application/problem+json with type, title, status, detail.

  • Lists use ?limit=&cursor= and answer {data, next_cursor}.

  • A resource you cannot access answers 404, not 403.

  • Credentials are a session cookie (web) or Authorization: Bearer <token>. Keep tokens in the environment ($WT_TOKEN), never in source.

Go

c, _ := wtapi.NewClientWithResponses(os.Getenv("WT_API"), wtapi.WithRequestEditorFn(
	func(_ context.Context, r *http.Request) error {
		r.Header.Set("Authorization", "Bearer "+os.Getenv("WT_TOKEN"))
		return nil
	}))
res, err := c.MeWithResponse(ctx)

Explorer and code export

The web app's API page lists every operation, sends requests as the signed-in user (roles and 404s apply) and exports the request as curl, Go or TypeScript fetch with $WT_TOKEN and $WT_API placeholders.

Test data

wtctl gen --scenario <name> --rate 20/s --duration 5m --key-env WT_INGEST_KEY replays the scenarios checkout_latency, regression_after_deploy, noisy_neighbor and cron_misses through the gateway, time-shifted to now with fresh ids on every loop. The Rust testkit is the only place scenarios are defined: cargo run -p wt-testkit --bin gen_fixtures writes testdata/scenarios/*.otlp.json. The key is read from the named environment variable and is never a flag value. Each loop is time-shifted when it starts, so at low rates the data trails now by up to the loop's send time and consecutive loops overlap.

Updated