Skip to main content
AmikaClient needs a bearer token for every request. You provide it in one of two ways: a static accessToken, or a tokenSource that the client calls each time it needs a token. They’re mutually exclusive.

Static token

The simplest case — pass a token string you already have.

The TokenSource interface

For tokens that need to be fetched or refreshed, implement TokenSource:
The client calls token() to obtain a bearer for requests. Returning a promise lets you fetch or refresh on demand.

StaticTokenSource

A ready-made TokenSource that always returns the same token. Equivalent to passing accessToken, but useful when an API expects a TokenSource.

A refreshing token source

Implement TokenSource yourself when tokens expire and need refreshing. The client awaits token() on each request, so you can cache and refresh inside it.
The SDK never reads AMIKA_API_KEY from the environment or disk on your behalf. Sourcing the token — from an env var, a secret manager, or an auth service — is always the caller’s responsibility.