> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payven.com.tr/llms.txt
> Use this file to discover all available pages before exploring further.

# Mevcut Kullanıcı (/me)

> Aktif kullanıcının organizasyon, merchant ve aktif feature bağlamı.

`/me` endpoint'i; aktif kullanıcının **kim olduğu**, **hangi tenant'a bağlı**, **hangi merchant adına** çalıştığı ve **hangi modüller** için yetkili olduğunu tek bir istekte döner. Konsolun ilk açılışta yaptığı kanonik çağrıdır.

## Endpoint

```http theme={null}
GET /api/v1/me
```

Bearer access token gerektirir.

## İstek

```bash theme={null}
curl https://identity.payven.com.tr/api/v1/me \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiI..."
```

## Yanıt

`200 OK` — `MeDto`:

```json theme={null}
{
  "user": {
    "id":       "9f3d2b8e-...",
    "username": "ayse@example.com",
    "email":    "ayse@example.com",
    "name":     "Ayşe Yılmaz"
  },
  "tenant": {
    "id":            "1a2b3c4d-...",
    "slug":          "payven",
    "display_name":  "Payven A.Ş."
  },
  "merchant": {
    "id":          "3fa85f64-...",
    "external_id": "M-IST-001",
    "name":        "Acme E-Ticaret"
  },
  "roles": ["pos-admin", "transfer-viewer"],
  "features": [
    {
      "code":         "sanalpos",
      "display_name": "Sanal POS",
      "base_path":    "/sanalpos",
      "is_active":    true,
      "permissions": [
        "transactions.view",
        "transactions.refund",
        "merchants.manage"
      ],
      "nav_items": [
        { "id": "dashboard",    "name": "Genel Bakış", "href": "/dashboard" },
        { "id": "transactions", "name": "İşlemler",     "href": "/transactions" },
        { "id": "refunds",      "name": "İadeler",      "href": "/refunds" }
      ]
    },
    {
      "code":         "para-transferi",
      "display_name": "Para Transferi",
      "base_path":    "/paratransferi",
      "is_active":    true,
      "permissions":  ["transfers.view"],
      "nav_items":    [...]
    }
  ]
}
```

| Alan         | Açıklama                                                                                                                                               |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `user`       | Kullanıcı kimliği — `id`, `username`, `email`, `name`                                                                                                  |
| `tenant`     | Aktif tenant — `id`, `slug`, `display_name` (null olabilir, access token claim'inde yoksa)                                                             |
| `merchant`   | Aktif merchant — multi-merchant senaryolarda override edilebilir (null olabilir)                                                                       |
| `roles`      | Tenant rolleri (`pos-admin`, `transfer-admin`, `tenant-admin`, vb.)                                                                                    |
| `features[]` | Tenant planında aktif **modül** feature'ları — her birinin kullanıcının rollerinden çıkarılan effective permission listesi + filtrelenmiş nav item'lar |

## Plan ve kullanım

Tenant planının detayını ayrı endpoint'ten çekin:

```http theme={null}
GET /api/v1/me/plan
```

Yanıt — `MyPlanDto`:

```json theme={null}
{
  "plan": {
    "id":                "abc-...",
    "code":              "standard",
    "name":              "Standart Plan",
    "description":       "...",
    "price":             999900,
    "currency":          "TRY",
    "billing_cycle":     "monthly",
    "features": [
      { "code": "sanalpos",       "name": "Sanal POS",       "category": "module" },
      { "code": "para-transferi", "name": "Para Transferi",  "category": "module" }
    ]
  }
}
```

Tenant planı yoksa yanıt `null` döner.

## Kullanım örnekleri

### Aktif modülleri keşfet

```javascript theme={null}
const me = await fetch("/api/v1/me", { headers: auth }).then(r => r.json());
const activeModules = me.features.filter(f => f.is_active).map(f => f.code);
// → ["sanalpos", "para-transferi"]
```

### UI'da bir butonu permission ile koru

```javascript theme={null}
const sanalpos = me.features.find(f => f.code === "sanalpos");
const canRefund = sanalpos?.permissions.includes("transactions.refund");

if (!canRefund) hideRefundButton();
```

### Sidebar nav item'larını render et

```javascript theme={null}
const navItems = sanalpos?.nav_items ?? [];
// Backend filtered: kullanıcının izni olmayanlar zaten listede yok
```

## Hata response'ları

| HTTP  | Anlam                                       |
| ----- | ------------------------------------------- |
| `401` | Token yok / geçersiz / expired              |
| `404` | (boş) Kullanıcı tenant context'i bulunamadı |

## Alternatif endpoint

`/api/v1/auth/{slug}/me` endpoint'i userinfo proxy olarak da kullanılabilir — sadece ham userinfo döner (roles + email + name), tenant/merchant/feature context'i içermez. Production akışlarında **`/api/v1/me`** tercih edin.
