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

# Sohbet Kimlik Doğrulaması

> Gömülü sohbet için kullanıcıların kimliğini hesap kapsamlı token'larla veya OAuth ile doğrulayın

> [card] [Whop'un kimlik bilgisi türleri](https://docs.whop.com/tr/developer/guides/auth-scoping.md)
>
> Dört Whop kimlik bilgisi türünün tümü, her birinin ne zaman kullanılacağı ve bir token'ın kapsamının ihtiyaç duyduğu işlemlere nasıl daraltılacağı için Kimlik doğrulama ve API anahtarları sayfasına bakın.

Sohbet SDK'sını kullanmadan önce kullanıcıların kimliğini doğrulamanız gerekir. İki yaklaşımdan birini seçin:

| Yaklaşım | En uygun olduğu durum |
| - | - |
| **[Hesap kapsamlı kullanıcı token'ları](#account-scoped-user-tokens)** | Zaten kendi kullanıcıları olan uygulamalar. Sunucunuz, oturum açma adımı olmadan onlar için Whop token'ları oluşturur. |
| **[OAuth](https://docs.whop.com/tr/developer/guides/chat/oauth.md)** | Kullanıcıların bir oturum açma sayfası veya webview aracılığıyla Whop'ta kendilerinin oturum açmasını isteyen uygulamalar. |

## Hesap kapsamlı kullanıcı token'ları

**Uygulamanızın zaten kendi kullanıcıları varsa** (kendi kimlik doğrulama / oturum sisteminiz aracılığıyla) bu yaklaşımı kullanın. Mevcut giriş akışınızı korur ve o anda oturum açmış olan kullanıcı için bir Whop token'ı oluşturursunuz — ek bir oturum açma adımı olmadan.

Sunucunuz, Whop API anahtarınızı ihtiyaç duyulduğunda kısa ömürlü bir kullanıcı token'ıyla değiştirir ve bunu istemciye döndürür. Token'ın hangi kullanıcı için olduğuna siz karar verirsiniz.

### Kimlik bilgilerinizi toplayın

Üç şeye ihtiyacınız olacak:

1. **API anahtarı** — [Whop Geliştirici Kontrol Paneli](https://whop.com/dashboard/developer) üzerinden bir tane oluşturun. Bir parola gibi davranın ve yalnızca sunucunuzda tutun.
2. **Hesap kimliği**. Bunu kontrol paneli URL'nizde bulabilirsiniz: `whop.com/dashboard/biz_XXXXXXXXX/`.
3. **Kullanıcı kimliği** — kimliğini doğrulamak istediğiniz kullanıcı. Üretimde bunu kendi kimlik doğrulama / oturum sisteminizden türetin.

> [!NOTE]
>
> Gömülü sohbet için, bir token oluştururken hem `account_id` hem de `user_id` birlikte zorunludur.

### Sunucunuzda bir token uç noktası oluşturun

API anahtarınızla `POST https://api.whop.com/api/v1/access_tokens` çağrısı yapan ve ortaya çıkan token'ı istemciye döndüren bir uç nokta ekleyin.

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

### Token'ı uygulamanızdan getirin

SDK'ya, uç noktanızdan veri getiren bir token geri çağırma fonksiyonu sağlayın. Sohbet öğeleri, kimlik doğrulamaya ihtiyaç duyduklarında ve token'ın süresi dolduğunda otomatik olarak bunu çağırır.

> [tab] React
>
> ```typescript theme={null}
> async function getToken() {
>   const response = await fetch("/api/chat/token", { method: "POST" });
>   const data = await response.json();
>   return data.token;
> }
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> async function getToken() {
>   const response = await fetch("/api/chat/token", { method: "POST" });
>   const data = await response.json();
>   return data.token;
> }
> ```

> [tab] Swift
>
> ```swift theme={null}
> import WhopElements
>
> class WhopAPITokenProvider: WhopTokenProvider {
>     private let serverURL = URL(string: "https://your-server.com")!
>
>     func getToken() async -> WhopTokenResponse {
>         do {
>             var req = URLRequest(url: serverURL.appendingPathComponent("api/chat/token"))
>             req.httpMethod = "POST"
>
>             let (data, _) = try await URLSession.shared.data(for: req)
>             let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
>             return WhopTokenResponse(accessToken: json["token"] as? String ?? "")
>         } catch {
>             return WhopTokenResponse(accessToken: "")
>         }
>     }
> }
> ```
>
> Uygulama başlatıldığında token sağlayıcısını SDK'ya iletin:
>
> ```swift theme={null}
> .task {
>     await WhopSDK.configure(tokenProvider: WhopAPITokenProvider())
> }
> ```

### Gerekli kapsamlar

Token'ı oluştururken şu kapsamları isteyin:

| Kapsam | Amaç |
| - | - |
| `chat:message:create`, `chat:read` | Kanallar |
| `dms:read`, `dms:message:manage`, `dms:channel:manage` | Doğrudan mesajlar |
| `support_chat:read`, `support_chat:message:create` | Destek sohbetleri |

> [!NOTE]
>
> Uygulamanız kullanıcı hesaplarına sahipse ve hesap kapsamlı sohbet token'ları oluşturuyorsa, `user_id` değerlerini buraya iletmeden önce bu kullanıcıları senkronize edin. Kullanıcı senkronizasyonu OAuth'un bir parçası değildir.

> [card] [Kullanıcılarınızı senkronize edin](https://docs.whop.com/tr/developer/guides/chat/sync-users.md)
>
> Hesap kapsamlı sohbet token'ları oluşturmadan önce Whop kullanıcılarını oluşturun veya eşleyin.

## OAuth

Bu kılavuzun hesap kapsamlı kullanıcı token'larına odaklanabilmesi için OAuth kendi sayfasında yer alır.

Uygulamanızın, kullanıcıların bir oturum açma sayfası veya iOS webview aracılığıyla Whop'ta kendilerinin oturum açmasını istediği durumlarda OAuth kullanın. Uygulamanızın kullanıcıya ait bir Whop hesabına erişmesi gerektiğinde veya arka ucunuzun Whop kullanıcı token'ları oluşturmasını istemediğinizde doğru seçim budur.

> [card] [OAuth](https://docs.whop.com/tr/developer/guides/chat/oauth.md)
>
> OAuth kapsamlarını, yönlendirme URI'lerini, web token uç noktalarını ve iOS'ta SDK tarafından yönetilen OAuth'u ayarlayın.


## Related topics

- [Whop Entegrasyonlarında Sorun Giderme](https://docs.whop.com/tr/developer/troubleshooting.md)
- [Öğe Oturumları (Eski)](https://docs.whop.com/tr/sdk/elements/overview.md)
- [Sohbet Oturumu Oluşturun](https://docs.whop.com/tr/sdk/elements/chat-session.md)
