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

# Chat

> Chat en tiempo real con una lista de canales y búsqueda de mensajes.

> [!NOTE]
>
> Esta página documenta `@whop/elements@1.10.0` y `@whop/elements-react@1.10.0`.

*Desde `v1.10.0`.*

```tsx React theme={null}
import { WhopElements, Chat } from "@whop/elements-react";
import { loadWhop } from "@whop/elements";

function Example() {
  return (
    <WhopElements elements={loadWhop()}>
      <Chat /* options */>
        {/* mount elements here */}
      </Chat>
    </WhopElements>
  );
}
```

```html JavaScript theme={null}
<script src="https://cdn.whop.com/elements/amber/elements.js" data-whop-elements></script>
<script type="module">
  const chat = window.WhopElements().chat.create({ /* options */ });
</script>
```

## Opciones

Pásalas a `whop.chat.create({ … })`, o como props de `<Chat>` en React.

**accessToken** `string`

Un token de usuario con alcance limitado. Crea uno en tu servidor con `POST /api/v1/access_tokens` y establece uno nuevo con `update({ accessToken })` antes de que caduque. Los canales necesitan los scopes `chat:read` y `chat:message:create`; los mensajes directos, `dms:read`, `dms:message:manage` y `dms:channel:manage`; y los chats de soporte, `support_chat:read` y `support_chat:message:create`.

**accountId** `string`

El ID de la cuenta a la que se limita el chat, con el prefijo `biz_`.

**channelId** `string | null`

El ID del canal activo, con el prefijo `feed_` o `chat_feed_`.

**defaultChannelId** `string | null`

El ID del canal activo inicial, con el prefijo `feed_` o `chat_feed_`.

**style** `"imessage" | "discord"`

El estilo del chat. Por defecto es `"imessage"`.

**appearance** `Appearance`

Personalización visual para los elementos de este grupo. Anula el `WhopElements({ appearance })` global. Cámbiala en vivo con `update({ appearance })`.

**locale** `WhopElementsLocale`

Configuración regional para el texto de la interfaz de los elementos de este grupo. Establécela en una de las configuraciones regionales incluidas en la app para anular la configuración global. Cualquier otro valor recurre a la configuración regional predeterminada.

## Eventos

Pasa los callbacks en las opciones de creación o como props de React.

### `onChannelChange`

Se emite cuando cambia el canal activo. Incluye `focusMessageId` cuando el canal se abre con un mensaje enfocado.

**payload** `object`

**propiedades**

**channelId** `string` *required*

**focusMessageId** `string`

### `onLoadingChange`

Se ejecuta cuando cambia el estado de carga agrupado. El valor es `true` mientras algún elemento montado todavía se está cargando.

**loading** `boolean`

## Métodos

Llámalos en el handle de Chat obtenido de `whop.chat.create({ … })` o `useChat()`.

### `update`

Combina nuevas opciones del handle en todos los elementos montados. En React, cambia las props del namespace en su lugar.

**Parámetros**

**options** `Partial\<ChatOptions\>` *required*

### `destroy`

Destruye todos los elementos y subcontroladores que creó este handle, elimina el frame del controlador y libera sus suscripciones. Puedes llamarlo más de una vez, pero un handle destruido rechaza cualquier otra llamada: crea un nuevo handle para empezar de nuevo. React elimina el grupo automáticamente cuando el provider se desmonta.

## Elementos

Los elementos que monta este grupo. Cada uno tiene su propia página:

> [card] [ChatElement](https://docs.whop.com/es/elements/latest/chat/chat.md)
>
> Una vista de mensajes en tiempo real.

> [card] [ChannelListElement](https://docs.whop.com/es/elements/latest/chat/channelList.md)
>
> Una lista de los canales del usuario.

> [card] [SearchElement](https://docs.whop.com/es/elements/latest/chat/search.md)
>
> Un modal para buscar mensajes en todos los canales del usuario.


## Related topics

- [Chat element](https://docs.whop.com/es/developer/guides/chat/chat-element.md)
- [Comunidades y chat](https://docs.whop.com/es/developer/communities/overview.md)
- [Chats de soporte](https://docs.whop.com/es/developer/guides/chat/support-chats.md)
