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

# Whop Uygulamalarında Kullanıcıların Kimliğini Doğrulayın

> Whop uygulamanızın içinde mevcut kullanıcıyı doğrulayın ve erişim düzeyini kontrol edin.

Whop uygulamaları `whop.com` üzerinde bir iframe içinde görüntülenir. Uygulamanıza *kimin* istek yaptığını anlayabilmeniz için Whop, aynı kaynaktan gelen her istekte `x-whop-user-token` başlığında kısa ömürlü bir JSON Web Token (JWT) iletir. Bir kullanıcı kimliği almak için bu token'ı SDK ile doğrularsınız, ardından o kullanıcının neleri görebileceğini kontrol edersiniz.

## iframe kullanıcı token'ını doğrulayın

> [!WARNING]
>
> `verifyUserToken` güncel `@whop/sdk` içinde mevcut değildir, bu nedenle bu sayfadaki TypeScript kod parçacıkları referans amacıyla tutulmaktadır ve yazıldıkları şekliyle çalışmaz. Python farklıdır: `whop-sdk`, yardımcıyı `whop_sdk.lib.verify_user_token` olarak sunar ve bunun yanında PyJWT'nin kurulu olmasını gerektirir (`pip install "pyjwt[crypto]"`). `whop_sdk` gem'i de bunu sunar, ancak istemciden farklı bir kök ad alanı altında bir modül fonksiyonu olarak: `WhopSDK::Helpers::VerifyUserToken.verify_user_token!`; istemci ise `Whop_sdk::Client`'tır. Bu, istemci üzerinde bir yöntem değildir ve gem zaten `jwt`'ye bağımlıdır.

Her istekte `verifyUserToken` çağırın. `x-whop-user-token` başlığını okur, JWT imzasını ve son kullanma tarihini doğrular ve kullanıcı kimliğini döndürür. Geçersiz token'lar varsayılan olarak hata fırlatır. TypeScript ve Python ayrıca hata fırlatmayan bir varyant da sunar:

| Dil | Hata fırlatmayan varyant |
| - | - |
| TypeScript | İkinci argüman olarak `{ dontThrow: true }` iletin |
| Python | Hata fırlatmak yerine `None` döndüren `try_verify_user_token` çağırın |
| Ruby | Yok. Tek giriş noktası `verify_user_token!` olduğundan `StandardError` hatasını yakalayın. |

```typescript JS/TS + NextJS theme={null}
import { headers } from "next/headers";
import { whopsdk } from "@/lib/whop-sdk";

export default async function MyServerRenderedPage() {
	const { userId } = await whopsdk.verifyUserToken(await headers());

    // ... the rest of your component / api route etc...
}
```

```javascript JS/TS + ExpressJS theme={null}
import express from "express";
import { whopsdk } from "./lib/whop-sdk";

const app = express();

app.get("/my-route", async (req, res) => {
    const { userId } = await whopsdk.verifyUserToken(req.headers);

    // ... the rest of your route handler
});
```

```python Python + FastAPI theme={null}
from fastapi import FastAPI, Request
from whop_sdk.lib.verify_user_token import verify_user_token

app = FastAPI()

@app.get("/my-route")
async def my_route(request: Request):
    # Synchronous, and app_id is required: it is checked against the token's audience.
    result = verify_user_token(request.headers, app_id="app_xxxxxxxxxxxxx")
    user_id = result.user_id

    # ... the rest of your route handler
```

```ruby Ruby on Rails theme={null}
class MyController < ApplicationController
  def my_action
    # Give the helper a token string or a plain Hash, not an ActionDispatch headers object.
    # app_id is optional in Ruby. Pass it to check the token's audience.
    auth_result = WhopSDK::Helpers::VerifyUserToken.verify_user_token!(
      request.headers["x-whop-user-token"],
      app_id: "app_xxxxxxxxxxxxx",
    )
    user_id = auth_result.user_id

    # ... the rest of your controller action
  end
end
```

Token yalnızca iframe'inizin `window.location.origin` adresine giden isteklere eklenir. Örnekler:

* Göreli sayfa gezinmesi: `<a href="/sub_page">...</a>`
* Alan adı içermeyen fetch çağrıları: `await fetch("/api/quizzes")`

Bunlar `App.base_url` alan adınıza çözümlenir.

> [accordion] API farklı bir alan adında
>
> Ön ucunuz `example.com` üzerinde, API'niz ise `api.example.com` üzerinde çalışıyorsa, API isteklerinin `x-whop-user-token` başlığını taşıması için onları `example.com/api` üzerinden ters proxy ile yönlendirin.
>
> * **Cloudflare**: `example.com` üzerindeki `/api` yolunu `api.example.com/api` olarak yeniden yazmak için bir ["origin rule"](https://developers.cloudflare.com/rules/origin-rules/features/#dns-record) oluşturun.
>
> * **Next.js**: `next.config.mjs` içine bir [rewrite](https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites) ekleyin.
>
> * **nginx / Caddy**: sunucu yapılandırmanızdaki rewrite özelliğini kullanın.
>
> > [!NOTE]
> >
> > Bu kurulum, tarayıcıların katı çapraz kaynak çerez politikaları nedeniyle gereklidir.

## Yerel kurulum

Whop, üretimdeki iframe ve çerez davranışıyla eşleşen yerel bir ters proxy sunar; böylece yazdığınız kod `localhost` üzerinde ve üretimde aynı şekilde çalışır. Kurulum için [geliştirme proxy'si kılavuzuna](https://docs.whop.com/tr/developer/guides/dev-proxy.md) bakın.

## Erişimi kontrol edin

Artık isteği kimin yaptığını bildiğinize göre, neyi görmeye yetkili olduklarını kontrol edin. Bir Experience, Account veya Product'a erişimi doğrulamak için [`checkAccess`](https://docs.whop.com/tr/api-reference/users/check-user-access) yöntemini kullanın.

```typescript JS/TS theme={null}
import { whopsdk } from "@/lib/whop-sdk";

const response = await whopsdk.users.checkAccess({
    id: "user_xxxxxxxxxxxxx",
    resource_id: "resource_id",
});

// Response:
// {
//   "has_access": true,
//   "access_level": "customer"
// }
```

```python Python theme={null}
response = whopsdk.users.check_access(
    resource_id="resource_id",
    id="user_xxxxxxxxxxxxx",
)

# Response:
# {
#   "has_access": True,
#   "access_level": "customer"
# }
```

```ruby Ruby theme={null}
response = whopsdk.users.check_access(
  resource_id: "resource_id",
  id: "user_xxxxxxxxxxxxx",
)

# Response:
# {
#   "has_access": true,
#   "access_level": "customer"
# }
```

```rust Rust theme={null}
let response = client
    .users
    .check_access(&"user_xxxxxxxxxxxxx".to_string(), &"resource_id".to_string(), None)
    .await?;

println!("{} {}", response.has_access, response.access_level);
// has_access => true, access_level => "customer"
```

```go Go theme={null}
response, err := client.Users.CheckAccess(context.TODO(), &whopsdk.CheckAccessUsersRequest{
    ID:         "user_xxxxxxxxxxxxx",
    ResourceID: "resource_id",
})
if err != nil {
    log.Fatal(err)
}

fmt.Println(response.HasAccess, response.AccessLevel)
// has_access => true, access_level => "customer"
```

```bash cURL theme={null}
curl --request GET \
  --url https://api.whop.com/api/v1/users/{id}/access/{resource_id} \
  --header 'Authorization: Bearer <token>'
```

### Kaynak kimlikleri ve erişim düzeyleri

| `resource_id` öneki | Erişimi kontrol edilen |
| - | - |
| `biz_xxxx` | Hesap |
| `prod_xxxx` | Ürün |
| `exp_xxxx` | Deneyim |

Yanıttaki `access_level` şunlardan biridir:

| Düzey | Anlamı |
| - | - |
| `customer` | Kullanıcının geçerli bir üyeliği vardır. Bir deneyim için, ona bağlı herhangi bir ürüne üyeliği vardır. Bir ürün için, o belirli ürüne. Bir hesap için, hesaptaki herhangi bir ürüne. |
| `admin` | Kullanıcı hesabın bir ekip üyesidir (moderatör dahil herhangi bir rol). |
| `no_access` | Kullanıcının erişimi yoktur (`has_access` değeri `false`). |

### Müşteri uygulaması (deneyim görünümü)

Müşteri uygulamaları, yol parametrelerinde iletilen `experienceId` değerine göre erişimi kısıtlamalıdır. Görüntüleyenin geçerli bir üyeliği yoksa `no_access` döndürün veya yönlendirin.

```typescript theme={null}
import { headers } from "next/headers";
import { whopsdk } from "@/lib/whop-sdk";

export default async function ExperiencePage({
    params,
}: {
    params: Promise<{ experienceId: string }>;
}) {
    const { experienceId } = await params;
    const { userId } = await whopsdk.verifyUserToken(await headers());

    const access = await whopsdk.users.checkAccess({
        id: userId,
        resource_id: experienceId,
    });

    if (!access.has_access) {
        return <div>Access denied</div>;
    }

    return <div>Welcome to the experience!</div>;
}
```

Aynı kalıp bir API rotasında da çalışır. `headers()` yerine `request.headers` kullanın ve JSX yerine bir `403 Response` döndürün.

### Kontrol paneli uygulaması (kontrol paneli görünümü)

Kontrol paneli uygulamaları, görünümü yalnızca hesabın ekip üyelerinin yükleyebilmesi için `access_level === "admin"` koşuluna göre erişimi kısıtlamalıdır.

```typescript theme={null}
import { headers } from "next/headers";
import { whopsdk } from "@/lib/whop-sdk";

export default async function DashboardPage({
    params,
}: {
    params: Promise<{ companyId: string }>;
}) {
    const { companyId } = await params;
    const { userId } = await whopsdk.verifyUserToken(await headers());

    const access = await whopsdk.users.checkAccess({
        id: userId,
        resource_id: companyId,
    });

    if (access.access_level !== "admin") {
        return <div>Admin access required</div>;
    }

    return <div>Welcome to the dashboard!</div>;
}
```

Bir API rotasında da aynı kalıp geçerlidir. `headers()` yerine `request.headers` kullanın ve JSX yerine bir `403 Response` döndürün.

## Sonraki adımlar

> [card] [Yerel bir geliştirme proxy'si çalıştırın](https://docs.whop.com/tr/developer/guides/dev-proxy.md)
>
> Üretimdeki iframe + çerez kurulumunu localhost üzerinde eşleyin.

> [card] [İzin isteyin](https://docs.whop.com/tr/developer/guides/permissions.md)
>
> Yayınlamadan önce uygulamanızın ihtiyaç duyduğu kapsamları ekleyin.

> [card] [Webhook'ları dinleyin](https://docs.whop.com/tr/developer/guides/webhooks.md)
>
> Sunucunuzda ödeme, üyelik ve giriş olaylarını alın.

> [card] [Bir uygulama görünümü oluşturun](https://docs.whop.com/tr/developer/guides/app-views.md)
>
> Kontrol paneli görünümlerini, deneyimleri ve keşfet listelemelerini ayarlayın.


## Related topics

- [Whop Entegrasyonlarında Sorun Giderme](https://docs.whop.com/tr/developer/troubleshooting.md)
- [Kullanıcı Kimliklerini KYC ile Doğrulayın](https://docs.whop.com/tr/developer/verification/overview.md)
- [Whop API'ye Genel Bakış](https://docs.whop.com/tr/api-reference/overview.md)
