fetch.
Requirements
- Node.js 22 or newer
Installation
Set up the client
Create an API key in Settings, then construct the client once and reuse it:https://promptjuggler.com. Point the SDK at another
host (e.g. for testing) with the baseUrl option, or inject a custom fetch.
Per-endpoint usage
Every endpoint in the API reference includes a TypeScript SDK code sample showing the exact call — that’s the place to look for how to invoke each operation and what it returns. A typical flow:Methods return generated model objects with typed fields. They are plain, read-only
data — read the fields, don’t write them back. An enum field can hold a value added to the
API after your SDK version, outside its declared union.
Error handling
When the API responds with an error status, the SDK throws anApiError carrying the HTTP
status code and the server’s message. When the request never reaches the API (DNS failure,
timeout, offline), it throws a ConnectionError. When the API replies with a success status
but the SDK can’t decode the body, it throws a DecodeError: the request succeeded, so
retrying a run starts a second one. All three extend the PromptJugglerError base class, so
you can catch the whole surface at once.
Webhooks
PromptJuggler signs every webhook with thePromptJuggler-Signature header. Verify it
against the raw request body, before any JSON parsing:
verifyWebhookSignature recomputes the HMAC-SHA256 of {timestamp}.{raw_body}, compares
it in constant time, and rejects deliveries whose timestamp falls outside a tolerance
window (default 300s) to prevent replay. Widen or narrow it with the tolerance argument.
It uses the Web Crypto API, so it runs in Node, edge runtimes, and browsers alike.