# Hosted Intake
Build a secure hosted intake flow for forms, documents, follow-up, and review-ready case files
Source: https://www.klarefi.com/docs/guides/hosted-intake

## Overview

Hosted intake gives each applicant a signed session where they can complete the
form, upload documents, and answer follow-up questions. The session keeps form
answers, documents, chat history, extracted facts, and review status together.

Use hosted intake when the applicant-facing experience needs to stay simple but
the back-office review requires evidence, completeness checks, and audit trails.

## Recommended Flow

1. Create an intake session from trusted server-side code.
2. Redirect the applicant to the hosted session URL.
3. Let Klarefi collect answers, documents, and follow-up responses.
4. Subscribe to webhook events for session and case state changes.
5. Pull the final case file into your system of record when review is ready.

## Install

```bash
npm install @klarefi/node
export KLAREFI_API_KEY="sk_test_..."
npx klarefi doctor
```

## Create And Redirect

```ts
import { Klarefi } from "@klarefi/node";

const klarefi = new Klarefi({
  apiKey: process.env.KLAREFI_API_KEY!,
});

const session = await klarefi.sessions.create({
  case_type_id: "motor_claim",
  external_case_id: "claim_12345",
  external_applicant_id: "applicant_789",
  idempotency_key: "session_claim_12345",
  return_url: "https://claims.example.com/claim_12345",
  locale: "nl",
});

return Response.redirect(session.signed_url, 303);
```

The CLI can scaffold starter files for common frameworks:

```bash
npx klarefi hosted-intake install --framework next
```

## Session State

Hosted sessions progress through states such as created, submitted, blocked,
needs review, and completed. Treat webhooks as notifications and read the
current session or case state from the API when your system needs the latest
record.

## Design Notes

Hosted intake should ask only for what the case needs. Prefer targeted follow-up
questions over generic resubmission messages. If a fact cannot be supported by
evidence, route the case to clarification or human review instead of guessing.

## Related Guides

- [Create an intake session](/docs/guides/create-intake-session)
- [Upload documents](/docs/guides/upload-documents)
- [Webhook setup](/docs/guides/webhooks)
