{
  "openapi": "3.1.0",
  "info": {
    "title": "w-b free subdomain API",
    "description": "Открытый API выдачи бесплатных субдоменов вида name.lylymbi.dpdns.org. Без ключей и регистрации. Для ИИ-агентов, автоматизации и демо-сайтов. Зона не для фишинга и спама; записи с нарушением удаляются.",
    "version": "1.0.0"
  },
  "servers": [{ "url": "https://w-b.pages.dev" }],
  "paths": {
    "/api/claim": {
      "get": {
        "summary": "Информация о сервисе",
        "operationId": "serviceInfo",
        "responses": {
          "200": {
            "description": "Метаданные сервиса, эндпоинты, лимиты",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      },
      "post": {
        "summary": "Выдать поддомен",
        "operationId": "claim",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "target"],
                "properties": {
                  "name": {
                    "type": "string",
                    "pattern": "^[a-z0-9]([a-z0-9-]{0,29}[a-z0-9])?$",
                    "description": "1-31 символ: a-z, 0-9, дефисы; без дефиса по краям"
                  },
                  "target": {
                    "type": "string",
                    "description": "CNAME-цель, живой хостнейм (резолвится в DNS)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Поддомен выдан",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "domain": { "type": "string" },
                    "target": { "type": "string" },
                    "release_token": { "type": "string", "description": "Токен освобождения имени" },
                    "note": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "description": "Некорректное имя или цель не резолвится" },
          "409": { "description": "Имя занято" },
          "429": { "description": "Рейт-лимит: 5 заявок / 10 минут / IP" },
          "503": { "description": "Лимит записей зоны (50) достигнут" }
        }
      }
    },
    "/api/check": {
      "get": {
        "summary": "Свободно ли имя",
        "operationId": "check",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Статус имени",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "name": { "type": "string" },
                    "domain": { "type": "string" },
                    "available": { "type": "boolean" },
                    "reason": { "type": ["string", "null"] }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/release": {
      "post": {
        "summary": "Освободить поддомен",
        "operationId": "release",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["domain", "release_token"],
                "properties": {
                  "domain": { "type": "string", "description": "name.lylymbi.dpdns.org" },
                  "release_token": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Запись удалена" },
          "403": { "description": "Неверный токен" },
          "404": { "description": "Запись не найдена" }
        }
      }
    },
    "/api/records": {
      "get": {
        "summary": "Реестр выданных поддоменов",
        "operationId": "records",
        "responses": {
          "200": {
            "description": "Список выданных CNAME-записей",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    }
  }
}
