Skip to main content
The TypeScript SDK runs on Node 20 and newer, in browsers, in React Native and in edge runtimes. It has no runtime dependencies.
Set these two values once in your terminal. Every example in these docs reads them, so no example has a host or a key typed into it.
Use a test key (it starts with tf_test_) while you build. Never paste a live key into a page, a ticket or a chat.

Create a client

baseUrl defaults to the production API. credential is an organization key, a teammate token, or a function that returns one (for a key you load from a secret store). Keep organization keys on your servers.

Typed calls

Each method takes a path from the API reference and is typed from it: path parameters, query parameters, the body and the answer.

Pagination

paginate follows next_cursor for every list that has one and yields each item.

Send events

tf.events.send checks every event before it sends anything, gives each event that needs one an idempotency key, and splits a long list into requests within the API’s limits. The builders are on Observation builders.

Errors

Every error answer becomes an error class named for its code, and every one extends TechnicallyFitError with code, message, status, requestId and details. A code this version does not know is a plain TechnicallyFitError.

Retries and rate limits

The client sends a request again after a 429, and after a network failure, 500, 502, 503 or 504 when sending it again cannot change the outcome (reads, updates, and the event endpoints, whose events carry their own keys). It waits the Retry-After the API sent, or until the rate-limit window resets, or backs off with jitter. It never retries another 4xx.
A Retry-After longer than maxRetryAfterSeconds (60 by default) is not waited out: the call throws RateLimitError with retryAfterSeconds, so you can schedule the work.

Page through events

Use paginate to walk through paged endpoints such as GET /v1/events until next_cursor is null:

Sign a teammate in from a member app

A member app holds a teammate token, never an organization key. The SDK runs the sign-in flow and gives you a credential that refreshes itself. The issuer is the authorization server you configure.
When the refresh token no longer works (the teammate left, signed out or the app was turned off), calls throw TeammateSignedOutError: send the person back to sign-in.