> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Quickstart voor chat

> Voeg Whop-chat toe aan je web- of iOS-app, van het aanmaken van een API-sleutel tot het weergeven van je eerste gesprek.

[Whop-chat insluiten in je app](https://www.youtube.com/embed/MqgyFg9YyCw?rel=0)

1
Maak een API-sleutel aan

Maak een API-sleutel aan in het [Whop Developer Dashboard](https://whop.com/dashboard/developer) en sla die op je server op als `WHOP_API_KEY`.

Met deze sleutel kun je acties uitvoeren binnen de context van je account. Bewaar hem op de server. Zet hem nooit in browser-, mobiele of client-side code.

2
Installeer packages

Installeer de SDK in je backend:

> [tab] Next.js
>
> ```bash theme={null}
> pnpm add @whop/sdk
> ```

> [tab] Express
>
> ```bash theme={null}
> pnpm add @whop/sdk
> ```

> [tab] cURL
>
> Je kunt ook [de API-referentie](https://docs.whop.com/nl/developer/quickstart.md) raadplegen als je de requests liever zelf doet.

Installeer de elements-packages in je frontend:

> [tab] React
>
> ```bash theme={null}
> pnpm add @whop/embedded-components-react-js @whop/embedded-components-vanilla-js
> ```

> [tab] HTML
>
> ```html theme={null}
> <script src="https://apollo.elements.whop.com/release/elements.js"></script>
> ```

> [tab] iOS
>
> Voeg dit Swift-package toe in Xcode:
>
> ```text theme={null}
> https://github.com/whopio/whopsdk-elements-swift
> ```
>
> Chat ondersteunt foto's, video's en spraakberichten, dus voeg deze permissies toe aan de `Info.plist` van je app:
>
> ```xml Info.plist theme={null}
> <key>NSCameraUsageDescription</key>
> <string>Allow camera access to take photos and videos in chat</string>
> <key>NSMicrophoneUsageDescription</key>
> <string>Allow microphone access to record voice messages in chat</string>
> <key>NSPhotoLibraryUsageDescription</key>
> <string>Allow photo library access to share photos and videos in chat</string>
> ```

Elke klasse, optie en elk type die de webpackages exporteren, staat in de [packagereferentie](https://docs.whop.com/nl/sdk/elements/overview.md).

3
Haal een gebruikers-ID op voor je gebruikers

Schrijf je eigen gebruikers in als subaccounts voordat je chattokens aanmaakt. Zo ontstaat een Whop-account dat je kunt koppelen aan de gebruiker op je platform.

> [tab] Next.js
>
> ```typescript theme={null}
> import { WhopClient } from "@whop/sdk";
>
> const client = new WhopClient({ token: process.env.WHOP_API_KEY });
>
> const account = await client.accounts.create({
>   email: "user@example.com",
>   title: "Jane Doe",
>   external_id: "user_12345", // your platform's user ID
> });
> ```

> [tab] Express
>
> ```typescript theme={null}
> import { WhopClient } from "@whop/sdk";
>
> const client = new WhopClient({ token: process.env.WHOP_API_KEY });
>
> const account = await client.accounts.create({
>   email: "user@example.com",
>   title: "Jane Doe",
>   external_id: "user_12345", // your platform's user ID
> });
> ```

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST https://api.whop.com/api/v1/accounts \
>   -H "Authorization: Bearer $WHOP_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "email": "user@example.com",
>     "title": "Jane Doe",
>     "external_id": "user_12345"
>   }'
> ```

Sla de resulterende Whop-gebruikers-ID (`owner_user.id` in de response) aan jouw kant op en geef die mee als `user_id` wanneer je chattoegangstokens aanmaakt.

Zie [accountspecifieke profielen](https://docs.whop.com/nl/developer/guides/chat/sync-users.md#2-set-an-account-specific-name-and-profile-picture) voor meer informatie over het bijwerken van avatars en weergavenamen van gebruikers.

4
Maak een token-endpoint op je server

Voeg een endpoint toe dat `POST https://api.whop.com/api/v1/access_tokens` aanroept met je API-sleutel en het resulterende token aan de client retourneert.

> [tab] Next.js
>
> ```typescript app/api/chat/token/route.ts theme={null}
> import { NextResponse } from "next/server";
> import { WhopClient } from "@whop/sdk";
>
> const client = new WhopClient({ token: process.env.WHOP_API_KEY });
>
> export async function POST() {
>   // Derive these from your own auth / session in production.
>   const user_id = "user_XXXXXXXXXXXX";
>   const account_id = "biz_XXXXXXXXXXXXX";
>
>   const { token } = await client.accessTokens.create({
>     account_id,
>     user_id,
>     scoped_actions: [
>       "chat:message:create",
>       "chat:read",
>       "dms:read",
>       "dms:message:manage",
>       "dms:channel:manage",
>       "support_chat:read",
>       "support_chat:message:create",
>     ],
>   });
>
>   return NextResponse.json({ token });
> }
> ```

> [tab] Express
>
> ```typescript server.ts theme={null}
> import express from "express";
> import { WhopClient } from "@whop/sdk";
>
> const app = express();
> app.use(express.json());
>
> const client = new WhopClient({ token: process.env.WHOP_API_KEY });
>
> app.post("/api/chat/token", async (_req, res) => {
>   // Derive these from your own auth / session in production.
>   const user_id = "user_XXXXXXXXXXXX";
>   const account_id = "biz_XXXXXXXXXXXXX";
>
>   const { token } = await client.accessTokens.create({
>     account_id,
>     user_id,
>     scoped_actions: [
>       "chat:message:create",
>       "chat:read",
>       "dms:read",
>       "dms:message:manage",
>       "dms:channel:manage",
>       "support_chat:read",
>       "support_chat:message:create",
>     ],
>   });
>
>   res.json({ token });
> });
>
> app.listen(3000);
> ```

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST https://api.whop.com/api/v1/access_tokens \
>   -H "Authorization: Bearer $WHOP_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "account_id": "biz_XXXXXXXXXXXXX",
>     "user_id": "user_XXXXXXXXXXXX",
>     "scoped_actions": [
>       "chat:message:create",
>       "chat:read",
>       "dms:read",
>       "dms:message:manage",
>       "dms:channel:manage",
>       "support_chat:read",
>       "support_chat:message:create"
>     ]
>   }'
> ```

5
Maak een kanaal, DM of supportchat aan of haal er een op

Alle chattypes gebruiken realtime berichten en kunnen worden weergegeven in het Chat-element. Kies het type op basis van je behoeften:

> [card] [Kanalen](https://docs.whop.com/nl/developer/guides/chat/channels.md)
>
> Een gedeelde chat voor openbare gesprekken of gesprekken in grote groepen. Ruimtes met moderatie, alleen-lezenopties en geen vaste ledenlimiet.

> [card] [Directe berichten](https://docs.whop.com/nl/developer/guides/chat/direct-messages.md)
>
> Een privégesprek tussen gebruikers. Deze verschijnen in de DM-lijst en kunnen maximaal 50 leden hebben.

> [card] [Supportchat](https://docs.whop.com/nl/developer/guides/chat/support-chats.md)
>
> Een één-op-één-supportgesprek tussen een gebruiker en je account. Klanten zien ze als DM's. Beheerders beheren ze via een supportinbox in plaats van via de DM-lijst.

Haal voordat je de chat weergeeft de ID op van het kanaal dat je wilt openen.

* ID's van [**kanalen**](https://docs.whop.com/nl/developer/guides/chat/channels.md) beginnen met `chat_feed_`.
* ID's van [**DM's**](https://docs.whop.com/nl/developer/guides/chat/direct-messages.md) en [**supportchats**](https://docs.whop.com/nl/developer/guides/chat/support-chats.md) beginnen met `feed_`.

6
Geef de chat weer in je app

Hierbij wordt het token-endpoint dat je hebt aangemaakt gebruikt om een token op te halen en het chat-element weer te geven. De SDK beheert het token en vernieuwt het wanneer nodig.

> [tab] React
>
> ```tsx theme={null}
> "use client";
>
> import {
>   ChatElement,
>   ChatSession,
>   Elements,
> } from "@whop/embedded-components-react-js";
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
>
> const elements = loadWhopElements();
>
> async function getToken() {
>   const res = await fetch("https://your-server.com/api/chat/token", { method: "POST" });
>   const data = await res.json();
>   return data.token;
> }
>
> export function Chat() {
>   return (
>     <Elements elements={elements}>
>       <ChatSession token={getToken}>
>         <ChatElement
>           options={{ channelId: "chat_feed_XXXXXXXXXXXXXX" }}
>           style={{ height: "100dvh", width: "100%" }}
>         />
>       </ChatSession>
>     </Elements>
>   );
> }
> ```

> [tab] HTML
>
> ```html theme={null}
> <div id="chat" style="height: 100vh"></div>
>
> <script>
>   const elements = new WhopElements();
>
>   async function getToken() {
>     const res = await fetch("https://your-server.com/api/chat/token", { method: "POST" });
>     const data = await res.json();
>     return data.token;
>   }
>
>   const session = elements.createChatSession({ token: getToken });
>   const chat = session.createElement("chat-element", {
>     channelId: "chat_feed_XXXXXXXXXXXXXX",
>   });
>
>   chat.mount("#chat");
> </script>
> ```

> [tab] iOS
>
> ```swift theme={null}
> import SwiftUI
> import WhopElements
>
> struct ContentView: View {
>   var body: some View {
>     WhopChatView(
>       channelId: "chat_feed_XXXXXXXXXXXXXX",
>       style: .imessage
>     )
>     // This should be done as soon as you know your user is authenticated so its
>     // prepared and ready to use without delays.
>     .task {
>       await WhopSDK.configure(tokenProvider: WhopAPITokenProvider())
>     }
>   }
> }
>
> class WhopAPITokenProvider: WhopTokenProvider {
>   func getToken() async -> WhopTokenResponse {
>     let url = URL(string: "https://your-server.com/api/chat/token")!
>     var request = URLRequest(url: url)
>     request.httpMethod = "POST"
>
>     do {
>       let (data, _) = try await URLSession.shared.data(for: request)
>       let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
>       return WhopTokenResponse(accessToken: json["token"] as? String ?? "")
>     } catch {
>       return WhopTokenResponse(accessToken: "")
>     }
>   }
> }
> ```

## Volgende stappen

> [card] [Authenticatie](https://docs.whop.com/nl/developer/guides/chat/authentication.md)
>
> Kies tussen tokens met accountscope en OAuth voor ingesloten chat.

> [card] [Synchroniseer je gebruikers](https://docs.whop.com/nl/developer/guides/chat/sync-users.md)
>
> Maak Whop-gebruikers aan of koppel ze voordat je chattokens met accountscope aanmaakt.

> [card] [Chat-element](https://docs.whop.com/nl/developer/guides/chat/chat-element.md)
>
> Leer de props, events, stijlen en deeplinkopties voor de chat-UI kennen.

> [card] [DM-lijstelement](https://docs.whop.com/nl/developer/guides/chat/dms-list-element.md)
>
> Toon een lijst met de directe gesprekken van een gebruiker.


## Related topics

- [Playground voor ingesloten chat](https://docs.whop.com/nl/developer/guides/chat/playground.md)
- [Chat-OAuth](https://docs.whop.com/nl/developer/guides/chat/oauth.md)
- [Chat API](https://docs.whop.com/nl/developer/guides/chat.md)
