{
  "openapi": "3.1.0",
  "info": {
    "title": "Yapay Zekâ Eğitimi Kurum API",
    "version": "v1",
    "summary": "Kurumların kendi kullanıcılarına eğitim sunması için API.",
    "description": "Kurum API v1 ile eğitim kataloğunu okuyabilir, kendi kullanıcılarınızın (öğrenenlerin) ilerlemesini ve katılım belgelerini yönetebilir, eğitimleri sitenize gömebilirsiniz.\n\n**Kimlik:** her istekte `Authorization: Bearer yze_live_…` başlığı gerekir. Anahtar yalnız üretildiği an gösterilir; sunucuda yalnız özeti saklanır. `oku` yetkili anahtar yalnız GET isteklerinde kullanılabilir.\n\n**Öğrenen kimliği:** `dis_kimlik` sizin sisteminizdeki kullanıcı numarasıdır (1–120 karakter; harf, rakam ve `. _ @ : + -`). Kişisel veri göndermeniz gerekmez; belge için ad soyad isteğe bağlıdır.\n\n**Hız sınırı:** anahtar başına dakikalık istek sayısı planınıza bağlıdır; `X-RateLimit-Limit` başlığı sınırı bildirir. Aşılırsa `429` ve `Retry-After` döner.\n\n**CORS:** tarayıcıdan çağrı yalnız kurumunuzun izinli alan adlarından kabul edilir. Anahtarınızı tarayıcıya koymayın; sunucudan sunucuya çağrı önerilir.\n\n**Hata biçimi:** `{\"hata\": \"kod\", \"ileti\": \"Türkçe açıklama\"}`.\n\n**Gömme:** `POST /gomme-belirteci` ile 10 dakika geçerli bir belirteç alın ve sayfanıza `<iframe src=\"https://yapayzekaegitimi.com/gomulu/?b=BELIRTEC\">` koyun. Gömülü sayfalar çerez kullanmaz; ilerleme öğrenenin kaydına yazılır.\n\n**Webhook:** kurum kaydınızda webhook adresi tanımlıysa `ders_bitti`, `rota_bitti` ve `belge_verildi` olayları JSON olarak `POST` edilir. Başlıklar: `X-YZE-Olay`, `X-YZE-Teslimat`, `X-YZE-Imza: sha256=<gövdenin webhook sırrınızla HMAC-SHA256 özeti (onaltılık)>`. `2xx` dışındaki yanıtlarda 1 dk, 5 dk, 30 dk ve 2 saat sonra yeniden denenir (toplam 5 deneme)."
  },
  "servers": [
    {"url": "https://yapayzekaegitimi.com/api/v1"}
  ],
  "security": [{"anahtar": []}],
  "tags": [
    {"name": "Katalog", "description": "Kurumunuza açık eğitimler ve dersler"},
    {"name": "Öğrenenler", "description": "Kendi kullanıcılarınız"},
    {"name": "İlerleme ve belge", "description": "Ders bitirme ve katılım belgesi"},
    {"name": "Gömme", "description": "Eğitimi kendi sitenizde göstermek"}
  ],
  "paths": {
    "/": {
      "get": {
        "tags": ["Katalog"], "operationId": "kok", "summary": "Sürüm bilgisi ve bu belgenin adresi", "security": [],
        "responses": {"200": {"description": "Sürüm bilgisi", "content": {"application/json": {"schema": {"type": "object", "properties": {"ad": {"type": "string"}, "surum": {"type": "string"}, "belge": {"type": "string", "format": "uri"}, "gelistirici": {"type": "string", "format": "uri"}}}}}}}
      }
    },
    "/katalog": {
      "get": {
        "tags": ["Katalog"], "operationId": "katalog", "summary": "Kurumunuza açık eğitimlerin listesi",
        "responses": {
          "200": {"description": "Kurum bilgisi ve eğitimler", "content": {"application/json": {"schema": {"type": "object", "properties": {
            "kurum": {"type": "object", "properties": {"slug": {"type": "string"}, "ad": {"type": "string"}, "plan": {"type": "string", "enum": ["deneme", "standart", "kurumsal"]}, "koltuk": {"type": "integer", "description": "En çok öğrenen sayısı"}, "ogrenen": {"type": "integer", "description": "Kayıtlı öğrenen sayısı"}}},
            "rotalar": {"type": "array", "items": {"$ref": "#/components/schemas/RotaOzeti"}}}}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "429": {"$ref": "#/components/responses/HizSiniri"}
        }
      }
    },
    "/rota/{slug}": {
      "get": {
        "tags": ["Katalog"], "operationId": "rota", "summary": "Bir eğitimin durakları ve ders özetleri",
        "parameters": [{"$ref": "#/components/parameters/slug"}],
        "responses": {
          "200": {"description": "Eğitim", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Rota"}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "404": {"$ref": "#/components/responses/Bulunamadi"}
        }
      }
    },
    "/ders/{slug}": {
      "get": {
        "tags": ["Katalog"], "operationId": "ders", "summary": "Bir dersin içeriği (bloklar) ve ders sonu soruları",
        "description": "Dersi kendi arayüzünüzde göstermek isterseniz kullanın. `bloklar` dizisindeki her blok `t` (tür) alanı taşır: p, h, liste, adimlar, not, ornek, istem, karsilastir, tablo, vurgu, soru, etkilesim, ozet, odev, gorsel, ses, video. Metin alanlarında satır içi biçim vardır: `**kalın**`, `*italik*`, `` `kod` ``, `[[terim-slug]]` ya da `[[terim-slug|görünen metin]]`.",
        "parameters": [{"$ref": "#/components/parameters/slug"}],
        "responses": {
          "200": {"description": "Ders", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ders"}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "404": {"$ref": "#/components/responses/Bulunamadi"}
        }
      }
    },
    "/ogrenenler": {
      "get": {
        "tags": ["Öğrenenler"], "operationId": "ogrenenler", "summary": "Öğrenenlerin sayfalı listesi (sayfa başına 100)",
        "parameters": [{"name": "sayfa", "in": "query", "schema": {"type": "integer", "minimum": 1, "default": 1}}],
        "responses": {
          "200": {"description": "Liste", "content": {"application/json": {"schema": {"type": "object", "properties": {
            "sayfa": {"type": "integer"}, "sayfa_boyutu": {"type": "integer"}, "toplam": {"type": "integer"}, "sayfa_sayisi": {"type": "integer"},
            "ogrenenler": {"type": "array", "items": {"type": "object", "properties": {"dis_kimlik": {"type": "string"}, "ad": {"type": "string"}, "olusturma": {"type": "string", "format": "date-time"}, "son_gorulme": {"type": "string", "format": "date-time"}, "biten_ders": {"type": "integer"}, "belge": {"type": "integer"}}}}}}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}
        }
      }
    },
    "/ogrenen/{dis_kimlik}": {
      "parameters": [{"$ref": "#/components/parameters/dis_kimlik"}],
      "put": {
        "tags": ["Öğrenenler"], "operationId": "ogrenenYaz", "summary": "Öğreneni oluşturur ya da günceller",
        "requestBody": {"required": false, "content": {"application/json": {"schema": {"type": "object", "properties": {"ad": {"type": "string", "maxLength": 80, "description": "Belgede yazacak ad soyad (isteğe bağlı)"}}}}}},
        "responses": {
          "200": {"description": "Güncellendi", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ogrenen"}}}},
          "201": {"description": "Oluşturuldu", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ogrenen"}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "403": {"$ref": "#/components/responses/Yasak"},
          "409": {"description": "Koltuk sınırı doldu (`koltuk_dolu`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
          "422": {"$ref": "#/components/responses/Gecersiz"}
        }
      },
      "get": {
        "tags": ["Öğrenenler"], "operationId": "ogrenenOku", "summary": "Öğrenenin ilerlemesi, eğitim yüzdeleri ve belgeleri",
        "responses": {
          "200": {"description": "Öğrenen", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Ogrenen"}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "404": {"$ref": "#/components/responses/Bulunamadi"}
        }
      },
      "delete": {
        "tags": ["Öğrenenler"], "operationId": "ogrenenSil", "summary": "Öğreneni ilerlemesi ve belgeleriyle kalıcı siler",
        "responses": {
          "200": {"description": "Silindi", "content": {"application/json": {"schema": {"type": "object", "properties": {"silindi": {"type": "boolean"}, "dis_kimlik": {"type": "string"}}}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "403": {"$ref": "#/components/responses/Yasak"}, "404": {"$ref": "#/components/responses/Bulunamadi"}
        }
      }
    },
    "/ogrenen/{dis_kimlik}/ilerleme": {
      "post": {
        "tags": ["İlerleme ve belge"], "operationId": "ilerleme", "summary": "Bir dersi bitti olarak işaretler",
        "description": "Dersi kendi arayüzünüzde gösteriyorsanız kullanın (gömülü sayfalar ilerlemeyi kendisi yazar). İlk kez biten ders için `ders_bitti`, eğitimin bütün dersleri bittiyse `rota_bitti` webhook olayı kuyruğa girer.",
        "parameters": [{"$ref": "#/components/parameters/dis_kimlik"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["ders"], "properties": {"ders": {"type": "string", "description": "Ders slug'ı"}, "dogru": {"type": "integer", "minimum": 0, "description": "Ders sonu sorularında doğru sayısı"}, "toplam": {"type": "integer", "minimum": 0, "description": "Ders sonu soru sayısı"}}}}}},
        "responses": {
          "200": {"description": "Kaydedildi", "content": {"application/json": {"schema": {"type": "object", "properties": {"ders": {"type": "string"}, "bitti": {"type": "boolean"}, "yeni": {"type": "boolean", "description": "Ders ilk kez mi bitti"}, "biten_rotalar": {"type": "array", "items": {"type": "object", "properties": {"rota": {"type": "string"}, "ad": {"type": "string"}}}}}}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "403": {"$ref": "#/components/responses/Yasak"}, "404": {"$ref": "#/components/responses/Bulunamadi"}, "422": {"$ref": "#/components/responses/Gecersiz"}
        }
      }
    },
    "/ogrenen/{dis_kimlik}/belge": {
      "post": {
        "tags": ["İlerleme ve belge"], "operationId": "belge", "summary": "Eğitimi bitiren öğrenen için katılım belgesi üretir",
        "description": "Koşul: eğitim belge veriyor olmalı, öğrenen eğitimin bütün derslerini ve varsa ön koşul eğitimlerini bitirmiş olmalı. Belge daha önce üretildiyse aynısı döner (`yeni: false`). Belge `dogrulama` adresinden herkesçe doğrulanabilir; sayfada kurumunuzun adı görünür.",
        "parameters": [{"$ref": "#/components/parameters/dis_kimlik"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["rota"], "properties": {"rota": {"type": "string", "description": "Eğitim slug'ı"}, "ad": {"type": "string", "minLength": 3, "maxLength": 80, "description": "Belgede yazacak ad soyad (öğrenende kayıtlıysa boş bırakılabilir)"}}}}}},
        "responses": {
          "200": {"description": "Belge zaten vardı", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Belge"}}}},
          "201": {"description": "Belge üretildi", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Belge"}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "403": {"$ref": "#/components/responses/Yasak"}, "404": {"$ref": "#/components/responses/Bulunamadi"},
          "409": {"description": "Koşullar tamam değil (`kosul`) ya da eğitim belge vermiyor (`belge_yok`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
          "422": {"$ref": "#/components/responses/Gecersiz"}
        }
      }
    },
    "/gomme-belirteci": {
      "post": {
        "tags": ["Gömme"], "operationId": "gommeBelirteci", "summary": "Gömülü sayfa için 10 dakika geçerli belirteç üretir",
        "description": "Öğrenen yoksa oluşturulur. `rota` verilirse çerçeve doğrudan o eğitimi açar; verilmezse kurumunuza açık eğitimlerin listesini gösterir. Dönen `adres` değerini `<iframe src>` olarak kullanın. Çerçeve yalnız kurumunuzun izinli alan adlarındaki sayfalarda görüntülenir.",
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["dis_kimlik"], "properties": {"dis_kimlik": {"type": "string"}, "ad": {"type": "string", "maxLength": 80}, "rota": {"type": "string", "description": "Eğitim slug'ı (isteğe bağlı)"}}}}}},
        "responses": {
          "201": {"description": "Belirteç", "content": {"application/json": {"schema": {"type": "object", "properties": {"belirtec": {"type": "string"}, "son_kullanma": {"type": "string", "format": "date-time"}, "omur_sn": {"type": "integer"}, "adres": {"type": "string", "format": "uri"}}}}}},
          "401": {"$ref": "#/components/responses/Yetkisiz"}, "403": {"$ref": "#/components/responses/Yasak"}, "404": {"$ref": "#/components/responses/Bulunamadi"},
          "409": {"description": "Koltuk sınırı doldu (`koltuk_dolu`) ya da izinli alan adı tanımlı değil (`alan_adi_yok`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
          "422": {"$ref": "#/components/responses/Gecersiz"}
        }
      }
    }
  },
  "webhooks": {
    "ders_bitti": {"post": {"summary": "Öğrenen bir dersi ilk kez bitirdi", "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookZarfi"}, {"type": "object", "properties": {"veri": {"type": "object", "properties": {"dis_kimlik": {"type": "string"}, "ders": {"type": "string"}, "dogru": {"type": "integer"}, "toplam": {"type": "integer"}}}}}]}}}}, "responses": {"200": {"description": "2xx yanıt teslimatı tamamlar"}}}},
    "rota_bitti": {"post": {"summary": "Öğrenen bir eğitimin bütün derslerini bitirdi", "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookZarfi"}, {"type": "object", "properties": {"veri": {"type": "object", "properties": {"dis_kimlik": {"type": "string"}, "rota": {"type": "string"}}}}}]}}}}, "responses": {"200": {"description": "2xx yanıt teslimatı tamamlar"}}}},
    "belge_verildi": {"post": {"summary": "Öğrenene katılım belgesi verildi", "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookZarfi"}, {"type": "object", "properties": {"veri": {"type": "object", "properties": {"dis_kimlik": {"type": "string"}, "rota": {"type": "string"}, "kod": {"type": "string"}, "ad": {"type": "string"}, "dogrulama": {"type": "string", "format": "uri"}}}}}]}}}}, "responses": {"200": {"description": "2xx yanıt teslimatı tamamlar"}}}}
  },
  "components": {
    "securitySchemes": {
      "anahtar": {"type": "http", "scheme": "bearer", "description": "Kurum API anahtarı: yze_live_ ile başlar."}
    },
    "parameters": {
      "slug": {"name": "slug", "in": "path", "required": true, "schema": {"type": "string", "pattern": "^[a-z0-9-]+$"}},
      "dis_kimlik": {"name": "dis_kimlik", "in": "path", "required": true, "description": "Sizin sisteminizdeki kullanıcı kimliği", "schema": {"type": "string", "pattern": "^[A-Za-z0-9._@:+-]{1,120}$"}}
    },
    "responses": {
      "Yetkisiz": {"description": "Anahtar yok (`anahtar_yok`) ya da geçersiz (`anahtar_gecersiz`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
      "Yasak": {"description": "Anahtar yalnız okuma yetkili (`yetki`) ya da kurum hesabı askıda (`askida`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
      "Bulunamadi": {"description": "Kayıt yok ya da kurumunuza açık değil (`rota_yok`, `ders_yok`, `ogrenen_yok`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
      "Gecersiz": {"description": "Girdi geçersiz (hata kodu alan adıdır: `dis_kimlik`, `ad`, `dogru`, `toplam`)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}},
      "HizSiniri": {"description": "Dakikalık istek sınırı aşıldı (`hiz`)", "headers": {"Retry-After": {"schema": {"type": "integer"}}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Hata"}}}}
    },
    "schemas": {
      "Hata": {"type": "object", "required": ["hata", "ileti"], "properties": {"hata": {"type": "string", "description": "Makine-okur hata kodu"}, "ileti": {"type": "string", "description": "Türkçe açıklama"}}},
      "RotaOzeti": {"type": "object", "properties": {
        "slug": {"type": "string"}, "tur": {"type": "string", "enum": ["seviye", "meslek", "kurum"]}, "ad": {"type": "string"}, "ozet": {"type": "string"},
        "ders_sayi": {"type": "integer"}, "sure_dk": {"type": "integer", "description": "Toplam okuma süresi (dakika)"}, "kapak": {"type": ["string", "null"], "format": "uri"},
        "belge": {"type": "boolean", "description": "Bitirince katılım belgesi verilir mi"}, "adres": {"type": "string", "format": "uri"}}},
      "DersOzeti": {"type": "object", "properties": {"slug": {"type": "string"}, "baslik": {"type": "string"}, "ozet": {"type": "string"}, "seviye": {"type": "integer", "enum": [1, 2, 3]}, "sure_dk": {"type": "integer"}, "konu": {"type": "string"}, "konu_ad": {"type": "string"}}},
      "Rota": {"allOf": [{"$ref": "#/components/schemas/RotaOzeti"}, {"type": "object", "properties": {
        "aciklama": {"type": "string"}, "kitle": {"type": "string"}, "kazanimlar": {"type": "array", "items": {"type": "string"}}, "on_kosul": {"type": "array", "items": {"type": "string"}, "description": "Önce bitirilmesi gereken eğitim slug'ları"},
        "duraklar": {"type": "array", "items": {"type": "object", "properties": {"bolum": {"type": "string"}, "dersler": {"type": "array", "items": {"$ref": "#/components/schemas/DersOzeti"}}}}}}}]},
      "Soru": {"type": "object", "properties": {"s": {"type": "string", "description": "Soru"}, "sec": {"type": "array", "items": {"type": "string"}, "description": "Seçenekler"}, "d": {"type": "integer", "description": "Doğru seçeneğin sırası (0 tabanlı)"}, "a": {"type": "string", "description": "Açıklama"}}},
      "Ders": {"allOf": [{"$ref": "#/components/schemas/DersOzeti"}, {"type": "object", "properties": {
        "bloklar": {"type": "array", "items": {"type": "object", "required": ["t"], "properties": {"t": {"type": "string"}}, "additionalProperties": true}},
        "terimler": {"type": "array", "items": {"type": "object", "properties": {"slug": {"type": "string"}, "ad": {"type": "string"}, "ingilizce": {"type": "string"}, "kisa": {"type": "string"}}}},
        "sorular": {"type": "array", "items": {"$ref": "#/components/schemas/Soru"}},
        "ses": {"type": ["string", "null"], "format": "uri", "description": "Seslendirme dosyası (varsa)"}, "guncelleme": {"type": "string", "format": "date-time"}}}]},
      "Ogrenen": {"type": "object", "properties": {
        "dis_kimlik": {"type": "string"}, "ad": {"type": "string"}, "olusturma": {"type": "string", "format": "date-time"}, "son_gorulme": {"type": "string", "format": "date-time"}, "biten_ders": {"type": "integer"},
        "dersler": {"type": "array", "items": {"type": "object", "properties": {"ders": {"type": "string"}, "bitti": {"type": "boolean"}, "dogru": {"type": "integer"}, "toplam": {"type": "integer"}, "ilk": {"type": "string", "format": "date-time"}, "son": {"type": "string", "format": "date-time"}}}},
        "rotalar": {"type": "array", "items": {"type": "object", "properties": {"rota": {"type": "string"}, "ad": {"type": "string"}, "biten": {"type": "integer"}, "toplam": {"type": "integer"}, "yuzde": {"type": "integer"}, "tamam": {"type": "boolean"}}}},
        "belgeler": {"type": "array", "items": {"type": "object", "properties": {"rota": {"type": "string"}, "rota_ad": {"type": "string"}, "kod": {"type": "string"}, "ad": {"type": "string"}, "zaman": {"type": "string", "format": "date-time"}, "dogrulama": {"type": "string", "format": "uri"}}}}}},
      "Belge": {"type": "object", "properties": {"kod": {"type": "string", "examples": ["YZE-7K3M-9QX2"]}, "ad": {"type": "string"}, "rota": {"type": "string"}, "rota_ad": {"type": "string"}, "zaman": {"type": "string", "format": "date-time"}, "dogrulama": {"type": "string", "format": "uri"}, "yeni": {"type": "boolean"}}},
      "WebhookZarfi": {"type": "object", "properties": {"id": {"type": "integer", "description": "Teslimat numarası (yeniden denemelerde aynı kalır)"}, "olay": {"type": "string", "enum": ["ders_bitti", "rota_bitti", "belge_verildi", "deneme"]}, "zaman": {"type": "string", "format": "date-time"}, "veri": {"type": "object"}}}
    }
  }
}
