{
  "openapi": "3.1.0",
  "info": {
    "title": "Chamgap Mail API",
    "version": "1.0.0",
    "description": "참값 contact 사서함 서버 간 API. Zoho 토큰은 서버에만 저장됩니다. 키별 초안 격리. 월/일은 KST; Zoho 실제 잔여량은 동적 한도로 null."
  },
  "servers": [
    {
      "url": "https://admin.chamgap.com/mail/v1"
    }
  ],
  "security": [
    {
      "serviceKey": []
    }
  ],
  "paths": {
    "/info": {
      "get": {
        "operationId": "get_info",
        "summary": "연결 정보와 기능",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/account": {
      "get": {
        "operationId": "get_account",
        "summary": "계정 차단·저장공간 상태",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/folders": {
      "get": {
        "operationId": "get_folders",
        "summary": "메일함 목록",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/usage": {
      "get": {
        "operationId": "get_usage",
        "summary": "월·일·최근 1시간 발송 통계와 자체 상한 잔여량",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/messages": {
      "get": {
        "operationId": "get_messages",
        "summary": "폴더의 메일 목록",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 30
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "read",
                "unread"
              ],
              "default": "all"
            }
          }
        ]
      }
    },
    "/search": {
      "get": {
        "operationId": "get_search",
        "summary": "메일 전체 검색",
        "description": "한 페이지 30건. 다음 페이지도 같은 q와 at 값을 사용합니다.",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "최대 200자. 따옴표·콜론·역슬래시 제외"
          },
          {
            "name": "at",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "검색 시작시 고정한 Unix epoch 밀리초"
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            }
          }
        ]
      }
    },
    "/messages/{messageId}/content": {
      "get": {
        "operationId": "get_messages_messageId_content",
        "summary": "본문과 이전 대화",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          }
        ]
      }
    },
    "/messages/{messageId}/details": {
      "get": {
        "operationId": "get_messages_messageId_details",
        "summary": "수신자·참조 등 상세",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          }
        ]
      }
    },
    "/messages/{messageId}/header": {
      "get": {
        "operationId": "get_messages_messageId_header",
        "summary": "원본 인증·발송 경로 헤더",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          }
        ]
      }
    },
    "/messages/{messageId}/attachmentinfo": {
      "get": {
        "operationId": "get_messages_messageId_attachmentinfo",
        "summary": "첨부 목록",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          }
        ]
      }
    },
    "/messages/{messageId}/original": {
      "get": {
        "operationId": "get_messages_messageId_original",
        "summary": "MIME 원본 EML 다운로드",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "message/rfc822": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          }
        ]
      }
    },
    "/messages/{messageId}/attachments/{attachmentId}": {
      "get": {
        "operationId": "get_messages_messageId_attachments_attachmentId",
        "summary": "첨부 다운로드",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,30}$",
              "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/message-state": {
      "post": {
        "operationId": "post_message-state",
        "summary": "읽음·안읽음·이동·중요표시·스팸·보관",
        "description": "trash/restore/move에는 folderId, move에는 destinationFolderId, flag에는 flag가 필요합니다. 영구삭제·조직관리·폴더 생성/삭제는 이 API에 포함하지 않습니다.",
        "x-required-scopes": [
          "mail.write"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StateChange"
              }
            }
          }
        }
      }
    },
    "/drafts": {
      "get": {
        "operationId": "get_drafts",
        "summary": "이 연결의 초안 목록",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/drafts/{draftId}": {
      "get": {
        "operationId": "get_drafts_draftId",
        "summary": "초안 상세·발송 상태",
        "description": "",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftRecord"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "draftId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
              "description": "소문자 UUID를 사용합니다."
            }
          }
        ]
      },
      "put": {
        "operationId": "put_drafts_draftId",
        "summary": "초안 생성·수정",
        "description": "새 초안은 revision=0, 수정은 현재 revision. 저장할 때마다 새 operationId를 만들고, 응답 유실 재시도에는 같은 operationId와 본문을 사용합니다. 서비스별 초안은 격리됩니다.",
        "x-required-scopes": [
          "mail.write"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftRecord"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "draftId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
              "description": "소문자 UUID를 사용합니다."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftWrite"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_drafts_draftId",
        "summary": "미발송 초안 삭제",
        "description": "",
        "x-required-scopes": [
          "mail.write"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "draftId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
              "description": "소문자 UUID를 사용합니다."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer"
                  }
                },
                "required": [
                  "revision"
                ]
              }
            }
          }
        }
      }
    },
    "/upload": {
      "post": {
        "operationId": "post_upload",
        "summary": "발송용 첨부 업로드",
        "description": "첨부 합계 10MB, 최대10개. 업로드 ID는 같은 서비스 키에서만 1시간 유효합니다.",
        "x-required-scopes": [
          "mail.send"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "size"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "attach": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "attach"
                ]
              }
            }
          }
        }
      }
    },
    "/send": {
      "post": {
        "operationId": "post_send",
        "summary": "저장한 초안 발송·답장",
        "description": "고정 발신자 Chamgap <contact@chamgap.com>. To+Cc+Bcc 합계 최대30명. 먼저 같은 키로 초안을 저장하세요. 답장은 data.replyToMessage에 원본 ID를 넣고 to/cc를 명시합니다. timeout/unknown 때 새 키·새 초안을 만들어 재발송하지 말고 기존 초안/보낸함을 확인하세요.",
        "x-required-scopes": [
          "mail.send"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendResult"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
              "description": "소문자 UUID를 사용합니다."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Send"
              }
            }
          }
        }
      }
    },
    "/operations/{idempotencyKey}": {
      "get": {
        "operationId": "get_operations_idempotencyKey",
        "summary": "이 키의 최근 발송 요청 상태",
        "description": "최소 최근24시간의 요청. 조회 기간이 지나도 초안의 sent/unknown 잠금은 보존됩니다. 404는 미발송 입증이 아닙니다.",
        "x-required-scopes": [
          "mail.read"
        ],
        "responses": {
          "200": {
            "description": "성공. 발신 성공은 Zoho 접수이며 상대 도착 확인과 다릅니다.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "잘못된 입력",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API 키 인증 실패 또는 Zoho 인증 갱신 실패. code를 확인하세요.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "권한 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "리소스 없음",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "충돌 또는 결과 미확인",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "요청/자체 발송 상한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Zoho 처리 결과 확인 실패",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Zoho 재연결 필요",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "idempotencyKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
              "description": "소문자 UUID를 사용합니다."
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "serviceKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "cgm_<64 hex characters>",
        "description": "관리자 API 연결 화면에서 발급. URL/프런트엔드에 넣지 않습니다."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "code"
        ]
      },
      "Attachment": {
        "type": "object",
        "properties": {
          "slot": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
            "description": "소문자 UUID를 사용합니다."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10485760
          }
        },
        "required": [
          "slot",
          "name",
          "size"
        ]
      },
      "DraftData": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "maxLength": 3000
          },
          "cc": {
            "type": "string",
            "maxLength": 3000
          },
          "bcc": {
            "type": "string",
            "maxLength": 3000
          },
          "subject": {
            "type": "string",
            "maxLength": 500
          },
          "content": {
            "type": "string",
            "maxLength": 200000
          },
          "replyToMessage": {
            "type": [
              "string",
              "null"
            ],
            "description": "답장할 때 원본 messageId, 새 메일은 null"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "maxItems": 10
          }
        },
        "required": [
          "to",
          "cc",
          "bcc",
          "subject",
          "content",
          "replyToMessage",
          "attachments"
        ]
      },
      "DraftWrite": {
        "type": "object",
        "properties": {
          "operationId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
            "description": "소문자 UUID를 사용합니다."
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "data": {
            "$ref": "#/components/schemas/DraftData"
          }
        },
        "required": [
          "operationId",
          "revision",
          "data"
        ]
      },
      "DraftRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
            "description": "소문자 UUID를 사용합니다."
          },
          "revision": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "sending",
              "sent",
              "unknown"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/DraftData"
          },
          "updated": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "revision",
          "status"
        ]
      },
      "Send": {
        "type": "object",
        "properties": {
          "draftId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
            "description": "소문자 UUID를 사용합니다."
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "slot": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
                  "description": "소문자 UUID를 사용합니다."
                },
                "id": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "slot",
                "id"
              ]
            }
          }
        },
        "required": [
          "draftId",
          "revision",
          "attachments"
        ]
      },
      "SendResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "messageId": {
            "type": "string"
          },
          "accepted": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ]
      },
      "StateChange": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "read",
              "unread",
              "trash",
              "restore",
              "move",
              "flag",
              "spam",
              "notSpam",
              "archive",
              "unarchive"
            ]
          },
          "messageId": {
            "type": "string",
            "pattern": "^[0-9]{1,30}$",
            "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
          },
          "folderId": {
            "type": "string",
            "pattern": "^[0-9]{1,30}$",
            "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
          },
          "destinationFolderId": {
            "type": "string",
            "pattern": "^[0-9]{1,30}$",
            "description": "64비트 식별자를 손실 없이 문자열로 전달합니다."
          },
          "flag": {
            "type": "string",
            "enum": [
              "important",
              "info",
              "followup",
              "flag_not_set"
            ]
          }
        },
        "required": [
          "action",
          "messageId"
        ]
      },
      "Usage": {
        "type": "object",
        "properties": {
          "timezone": {
            "type": "string"
          },
          "periodStart": {
            "type": "integer"
          },
          "recorded": {
            "type": "object",
            "properties": {
              "monthSent": {
                "type": "integer"
              },
              "todaySent": {
                "type": "integer"
              },
              "hourSent": {
                "type": "integer"
              },
              "monthUncertain": {
                "type": "integer"
              },
              "firstRecordedAt": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "ownBudget": {
            "type": "object",
            "properties": {
              "monthlyLimit": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "remaining": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "includesUncertain": {
                "type": "boolean"
              }
            }
          },
          "provider": {
            "type": "object",
            "properties": {
              "monthlyLimit": {
                "type": "null"
              },
              "remaining": {
                "type": "null"
              },
              "dynamic": {
                "type": "boolean"
              },
              "source": {
                "type": "string"
              }
            }
          },
          "coverage": {
            "type": "string"
          }
        }
      }
    }
  }
}
