@anomalyarmor/sdk is the official TypeScript SDK for AnomalyArmor. Types are generated straight from our OpenAPI spec via openapi-typescript, so every endpoint is typed end-to-end. Runtime is a thin wrapper around openapi-fetch with Bearer auth and retry-on-429 middleware baked in.
Install
Quickstart
aa_live_.
Authentication
The SDK captures your API key at construction time and attachesAuthorization: Bearer <key> to every outgoing request via a small middleware. The SDK library itself never reads from process.env - that would hide auth at a distance. Only the CLI shim (next section) reads ANOMALYARMOR_API_KEY, because CLIs traditionally do.
CLI
The package ships abin binary so you can smoke-check connectivity without writing code:
health) by design - anything richer belongs in a real script calling the library API.
Rate limiting & retries
The SDK automatically retries HTTP 429 responses, honoringRetry-After. Retries are bounded (default 3 attempts, each sleep capped at 60 s) and only apply to idempotent verbs (GET, HEAD, PUT, DELETE, OPTIONS) so a POST failure never duplicates a side effect.
How requests work
Every typed SDK call flows through six layers: the ergonomic helper →openapi-fetch → the middleware stack → platform fetch → parse / unwrap → a statically-typed response.
Error handling
Ergonomic methods throwAnomalyArmorApiError on 4xx / 5xx responses:
Drop down to the raw client
The ergonomic surface covers the endpoints customers use most often. For anything else,client.raw exposes the full typed openapi-fetch client:
Configuration reference
| Option | Default | Purpose |
|---|---|---|
apiKey | (required) | Your aa_live_* Bearer token. |
baseUrl | https://app.anomalyarmor.ai | Override for staging or a local backend. |
maxRetries | 3 | 429-retry budget. Set to 0 to disable. |
maxRetrySleepSeconds | 60 | Cap on any single Retry-After sleep. |
fetch | globalThis.fetch | Injectable fetch for tests / alternate runtimes. |
Next steps
API reference
Full typed reference for every SDK method
Authentication
How API keys work across the platform
Python SDK
Same API surface in Python
CLI reference
Installable CLI for interactive use
Common Questions
What Node version does the SDK support?
Node 18 or higher, soglobalThis.fetch is available natively. The package ships dual ESM + CJS builds and its own TypeScript types, so it drops into Next.js, Vite, and plain Node projects without extra polyfills.
Does the SDK retry failed requests automatically?
Yes, but only for idempotent verbs (GET, HEAD, PUT, DELETE, OPTIONS) and only on HTTP 429. It honors the Retry-After header with a 3-attempt default, each sleep capped at 60 seconds. Tune with maxRetries / maxRetrySleepSeconds, or pass maxRetries: 0 to opt out when you want explicit control of mutation retries.
How do I call an endpoint that isn’t in client.alerts / client.freshness / client.schema?
Drop down toclient.raw, which is a fully typed openapi-fetch client covering the whole OpenAPI surface. You get the same Bearer auth and retry middleware, plus path/query/body types generated from the spec. Example: client.raw.GET('/api/v1/assets/{asset_id}', { params: { path: { asset_id } } }).
How do I point the SDK at a local backend or staging environment?
PassbaseUrl at construction time: createAnomalyArmorClient({ apiKey, baseUrl: 'http://localhost:8000' }). The default is https://app.anomalyarmor.ai. For testing, you can also inject a custom fetch via the fetch option to stub responses without going over the network.
Why does the SDK library ignore ANOMALYARMOR_API_KEY?
Intentional: library code must receiveapiKey explicitly so authentication isn’t hidden at a distance, which makes multi-tenant and per-request key rotation safe. Only the npx anomalyarmor CLI shim reads ANOMALYARMOR_API_KEY, matching standard CLI conventions.