> ## 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.

# 채팅 빠른 시작

> API 키 생성부터 첫 대화 렌더링까지, 웹 또는 iOS 앱에 Whop 채팅을 추가하세요.

[앱에 Whop 채팅 임베드하기](https://www.youtube.com/embed/MqgyFg9YyCw?rel=0)

1
API 키 생성하기

[Whop 개발자 대시보드](https://whop.com/dashboard/developer)에서 API 키를 생성하고 서버에 `WHOP_API_KEY`로 저장하세요.

이 키를 사용하면 내 계정의 컨텍스트에서 작업을 수행할 수 있습니다. 서버에 보관하세요. 브라우저, 모바일 또는 클라이언트 측 코드에 절대 넣지 마세요.

2
패키지 설치하기

백엔드에 SDK를 설치하세요:

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

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

> [tab] cURL
>
> 요청을 직접 보내고 싶다면 [API 레퍼런스](https://docs.whop.com/ko/developer/quickstart.md)를 확인할 수도 있습니다.

프런트엔드에 elements 패키지를 설치하세요:

> [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
>
> Xcode에서 이 Swift 패키지를 추가하세요:
>
> ```text theme={null}
> https://github.com/whopio/whopsdk-elements-swift
> ```
>
> 채팅은 사진, 동영상, 음성 메시지를 지원하므로 앱의 `Info.plist`에 다음 권한을 추가하세요:
>
> ```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>
> ```

웹 패키지가 내보내는 모든 클래스, 옵션, 타입은 [패키지 레퍼런스](https://docs.whop.com/ko/sdk/elements/overview.md)에 나열되어 있습니다.

3
사용자의 사용자 ID 받기

채팅 토큰을 발급하기 전에 자체 사용자를 하위 계정으로 등록하세요. 이렇게 하면 플랫폼 사용자에 다시 매핑할 수 있는 Whop 계정이 생성됩니다.

> [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"
>   }'
> ```

결과로 받은 Whop 사용자 ID(응답의 `owner_user.id`)를 저장해 두고, 채팅 액세스 토큰을 생성할 때 `user_id`로 전달하세요.

사용자의 아바타와 표시 이름을 업데이트하는 방법에 대한 자세한 내용은 [계정별 프로필](https://docs.whop.com/ko/developer/guides/chat/sync-users.md#2-set-an-account-specific-name-and-profile-picture)을 참고하세요.

4
서버에 토큰 엔드포인트 만들기

API 키로 `POST https://api.whop.com/api/v1/access_tokens`를 호출하고 결과 토큰을 클라이언트에 반환하는 엔드포인트를 추가하세요.

> [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
채널, DM 또는 지원 채팅 생성하거나 가져오기

모든 채팅 유형은 실시간 메시지를 사용하며 Chat 요소에서 렌더링할 수 있습니다. 필요에 따라 유형을 선택하세요:

> [card] [채널](https://docs.whop.com/ko/developer/guides/chat/channels.md)
>
> 공개 또는 대규모 그룹 대화를 위한 공유 채팅입니다. 모더레이션, 읽기 전용 옵션을 갖추고 고정된 멤버 수 제한이 없는 방입니다.

> [card] [다이렉트 메시지](https://docs.whop.com/ko/developer/guides/chat/direct-messages.md)
>
> 사용자 간 비공개 대화입니다. DM 목록에 표시되며 최대 50명의 멤버를 포함할 수 있습니다.

> [card] [지원 채팅](https://docs.whop.com/ko/developer/guides/chat/support-chats.md)
>
> 사용자와 내 계정 간의 1:1 지원 대화입니다. 고객에게는 DM처럼 보입니다. 관리자는 DM 목록 대신 지원 받은편지함에서 관리합니다.

채팅을 렌더링하기 전에 열려는 채널 ID를 가져오세요.

* [**채널**](https://docs.whop.com/ko/developer/guides/chat/channels.md) ID는 `chat_feed_`로 시작합니다.
* [**DM**](https://docs.whop.com/ko/developer/guides/chat/direct-messages.md)과 [**지원 채팅**](https://docs.whop.com/ko/developer/guides/chat/support-chats.md) ID는 `feed_`로 시작합니다.

6
앱에서 채팅 렌더링하기

생성한 토큰 엔드포인트를 사용해 토큰을 가져오고 채팅 요소를 렌더링합니다. SDK가 토큰을 관리하고 필요할 때 갱신합니다.

> [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: "")
>     }
>   }
> }
> ```

## 다음 단계

> [card] [인증](https://docs.whop.com/ko/developer/guides/chat/authentication.md)
>
> 임베디드 채팅에 계정 범위 토큰과 OAuth 중 하나를 선택합니다.

> [card] [사용자 동기화하기](https://docs.whop.com/ko/developer/guides/chat/sync-users.md)
>
> 계정 범위 채팅 토큰을 발급하기 전에 Whop 사용자를 생성하거나 매핑하세요.

> [card] [Chat 요소](https://docs.whop.com/ko/developer/guides/chat/chat-element.md)
>
> 채팅 UI의 props, 이벤트, 스타일, 딥 링크 옵션을 알아봅니다.

> [card] [DM 목록 요소](https://docs.whop.com/ko/developer/guides/chat/dms-list-element.md)
>
> 사용자의 다이렉트 메시지 대화 목록을 표시합니다.


## Related topics

- [커뮤니티 & 채팅](https://docs.whop.com/ko/developer/communities/overview.md)
- [채팅 OAuth](https://docs.whop.com/ko/developer/guides/chat/oauth.md)
- [플랫폼 맵](https://docs.whop.com/ko/developer/platform-map.md)
