// Shell:// export SPINE_API_KEY=sk_spine_...import { Spine } from 'spine-sdk';const client = new Spine({ apiKey: process.env.SPINE_API_KEY! });
Never commit keys to source control. Use your deployment platform’s
secret manager (AWS Secrets Manager, 1Password, Doppler, etc.) and
inject them at runtime. Never ship keys to the browser — proxy requests
through your own backend instead.
If apiKey is falsy, the Spine constructor throws immediately — before
any network call.
Keys revoked in the dashboard stop working on the next request; you’ll
see SpineAuthError thrown from the SDK. Roll new keys through your
secret store before revoking the old one so running processes don’t
break mid-run. The server caches keys for up to 5 minutes, so leave that
grace window.
For advanced cases (custom proxies, test doubles, alternative runtimes),
pass a pre-configured fetch implementation. The SDK still applies
X-API-KEY and User-Agent headers — your implementation does not need
to set them.
import undici from 'undici';const client = new Spine({ apiKey: process.env.SPINE_API_KEY!, fetch: undici.fetch as typeof fetch,});