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

# Inicio rápido del chat

> Añade el chat de Whop a tu app web o de iOS, desde crear una clave de API hasta mostrar tu primera conversación.

[Incrusta el chat de Whop en tu app](https://www.youtube.com/embed/MqgyFg9YyCw?rel=0)

1
Crea una clave de API

Crea una clave de API en el [panel de desarrollador de Whop](https://whop.com/dashboard/developer) y guárdala en tu servidor como `WHOP_API_KEY`.

Esta clave te permite realizar acciones en el contexto de tu cuenta. Mantenla en el servidor. No la pongas nunca en código del navegador, móvil ni del lado del cliente.

2
Instala los paquetes

Instala el SDK en tu backend:

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

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

> [tab] cURL
>
> También puedes consultar [la referencia de la API](https://docs.whop.com/es/developer/quickstart.md) si prefieres hacer las solicitudes tú mismo.

Instala los paquetes de elements en tu 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
>
> Añade este paquete de Swift en Xcode:
>
> ```text theme={null}
> https://github.com/whopio/whopsdk-elements-swift
> ```
>
> El chat admite fotos, vídeos y mensajes de voz, así que añade estos permisos al `Info.plist` de tu 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>
> ```

Todas las clases, opciones y tipos que exportan los paquetes web aparecen en la [referencia de paquetes](https://docs.whop.com/es/sdk/elements/overview.md).

3
Obtén un ID de usuario para tus usuarios

Inscribe a tus propios usuarios como subcuentas antes de generar tokens de chat. Esto crea una cuenta de Whop que puedes asociar con el usuario de tu plataforma.

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

Guarda el ID de usuario de Whop resultante (`owner_user.id` en la respuesta) en tu sistema y pásalo como `user_id` cuando crees tokens de acceso al chat.

Consulta los [perfiles específicos de la cuenta](https://docs.whop.com/es/developer/guides/chat/sync-users.md#2-set-an-account-specific-name-and-profile-picture) para obtener más detalles sobre cómo actualizar los avatares y los nombres visibles de los usuarios.

4
Crea un endpoint de token en tu servidor

Añade un endpoint que llame a `POST https://api.whop.com/api/v1/access_tokens` con tu clave de API y devuelva el token resultante al cliente.

> [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
Crea u obtén un canal, un MD o un chat de soporte

Todos los tipos de chat usan mensajería en tiempo real y se pueden mostrar en el Chat element. Elige el tipo según tus necesidades:

> [card] [Canales](https://docs.whop.com/es/developer/guides/chat/channels.md)
>
> Un chat compartido para conversaciones públicas o de grupos grandes. Salas con moderación, opciones de solo lectura y sin un límite fijo de miembros.

> [card] [Mensajes directos](https://docs.whop.com/es/developer/guides/chat/direct-messages.md)
>
> Una conversación privada entre usuarios. Aparecen en la lista de MD y pueden incluir hasta 50 miembros.

> [card] [Chat de soporte](https://docs.whop.com/es/developer/guides/chat/support-chats.md)
>
> Una conversación de soporte individual entre un usuario y tu cuenta. Los clientes los ven como MD. Los administradores los gestionan desde una bandeja de soporte en lugar de la lista de MD.

Antes de mostrar el chat, obtén el ID del canal que quieres abrir.

* Los ID de los [**canales**](https://docs.whop.com/es/developer/guides/chat/channels.md) empiezan por `chat_feed_`.
* Los ID de los [**MD**](https://docs.whop.com/es/developer/guides/chat/direct-messages.md) y de los [**chats de soporte**](https://docs.whop.com/es/developer/guides/chat/support-chats.md) empiezan por `feed_`.

6
Muestra el chat en tu app

Esto usará el endpoint de token que creaste para obtener un token y mostrar el chat element. El SDK se encarga de gestionar el token y de renovarlo cuando sea necesario.

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

## Próximos pasos

> [card] [Autenticación](https://docs.whop.com/es/developer/guides/chat/authentication.md)
>
> Elige entre tokens con alcance de cuenta y OAuth para el chat incrustado.

> [card] [Sincroniza tus usuarios](https://docs.whop.com/es/developer/guides/chat/sync-users.md)
>
> Crea o asigna usuarios de Whop antes de generar tokens de chat con alcance de cuenta.

> [card] [Chat element](https://docs.whop.com/es/developer/guides/chat/chat-element.md)
>
> Conoce las props, los eventos, los estilos y las opciones de enlaces directos de la interfaz de chat.

> [card] [DMs list element](https://docs.whop.com/es/developer/guides/chat/dms-list-element.md)
>
> Muestra una lista de las conversaciones de mensajes directos de un usuario.


## Related topics

- [OAuth del chat](https://docs.whop.com/es/developer/guides/chat/oauth.md)
- [Comunidades y chat](https://docs.whop.com/es/developer/communities/overview.md)
- [API de chat](https://docs.whop.com/es/developer/guides/chat.md)
