# Quickstart: Hosted Intake
Create a hosted intake session, redirect the applicant, and read the resulting case file
Source: https://www.klarefi.com/docs/guides/hosted-intake-quickstart

## Overview

Use Hosted Intake when Klarefi should run the applicant-facing flow. Your
backend creates a session, redirects the applicant to a signed URL, and then
uses webhooks or case reads to consume the result.

## Typical Fit

- You want a hosted applicant-facing intake flow.
- You want Klarefi to manage document collection and follow-up questions.
- You want operators to review the resulting case in Klarefi.

## Basic Flow

1. Create an intake session.
2. Redirect the applicant to the signed hosted URL.
3. Receive webhook events or poll case state.
4. Read the case or case package when it is ready for review.

<Mermaid
  title="Hosted Intake sequence"
  chart={`sequenceDiagram
  participant App as Your backend
  participant K as Klarefi
  participant Applicant

App->>K: POST /api/v1/sessions
K-->>App: signed_url
App-->>Applicant: redirect to signed_url
Applicant->>K: complete form and upload documents
K-->>App: signed webhook event
App->>K: GET /api/v1/cases/{caseId}
K-->>App: case with facts and evidence
`}
/>

## Create A Session

Install the TypeScript SDK:

```bash
npm install @klarefi/node
```

Create sessions from trusted server-side code:

```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",
  idempotency_key: "session_2026_05_01_001",
  external_case_id: "claim_12345",
  external_applicant_id: "applicant_789",
  ttl_hours: 168,
  locale: "nl",
});
```

The same request over HTTP:

```http
POST /api/v1/sessions
Authorization: Bearer sk_live_...
Content-Type: application/json

{
  "case_type_id": "motor_claim",
  "idempotency_key": "session_2026_05_01_001",
  "external_case_id": "claim_12345",
  "external_applicant_id": "applicant_789",
  "ttl_hours": 168,
  "locale": "nl"
}
```

Example response:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "signed_url": "https://app.klarefi.com/s/550e8400...?token=...",
  "expires_at": "2026-01-22T10:30:00Z",
  "idempotent_replay": false
}
```

## Redirect The Applicant

Send the applicant to the returned `signed_url`. From there, Klarefi owns the
hosted intake flow, including structured sections, uploads, and follow-up
questions.

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

For a quick local check:

```bash
npx klarefi sessions create \
  --case-type motor_claim \
  --external-case-id claim_12345 \
  --url-only
```

## Consume The Result

After the applicant submits the hosted intake, consume:

- webhook events for state changes
- case reads for current case state
- case packages for review-ready handoff material

The case is the result. Hosted Intake does not produce a separate output model.

```ts
const caseFile = await klarefi.cases.retrieve(session.session_id);
const pkg = await klarefi.cases.getPackage(session.session_id);
```
