Skip to main content
Set CHECKFU_MODEL_ID to a model configured on your deployment for the examples below. The SDK requires Node.js 22.0.0 or later and also runs in Cloudflare Workers and browsers. It exports both a Promise client and an Effect client.
When you send a user.message, keep the turn from its receipt in data to track that message’s reply or usage. Retry the same payload with the same idempotencyKey to recover the original receipt even if the Session has advanced. See Send events. Promise results are plain JSON with ISO 8601 timestamp strings. Effect results decode through the API’s Schema types, so timestamps are DateTime.Utc.

Compatibility

The SDK exports its Promise client at @checkfu/sdk and its Effect client at both @checkfu/sdk and @checkfu/sdk/effect (see the package’s exports map for all public entry points). Keep @checkfu/sdk and checkfu aligned with your deployed server revision.

Options

new Checkfu(options) and CheckfuClient.layerFetchFromEnv(overrides?) take the same options. CheckfuClient.layer(config) and CheckfuClient.layerFetch(config) require apiKey (which also accepts Redacted.Redacted<string> in Effect), and layer / layerFromEnv omit fetch because you provide your own HttpClient layer. The client never follows redirects. client.withOptions({ ... }) returns a copy with updated options (wrapped in an Effect on the Effect client). Call client.close() to dispose of the Promise client’s runtime.

Resources

Methods mirror the API: path parameters first, then body or query, then request options.
files includes upload and content (aliased as download) for raw bytes alongside metadata methods; see Files. artifacts.versions.content(id, version, { file }) downloads raw bytes from a pinned version, while artifacts.versions.file returns JSON with text or base64 content.

Pending receipts

waitForPending(result) returns an already-settled resource as is. For a pending receipt, it polls for the requested state. The result returned directly by an SDK mutation can carry readiness information in memory. For a receipt read from HTTP or restored from JSON, use an until predicate to confirm the requested state. An Agent update receipt’s version and an Automation update receipt’s revision are targets the predicate can check. A receipt with only an ID and type needs the intended state from your application. For example, load a saved Environment archive receipt and check archived_at on the returned Environment.
restore-environment-archive.ts
maxDelay caps the local polling delay. A retryable response can increase the next delay through Retry-After or retry-after-ms. The SDK caps the server hint at 60 seconds and applies the overall timeout to the entire wait, including those delays.

Pagination

In Effect, paginated list methods return one page, listPages returns a Stream of pages, and listStream returns a Stream of items. For sessions.resources.list, omitting limit returns all remaining resources. Automatic traversal yields each decoded page or its items before following its next cursor. If that cursor has already been used in the traversal, the next pull raises PaginationCursorCycleError without sending another request.

Per-request options

Unary and paginated methods accept headers, timeout, maxRetries, and (in the Promise client) signal. Endpoints that support Idempotency-Key also accept idempotencyKey; passing idempotencyKey to an endpoint that does not support it throws CheckfuConfigError. Use asResponse() or withResponse() before closing the Promise client, even if you already awaited the call. Keep the returned Response if you need to inspect it after close().
sessions.events.stream takes stream-specific options instead: headers, event_deltas, openTimeoutMs, idleTimeoutMs, maxReconnectAttempts, baseReconnectDelayMs, onOpen, and (in the Promise client) signal.

Retries

The SDK retries with exponential backoff (500 ms to 8 seconds, with jitter) and honors Retry-After-Ms and Retry-After up to 60 seconds. With autoIdempotencyKey, each call generates one key and reuses it across retries within that call; to survive a process restart, pass your own key. automations.create always requires a key you choose:

Errors

Every error carries a _tag for Effect and matches instanceof on the classes attached to Checkfu. API errors expose status, errorType, message, requestId, headers, and body. The full list is in SDK error classes.

Types and helpers

Request bodies for Credential secrets expect Redacted.make(...) from effect/Redacted. A few request body/query IDs (ArtifactId, FileId, VaultId, PublicationAddress) are branded types exported from @checkfu/sdk with a .make(value) constructor when passing strings returned by the Promise client. For wildcard Webhooks, follow the receiver example to verify deliveries and dispatch the types you handle. Use unwrapWebhookEvent when your subscription selects specific types supported by the SDK you installed.