{
  "openapi": "3.1.0",
  "info": {
    "title": "Serçe Bot API",
    "version": "1.0.0",
    "description": "SDK 0.5.1 ile uyumlu HTTP API. Kanal/kurulum izinleri sunucuda denetlenir."
  },
  "servers": [
    {
      "url": "https://xn--sere-2oa.com/api/bot/v1"
    }
  ],
  "security": [
    {
      "botToken": []
    }
  ],
  "components": {
    "securitySchemes": {
      "botToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Serçe Geliştirici panelinden serce_bot_ ile başlayan token."
      }
    }
  },
  "paths": {
    "/messages": {
      "post": {
        "summary": "Mesaj gönder",
        "operationId": "sendMessage",
        "description": "Kanal görüntüleme + mesaj gönderme; toplu etiket için ayrıca etiket izni.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "message_id": 42
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "content": {
                    "type": "string"
                  },
                  "mentions_everyone": {
                    "type": "boolean"
                  },
                  "mentions_here": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "channel_id",
                  "content"
                ]
              }
            }
          }
        }
      }
    },
    "/channels/{id}/messages": {
      "get": {
        "summary": "Mesajları oku",
        "operationId": "listMessages",
        "description": "Kanal görüntüleme. after hariç alt sınır; limit 1–100. Sonuç artan kimlik sırasındadır.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "example": [
                  {
                    "id": 42,
                    "author_id": "uuid",
                    "content": "Merhaba",
                    "created_at": "2026-11-05T10:00:00Z"
                  }
                ]
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      }
    },
    "/channels/{id}/cursor": {
      "get": {
        "summary": "Son mesaj kimliği",
        "operationId": "messageCursor",
        "description": "Kanal görüntüleme. Boş kanalda cursor 0; eski komutları atlamak için kullan.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "cursor": "42"
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      }
    },
    "/messages/{id}": {
      "delete": {
        "summary": "Mesaj sil",
        "operationId": "deleteMessage",
        "description": "Kanal görüntüleme + mesaj yönetme.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      }
    },
    "/servers/{id}/channels": {
      "get": {
        "summary": "Kanalları listele",
        "operationId": "listChannels",
        "description": "Kurulum ve kanal görüntüleme izinleri.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "example": [
                  {
                    "id": "uuid",
                    "name": "genel",
                    "type": "text",
                    "position": 0
                  }
                ]
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      },
      "post": {
        "summary": "Metin veya ses odası oluştur",
        "operationId": "createRoom",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "key",
                  "name",
                  "type"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "enum": [
                      "text",
                      "voice"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "channel_id; aynı key için aynı oda"
          },
          "400": {
            "description": "Yetki, kota veya alan hatası"
          }
        }
      }
    },
    "/servers/{id}/members": {
      "get": {
        "summary": "Onaylı üyeleri listele",
        "operationId": "listMembers",
        "description": "Kurulu bot ve kanal görüntüleme izni gerekir. Yalnız bu bota kişisel veri izni veren, sunucuda bulunan ve yasaklı olmayan üyeler döner. E-posta veya özel profil verisi içermez. after UUID cursor; limit 1–100. Her sayfa güncel izinlerle filtrelenir.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "members": [
                    {
                      "id": "uuid",
                      "username": "kaan",
                      "displayName": "Kaan"
                    }
                  ],
                  "nextAfter": null
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      }
    },
    "/servers/{id}/invites": {
      "post": {
        "summary": "Davet oluştur",
        "operationId": "createInvite",
        "description": "Davet oluşturma.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "code": "example"
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "max_uses": {
                    "type": "integer"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": []
              }
            }
          }
        }
      }
    },
    "/servers/{id}/kick": {
      "post": {
        "summary": "Üyeyi çıkar",
        "operationId": "kickMember",
        "description": "Üye atma. Komutu çağıran kişinin yetkisini botun ayrıca kontrol etmeli.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "user_id"
                ]
              }
            }
          }
        }
      }
    },
    "/servers/{id}/ban": {
      "post": {
        "summary": "Üyeyi yasakla",
        "operationId": "banMember",
        "description": "Üye yasaklama. Komutu çağıran kişinin yetkisini botun ayrıca kontrol etmeli.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_id"
                ]
              }
            }
          }
        }
      }
    },
    "/servers/{id}/events": {
      "post": {
        "summary": "Etkinlik oluştur",
        "operationId": "createEvent",
        "description": "Etkinlik yönetme; başlangıç gelecekte olmalı.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "event_id": 14
                }
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "starts_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "ends_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": [
                  "title",
                  "starts_at"
                ]
              }
            }
          }
        }
      }
    },
    "/servers/{id}/audit-log": {
      "get": {
        "summary": "Denetim günlüğü",
        "operationId": "listAuditLog",
        "description": "Denetim günlüğünü görüntüleme. limit en fazla 100.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "example": []
              }
            }
          },
          "400": {
            "description": "İş kuralı, kurulum veya kanal izni hatası"
          },
          "401": {
            "description": "Geçersiz/eksik token başlığı"
          },
          "429": {
            "description": "İstek sınırı",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Beklenecek saniye"
              }
            }
          }
        }
      }
    },
    "/extensions": {
      "post": {
        "summary": "Bot için eklenti sürümü yayımla",
        "operationId": "registerExtension",
        "description": "Bot tokenının sahibine ait değişmez bir sürüm oluşturur. Kurulum sunucu sahibinin onayını gerektirir.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "html",
                  "position",
                  "width",
                  "height",
                  "shared"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "html": {
                    "type": "string"
                  },
                  "width": {
                    "type": "integer"
                  },
                  "height": {
                    "type": "integer"
                  },
                  "position": {
                    "type": "string"
                  },
                  "shared": {
                    "type": "boolean"
                  },
                  "events": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Yeni eklenti kimliği"
          },
          "400": {
            "description": "Token, kota veya manifest hatası"
          },
          "413": {
            "description": "100 KB sınırı aşıldı"
          },
          "429": {
            "description": "İstek sınırı"
          }
        }
      }
    },
    "/events": {
      "get": {
        "summary": "Botun izinli sunucularından olayları oku",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "events ve cursor; after yoksa başlangıç cursor değeri"
          }
        }
      }
    },
    "/interactions": {
      "get": {
        "summary": "Botun bekleyen etkileşimlerini al",
        "responses": {
          "200": {
            "description": "30 saniyelik teslim süresiyle en fazla 10 işlem"
          }
        }
      },
      "post": {
        "summary": "Etkileşime idempotent yanıt ver",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id",
                  "result"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "result": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Yanıt kaydedildi"
          },
          "400": {
            "description": "Erişim, süre veya farklı tekrar yanıtı"
          }
        }
      }
    },
    "/installations": {
      "get": {
        "summary": "Botun etkin kurulumlarını listele",
        "responses": {
          "200": {
            "description": "Kurulum kimliği, sunucu, izinler ve kurulum zamanı"
          }
        }
      }
    },
    "/servers/{serverId}/roles": {
      "post": {
        "summary": "Botun kendi yetkisiz rolünü oluştur, düzenle veya ata",
        "parameters": [
          {
            "name": "serverId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "role_id"
          },
          "400": {
            "description": "İzin yok veya rol korunuyor"
          }
        }
      }
    }
  }
}
