{
  "openapi": "3.1.0",
  "info": {
    "title": "Pukae Independent API",
    "version": "0.1.0",
    "description": "뿌까에 자체 회원·번역·운영 API. 기본 서버는 현재 웹 서비스와 같은 origin입니다. 회원 세션은 30일, 번역 API 키는 폐기 전까지 유효합니다. 브라우저 쿠키를 사용하는 변경 요청에는 X-Pukae-CSRF: 1 헤더가 필요합니다. LastAI 최고 관리자는 별도 가입 없이 일회용 SSO를 거쳐 관리자 전용 쿠키로 운영 API를 사용합니다. 일반 회원 API와 분리됩니다."
  },
  "servers": [
    {
      "url": "/",
      "description": "Current Pukae server"
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    },
    {
      "name": "Translation"
    },
    {
      "name": "Account"
    },
    {
      "name": "Administration"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "summary": "서버 상태",
        "tags": [
          "Authentication"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        }
      }
    },
    "/api/v1/config": {
      "get": {
        "summary": "공개 운영 설정",
        "tags": [
          "Authentication"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        }
      }
    },
    "/api/v1/auth/register": {
      "post": {
        "summary": "독립 회원가입",
        "tags": [
          "Authentication"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 10,
                    "description": "10자 이상, UTF-8 128바이트 이하"
                  }
                },
                "required": [
                  "name",
                  "email",
                  "password"
                ]
              }
            }
          }
        },
        "description": "운영 Supabase 모드는 verification_required=true와 안내 메시지를 반환하며 메일 확인 후 로그인합니다. 로컬 SQLite 모드만 user/token을 즉시 반환합니다."
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "summary": "회원 로그인 및 세션 발급",
        "tags": [
          "Authentication"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "description": "10자 이상, UTF-8 128바이트 이하"
                  }
                },
                "required": [
                  "email",
                  "password"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "summary": "현재 세션 종료",
        "tags": [
          "Authentication"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ]
      }
    },
    "/api/v1/me": {
      "get": {
        "summary": "내 회원 정보",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ]
      },
      "patch": {
        "summary": "이름 변경",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete own Pukae account after password verification",
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "current_password"
                ],
                "properties": {
                  "current_password": {
                    "type": "string",
                    "maxLength": 128
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account deleted and session cookie cleared"
          },
          "401": {
            "description": "Invalid session or password"
          },
          "409": {
            "description": "Administrator must transfer or remove admin role first"
          }
        }
      }
    },
    "/api/v1/auth/password": {
      "post": {
        "summary": "비밀번호 변경 후 세션 종료",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current_password": {
                    "type": "string"
                  },
                  "new_password": {
                    "type": "string",
                    "minLength": 10,
                    "description": "10자 이상, UTF-8 128바이트 이하"
                  }
                },
                "required": [
                  "current_password",
                  "new_password"
                ]
              }
            }
          }
        },
        "description": "현재 비밀번호를 확인하고 새 비밀번호를 저장합니다. 기존 세션과 API 키를 모두 폐기하므로 다시 로그인해야 합니다."
      }
    },
    "/api/v1/translate": {
      "post": {
        "summary": "텍스트 번역",
        "tags": [
          "Translation"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "translation": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "ko",
                        "km",
                        "en"
                      ]
                    },
                    "target": {
                      "type": "string",
                      "enum": [
                        "ko",
                        "km",
                        "en"
                      ]
                    },
                    "mode": {
                      "type": "string",
                      "enum": [
                        "demo",
                        "live"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "translation",
                    "source",
                    "target",
                    "mode"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          },
          "503": {
            "description": "예문 모드에서 지원하지 않는 문장. 사용 한도 복구."
          },
          "502": {
            "description": "번역 공급자 실패. 사용 한도 복구."
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "ko",
                      "km",
                      "en"
                    ]
                  },
                  "target": {
                    "type": "string",
                    "enum": [
                      "ko",
                      "km",
                      "en"
                    ]
                  }
                },
                "required": [
                  "text",
                  "source",
                  "target"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/history": {
      "get": {
        "summary": "내 번역 기록",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ]
      }
    },
    "/api/v1/history/{id}": {
      "patch": {
        "summary": "번역 기록 즐겨찾기",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "favorite": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "favorite"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "summary": "내 번역 기록 삭제",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/keys": {
      "get": {
        "summary": "내 API 키 목록",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ]
      },
      "post": {
        "summary": "번역 전용 API 키 발급",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "translate"
                    ]
                  }
                },
                "required": [
                  "name",
                  "scope"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{id}": {
      "delete": {
        "summary": "내 API 키 폐기",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/progress": {
      "get": {
        "summary": "학습 완료 목록",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ]
      }
    },
    "/api/v1/progress/{unit_id}": {
      "put": {
        "summary": "학습 단원 완료 저장",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          }
        ],
        "parameters": [
          {
            "name": "unit_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "table",
                "town",
                "friends",
                "day",
                "discover"
              ]
            }
          }
        ]
      }
    },
    "/api/v1/admin/overview": {
      "get": {
        "summary": "운영 현황",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ]
      }
    },
    "/api/v1/me/mobile-visit": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "로그인한 회원의 최근 모바일 접속 기록",
        "security": [
          {
            "BearerSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "platform",
                  "version"
                ],
                "properties": {
                  "platform": {
                    "type": "string",
                    "enum": [
                      "ios",
                      "android"
                    ]
                  },
                  "version": {
                    "type": "string",
                    "maxLength": 32,
                    "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "서버 접속 시각과 앱 정보를 저장했습니다."
          },
          "400": {
            "description": "잘못된 플랫폼 또는 버전"
          },
          "401": {
            "description": "회원 세션이 필요합니다."
          }
        }
      }
    },
    "/api/v1/admin/members": {
      "get": {
        "summary": "회원 목록",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ]
      }
    },
    "/api/v1/admin/audit": {
      "get": {
        "summary": "관리자 감사 기록",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ]
      }
    },
    "/api/v1/admin/settings": {
      "get": {
        "summary": "운영 설정",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ]
      },
      "put": {
        "summary": "회원가입·기본 한도·공지 설정",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "registration_enabled": {
                    "type": "boolean"
                  },
                  "default_quota": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "notice": {
                    "type": "string"
                  }
                },
                "required": [
                  "registration_enabled",
                  "default_quota",
                  "notice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/keys": {
      "get": {
        "summary": "전체 API 키 목록",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ]
      }
    },
    "/api/v1/admin/members/{id}": {
      "patch": {
        "summary": "회원 권한·상태·이용 한도 변경",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "member",
                      "admin"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "suspended"
                    ]
                  },
                  "quota": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": []
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/keys/{id}": {
      "delete": {
        "summary": "관리자 API 키 폐기",
        "tags": [
          "Administration"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Insufficient permission"
          },
          "429": {
            "description": "Rate limit or quota exceeded"
          }
        },
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/admin/usage": {
      "get": {
        "summary": "최근 500건 사용 내역",
        "tags": [
          "Administration"
        ],
        "security": [
          {
            "BearerSession": []
          },
          {
            "CookieSession": []
          },
          {
            "OperatorSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "items 배열. 회원 이름/이메일/언어/문자수/모드/UTC시각 포함; 번역 원문은 포함하지 않음."
          },
          "403": {
            "description": "관리자 권한 필요"
          }
        }
      }
    },
    "/api/v1/auth/resend": {
      "post": {
        "summary": "인증 메일 재전송 (운영 모드)",
        "tags": [
          "Authentication"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "계정 존재 여부를 드러내지 않는 안내 메시지"
          },
          "429": {
            "description": "요청 빈도 초과"
          }
        }
      }
    },
    "/api/v1/admin/login/start": {
      "get": {
        "tags": [
          "Administration"
        ],
        "summary": "LastAI 최고 관리자 로그인 시작",
        "description": "운영 Supabase 모드 전용. 브라우저에 5분짜리 흐름 쿠키를 설정하고 고정된 LastAI 인증 경로로 이동합니다.",
        "responses": {
          "303": {
            "description": "LastAI 로그인 또는 기존 로그인 확인으로 이동"
          }
        }
      }
    },
    "/admin/callback": {
      "get": {
        "tags": [
          "Administration"
        ],
        "summary": "LastAI 관리자 일회용 코드 소비",
        "description": "운영 Supabase 모드 전용. 코드와 브라우저 흐름 쿠키를 함께 확인합니다. 토큰은 응답 JSON에 노출하지 않습니다.",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          }
        ],
        "responses": {
          "303": {
            "description": "성공 시 관리자 전용 쿠키를 설정하고 /admin으로 이동. 실패 시 안전한 오류 안내로 이동"
          }
        }
      }
    },
    "/api/v1/admin/session": {
      "get": {
        "tags": [
          "Administration"
        ],
        "summary": "현재 운영 관리자 확인",
        "security": [
          {
            "OperatorSession": []
          },
          {
            "CookieSession": []
          },
          {
            "BearerSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "관리자 출처를 포함한 신원",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "user"
                  ],
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/AdminIdentity"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "로그인 필요 또는 만료된 관리자 세션"
          },
          "403": {
            "description": "관리자 권한 없음"
          }
        }
      }
    },
    "/api/v1/admin/logout": {
      "post": {
        "tags": [
          "Administration"
        ],
        "summary": "LastAI 관리자 연결만 로그아웃",
        "description": "운영 Supabase 모드 전용. 해당 관리자 세션만 폐기하며 일반 뿌까에 회원 쿠키와 원래 LastAI 로그인은 유지합니다. 쿠키 요청에는 X-Pukae-CSRF: 1이 필요합니다.",
        "security": [
          {
            "OperatorSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "관리자 세션 폐기 및 쿠키 제거"
          },
          "403": {
            "description": "Origin 또는 CSRF 검사 실패"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "로그인 응답 token 또는 번역 전용 API 키. API 키는 translate에서만 허용됩니다."
      },
      "CookieSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "pukae_session"
      },
      "OperatorSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "pukae_operator_session",
        "description": "LastAI 최고 관리자 SSO로 발급한 관리자 전용 세션. 최대 8시간이며 원래 LastAI 세션·최고 관리자 권한·인증 상태를 매 요청 재확인합니다. 회원 API에는 사용할 수 없습니다."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": [
              "member",
              "admin"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "quota": {
            "type": "integer"
          },
          "used": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          }
        }
      },
      "AdminIdentity": {
        "type": "object",
        "required": [
          "id",
          "name",
          "email",
          "role",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "const": "admin"
          },
          "source": {
            "type": "string",
            "enum": [
              "pukae",
              "lastai"
            ]
          }
        }
      }
    }
  }
}
