SDKs
Use the Klarefi TypeScript client and webhook helpers
The TypeScript SDK exists in the private Klarefi repository, but it is not published to npm yet. Public developers should start with curl and the API reference. Pilot teams can use the SDK only when Klarefi grants private package access.
Current Setup
Use the HTTP API directly:
export KLAREFI_API_BASE_URL="https://api.klarefi.com"
export KLAREFI_API_KEY="sk_test_..."
curl "$KLAREFI_API_BASE_URL/api/v1/cases/case_abc123" \
-H "Authorization: Bearer $KLAREFI_API_KEY"When the SDK is published, public JavaScript docs should use npm as the default package manager:
npm install @klarefi/nodeUntil then, do not assume that command works for outside developers. This repository uses Bun internally, but public JavaScript documentation should default to npm unless a customer explicitly uses another package manager.
CLI Status
There is no public klarefi CLI yet. A CLI can make sense after the SDK is
published, for example npx klarefi init to write environment variables and
generate a webhook receiver. Until then, documenting a CLI install path would
promise something developers cannot run.
Use With AI
Agents can read the docs as plain text:
export KLAREFI_DOCS_URL="https://www.klarefi.com"
curl "$KLAREFI_DOCS_URL/llms.txt"
curl "$KLAREFI_DOCS_URL/llms-full.txt"
curl "$KLAREFI_DOCS_URL/docs-source/api/quickstart"When working against the local docs server, set
KLAREFI_DOCS_URL="http://localhost:3000".
Paste this into Claude, ChatGPT, Cursor, or Codex:
Use the Klarefi docs as source material.
1. Read https://www.klarefi.com/llms.txt and https://www.klarefi.com/docs-source/api/quickstart.
2. Use Hosted Intake when Klarefi should run the applicant-facing flow.
3. Use the Processing API only if the Klarefi workspace has Processing API access enabled.
4. Authenticate API calls with Authorization: Bearer $KLAREFI_API_KEY.
5. Use idempotency keys for POST /api/v1/sessions and POST /api/v1/process.
6. Treat webhooks as notifications, then read the case for current state.
7. Verify webhook signatures with the raw request body before JSON parsing.Client Setup
Available only after Klarefi grants private package or registry access:
import { Klarefi } from "@klarefi/node";
const klarefi = new Klarefi({
apiKey: process.env.KLAREFI_API_KEY!,
baseUrl: process.env.KLAREFI_API_BASE_URL!,
});Hosted Intake
const session = await klarefi.sessions.create({
case_type_id: "motor_claim",
external_case_id: "claim_12345",
});
console.log(session.signed_url);The SDK generates an idempotency_key when you do not provide one. Pass your
own key when retries must be safe across process restarts.
Processing API
const queued = await klarefi.cases.submitDocument({
document_url: "https://storage.example.com/claim-form.pdf",
case_type_id: "motor_claim",
external_case_id: "claim_12345",
idempotency_key: "process_claim_12345_doc_1",
});
const caseFile = await klarefi.cases.retrieve(queued.case_id);
const events = await klarefi.cases.events(queued.case_id, { afterCursor: 0 });
const pkg = await klarefi.cases.getPackage(queued.case_id);Webhook Verification
const event = klarefi.webhooks.constructEvent(
rawBody,
request.headers.get("X-Klarefi-Signature"),
process.env.KLAREFI_WEBHOOK_SECRET!,
);Non-2xx API responses throw KlarefiApiError. Network failures throw
KlarefiConnectionError.