Skip to main content
@humanity-org/connect-sdk is the official TypeScript helper for Humanity’s Public API. It wraps the generated REST client with ergonomic helpers for OAuth, preset verification, feeds, and error handling so partner teams can ship integrations quickly.

Installation

Initialization & configuration

Create an instance per incoming request (ideal for serverless) or share a singleton and pass tokens into each helper—whichever matches your runtime. Store secrets in your platform’s secret manager; never embed them in client-side bundles.
Next.js / SSR frameworks: Do not instantiate the SDK at module level during build time, as environment variables may not be available. Use lazy initialization instead:

OAuth helpers

Every helper maps to an OAuth endpoint (/oauth/authorize, /oauth/token, /oauth/revoke) and enforces the PKCE + grant-type requirements documented in the API reference.

buildAuthUrl options

Returns: { url: string, codeVerifier: string } — the state is NOT returned; you must pass it in and store it yourself.

TokenResult

The exchangeCodeForToken helper returns a fully typed TokenResult:

Static security helpers

The SDK provides static methods for OAuth security parameters:

Preset verification

  • verifyPreset, verifyPresets, and getPreset expose the /presets/* endpoints with fully typed responses (including evidence payloads).
  • Use listPresets() to discover all available presets with their metadata.
  • Maximum of 10 presets per batch request; the helper enforces this before hitting the API.

PresetBatchResult

The verifyPresets helper returns a PresetBatchResult with two arrays:

Query Engine

For declarative queries against user credentials, use the Query Engine:
See the Query Engine documentation for operators and examples.

Dropping down to the raw client

The generated sdk.client exposes every controller method exactly as declared in the OpenAPI. Use it whenever you need lower-level access or when rolling your own abstractions.
Because the SDK and API reference regenerate from the same DTOs (src/contracts), you can rely on TypeScript to catch breaking changes long before runtime.

Error handling

The SDK exports typed error classes for precise error handling:
  • Rate limits follow the guidance in Environments & tooling. Honor Retry-After headers and reuse idempotency_key values when retrying POSTs.
  • If you lose track of the SDK abstraction, call sdk.client directly—both layers share the same authentication headers and transport pipeline.