{
  "openapi": "3.1.0",
  "info": {
    "title": "公众号管理平台 Open API",
    "description": "公众号管理平台开放接口文档。通过 API Token 进行身份认证，支持公众号管理、样式配置、草稿发布、后台文章同步、流量主收益查询、Agent Context、CLI 和远程 HTTP MCP 等功能。\n\n## 认证方式\n\n所有 API 请求需要在 HTTP 请求头中携带 Bearer Token：\n\n```\nAuthorization: Bearer mp_your_token_here\n```\n\nToken 可在「系统设置 → API Token」页面创建和管理。Token 格式为 `mp_` 前缀加 48 位十六进制字符。Token 支持 scope 权限：`accounts:read`、`styles:read`、`drafts:create`、`publisher:read`、`agent:context`。\n\n## 响应格式\n\n### 成功响应\n\n```json\n{\n  \"success\": true,\n  \"message\": \"操作成功\",\n  \"data\": {}\n}\n```\n\n### 错误响应\n\n所有错误返回统一格式：\n\n```json\n{\n  \"success\": false,\n  \"code\": \"ERROR_CODE\",\n  \"message\": \"错误描述\",\n  \"details\": {}\n}\n```\n\n## 错误代码\n\n| 错误代码 | HTTP 状态码 | 说明 |\n|---|---|---|\n| `UNAUTHORIZED` | 401 | 缺少或无效的 Authorization 头 |\n| `FORBIDDEN` | 403 | Token 缺少接口所需 scope |\n| `TOKEN_INVALID_FORMAT` | 401 | Token 格式不正确（应以 mp_ 开头） |\n| `TOKEN_NOT_FOUND` | 401 | Token 不存在或已被删除 |\n| `TOKEN_EXPIRED` | 401 | Token 已过期 |\n| `MISSING_PARAM` | 400 | 缺少必填参数 |\n| `INVALID_PARAM` | 400 | 参数格式或类型不正确 |\n| `PARAM_TOO_LONG` | 400 | 参数超过最大长度限制 |\n| `CONTENT_TOO_LARGE` | 400 | 内容体积过大 |\n| `NOT_FOUND` | 404 | 请求的资源不存在 |\n| `NO_ACCOUNT` | 400 | 没有可用的公众号 |\n| `ACCOUNT_TOKEN_INVALID` | 400 | 公众号令牌无效需重新授权 |\n| `WECHAT_API_ERROR` | 400 | 微信 API 返回错误 |\n| `INTERNAL_ERROR` | 500 | 服务器内部错误 |",
    "version": "1.4.0",
    "contact": {
      "name": "公众号管理平台"
    }
  },
  "servers": [
    {
      "url": "/api/open",
      "description": "当前服务器"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "公众号",
      "description": "查询已授权的公众号账号信息"
    },
    {
      "name": "样式配置",
      "description": "查询公众号的文章样式配置"
    },
    {
      "name": "流量主收益",
      "description": "查询流量主累计收益、区间汇总和每日趋势"
    },
    {
      "name": "草稿发布",
      "description": "将 Markdown 内容创建为微信草稿，并同步写入后台文章管理"
    },
    {
      "name": "Agent",
      "description": "Agent Context、CLI 和远程 MCP 接入所需能力"
    }
  ],
  "paths": {
    "/agent/context": {
      "get": {
        "tags": ["Agent"],
        "summary": "获取 Agent 接入上下文",
        "description": "返回当前 Token 的 scope、可用能力、账号矩阵、接口限制和发布安全策略。适合 Codex、Claude、Cursor 或自定义 Agent 在执行前读取边界。",
        "operationId": "getAgentContext",
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "context": {
                      "type": "object",
                      "properties": {
                        "platform": { "type": "object" },
                        "token": { "type": "object" },
                        "capabilities": { "type": "array", "items": { "type": "object" } },
                        "limits": { "type": "object" },
                        "publishingPolicy": { "type": "object" },
                        "accounts": { "type": "array", "items": { "$ref": "#/components/schemas/Account" } }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/accounts": {
      "get": {
        "tags": ["公众号"],
        "summary": "获取公众号列表",
        "description": "获取当前用户已授权的所有公众号列表，包含基本信息和认证状态。",
        "operationId": "listAccounts",
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "accounts": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Account" }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "accounts": [
                    {
                      "appid": "wx1234567890abcdef",
                      "nickName": "我的公众号",
                      "headImg": "https://wx.qlogo.cn/mmopen/xxx/0",
                      "verified": true,
                      "hasStyleConfig": true
                    }
                  ]
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/account-style": {
      "get": {
        "tags": ["样式配置"],
        "summary": "获取公众号样式配置",
        "description": "获取公众号的文章样式配置。不传 `appid` 则返回所有公众号的样式配置；传入 `appid` 则返回指定公众号的样式配置。\n\n样式配置用于 Markdown 转换为微信公众号 HTML 时的主题渲染。",
        "operationId": "getAccountStyle",
        "parameters": [
          {
            "name": "appid",
            "in": "query",
            "required": false,
            "description": "公众号 AppID（不传则返回所有）",
            "schema": { "type": "string" },
            "example": "wx1234567890abcdef"
          }
        ],
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "description": "指定 appid 时返回单个账号",
                      "properties": {
                        "success": { "type": "boolean", "example": true },
                        "account": {
                          "type": "object",
                          "properties": {
                            "appid": { "type": "string" },
                            "nickName": { "type": "string" },
                            "styleConfig": { "$ref": "#/components/schemas/StyleConfig" }
                          }
                        }
                      }
                    },
                    {
                      "type": "object",
                      "description": "不传 appid 时返回所有账号",
                      "properties": {
                        "success": { "type": "boolean", "example": true },
                        "accounts": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "appid": { "type": "string" },
                              "nickName": { "type": "string" },
                              "styleConfig": { "$ref": "#/components/schemas/StyleConfig" }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "公众号不存在",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "code": "NOT_FOUND", "message": "未找到该公众号或无权限访问", "details": { "appid": "wx1234567890abcdef" } }
              }
            }
          }
        }
      }
    },
    "/publisher/summary": {
      "get": {
        "tags": ["流量主收益"],
        "summary": "获取流量主累计概览",
        "description": "返回当前 Token 所属用户的流量主累计概览。可按 `appids` 过滤指定公众号；不传时返回全部已授权公众号，并附带跨账号总计。",
        "operationId": "getPublisherSummary",
        "parameters": [
          {
            "name": "appids",
            "in": "query",
            "required": false,
            "description": "公众号 AppID 列表，多个用英文逗号分隔",
            "schema": { "type": "string" },
            "example": "wx123,wx456"
          }
        ],
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "accounts": [
                    {
                      "appid": "wx123",
                      "nickName": "公众号A",
                      "headImg": "https://wx.qlogo.cn/xxx",
                      "revenueAll": 125000,
                      "settledRevenueAll": 118000,
                      "penaltyAll": 0,
                      "wywRevenueAll": 0,
                      "wywSettledRevenueAll": 0,
                      "wywPenaltyAll": 0,
                      "adReqSuccCount": 120000,
                      "adExposureCount": 85000,
                      "adClickCount": 2100,
                      "adIncome": 16800,
                      "adWindowStart": "2026-01-01T00:00:00.000Z",
                      "adWindowEnd": "2026-04-14T00:00:00.000Z",
                      "lastSettlementSyncedAt": "2026-04-15T02:00:00.000Z",
                      "lastAdposSyncedAt": "2026-04-15T02:00:00.000Z",
                      "lastSettlementStatus": "ok",
                      "lastAdposStatus": "ok",
                      "lastSyncError": null
                    }
                  ],
                  "total": {
                    "revenueAll": 125000,
                    "settledRevenueAll": 118000,
                    "penaltyAll": 0,
                    "adIncome": 16800,
                    "adExposureCount": 85000,
                    "adClickCount": 2100,
                    "adReqSuccCount": 120000
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/publisher/settlement-summary": {
      "get": {
        "tags": ["流量主收益"],
        "summary": "获取指定时间段收益汇总",
        "description": "统计指定时间段的流量主结算收益汇总。支持按公众号拆分（`groupBy=appid`）或仅返回总汇总（`groupBy=total`）。",
        "operationId": "getPublisherSettlementSummary",
        "parameters": [
          {
            "name": "appids",
            "in": "query",
            "required": false,
            "description": "公众号 AppID 列表，多个用英文逗号分隔",
            "schema": { "type": "string" },
            "example": "wx123,wx456"
          },
          {
            "name": "startDate",
            "in": "query",
            "required": false,
            "description": "开始日期，格式 YYYY-MM-DD。默认近 90 天窗口。",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-01-01"
          },
          {
            "name": "endDate",
            "in": "query",
            "required": false,
            "description": "结束日期，格式 YYYY-MM-DD。默认昨天。",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-04-14"
          },
          {
            "name": "groupBy",
            "in": "query",
            "required": false,
            "description": "汇总维度。`appid` 返回各公众号汇总，`total` 仅返回合计。",
            "schema": {
              "type": "string",
              "enum": ["appid", "total"],
              "default": "appid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "range": {
                    "startDate": "2026-01-01",
                    "endDate": "2026-04-14",
                    "days": 104
                  },
                  "accounts": [
                    {
                      "appid": "wx123",
                      "nickName": "公众号A",
                      "headImg": "https://wx.qlogo.cn/xxx",
                      "money": 32500,
                      "settledRevenue": 30000,
                      "penalty": 0
                    }
                  ],
                  "total": {
                    "money": 32500,
                    "settledRevenue": 30000,
                    "penalty": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "参数错误",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "code": "INVALID_PARAM", "message": "startDate / endDate 格式错误或时间范围非法" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/publisher/settlement-daily": {
      "get": {
        "tags": ["流量主收益"],
        "summary": "获取指定时间段每日收益趋势",
        "description": "返回指定时间段内的每日结算收益趋势。支持按公众号展开（`groupBy=appid`）或按全账号汇总趋势（`groupBy=total`）。",
        "operationId": "getPublisherSettlementDaily",
        "parameters": [
          {
            "name": "appids",
            "in": "query",
            "required": false,
            "description": "公众号 AppID 列表，多个用英文逗号分隔",
            "schema": { "type": "string" },
            "example": "wx123,wx456"
          },
          {
            "name": "startDate",
            "in": "query",
            "required": false,
            "description": "开始日期，格式 YYYY-MM-DD。默认近 90 天窗口。",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-01-01"
          },
          {
            "name": "endDate",
            "in": "query",
            "required": false,
            "description": "结束日期，格式 YYYY-MM-DD。默认昨天。",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-04-14"
          },
          {
            "name": "groupBy",
            "in": "query",
            "required": false,
            "description": "返回维度。`appid` 返回每日按公众号展开的数据，`total` 返回每日总汇总。",
            "schema": {
              "type": "string",
              "enum": ["appid", "total"],
              "default": "appid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "获取成功",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "range": {
                    "startDate": "2026-01-01",
                    "endDate": "2026-04-14",
                    "days": 104
                  },
                  "accounts": [
                    {
                      "appid": "wx123",
                      "nickName": "公众号A",
                      "headImg": "https://wx.qlogo.cn/xxx"
                    }
                  ],
                  "days": [
                    {
                      "date": "2026-04-10",
                      "perAppid": {
                        "wx123": {
                          "appid": "wx123",
                          "nickName": "公众号A",
                          "headImg": "https://wx.qlogo.cn/xxx",
                          "money": 1200,
                          "settledRevenue": 1100,
                          "penalty": 0,
                          "settleStatus": 2
                        }
                      },
                      "totalMoney": 1200,
                      "totalSettled": 1100,
                      "totalPenalty": 0
                    }
                  ],
                  "total": {
                    "money": 1200,
                    "settledRevenue": 1100,
                    "penalty": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "参数错误",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "code": "INVALID_PARAM", "message": "groupBy 只能是 appid 或 total" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/draft": {
      "post": {
        "tags": ["草稿发布"],
        "summary": "创建微信草稿并同步后台文章",
        "description": "创建微信公众号草稿，支持两种消息类型：普通图文消息（`news`）和图片消息（`newspic`）。接口在微信侧创建草稿成功后，会同步写入系统本地 `Article` 表，便于在后台文章管理中继续查看和正式发布。\n\n**注意：** Content-Type 必须为 `application/json`。\n\n### 支持的草稿类型\n- `news`：默认值。将 Markdown 转换为带内联样式的 HTML，自动上传正文图片并自动处理封面。\n- `newspic`：图片消息。`content` 按原样发送；需额外提供 `imageUrls` / `imageMediaIds` / `coverImageUrl` 中至少一种图片来源。\n\n### `news` 处理流程\n1. 将 Markdown 转换为带内联样式的 HTML（应用主题配置）\n2. 自动上传文章中的外部图片为微信素材\n3. 上传封面图片为永久素材\n4. 自动提取摘要（如未手动指定）\n5. 调用微信 API 创建草稿\n6. 将草稿同步写入后台文章管理，返回本地 `articleId`\n\n### 样式优先级\n`themeConfig` 参数 > 公众号默认样式配置 > 系统默认样式\n\n### 参数限制\n| 参数 | 最大长度 |\n|---|---|\n| title | 64 字符 |\n| author | 16 字符 |\n| summary | 120 字符 |\n| content | 1,000,000 字符 |\n| sourceUrl | 2,048 字符 |",
        "operationId": "createDraft",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["title", "content"],
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "文章标题",
                    "maxLength": 64,
                    "example": "如何使用 Open API 发布公众号文章"
                  },
                  "article_type": {
                    "type": "string",
                    "enum": ["news", "newspic"],
                    "default": "news",
                    "description": "文章类型。`news` 为普通图文消息，`newspic` 为图片消息。兼容 `articleType` 驼峰写法。",
                    "example": "news"
                  },
                  "content": {
                    "type": "string",
                    "description": "`news` 时建议传 Markdown；`newspic` 时按原样发送为图片消息正文。",
                    "maxLength": 1000000,
                    "example": "# 标题\n\n这是一篇通过 API 发布的文章。\n\n## 小标题\n\n- 列表项 1\n- 列表项 2\n\n> 引用内容\n\n```python\nprint('Hello World')\n```"
                  },
                  "appid": {
                    "type": "string",
                    "description": "目标公众号 AppID（不传则自动选择第一个可用公众号）",
                    "example": "wx1234567890abcdef"
                  },
                  "author": {
                    "type": "string",
                    "description": "文章作者名称。不传时默认使用公众号名称（若可用）。",
                    "maxLength": 16,
                    "example": "张三"
                  },
                  "summary": {
                    "type": "string",
                    "description": "文章摘要（不传则自动从内容中提取前 120 字）",
                    "maxLength": 120,
                    "example": "本文介绍如何通过 Open API 自动化发布公众号文章..."
                  },
                  "coverImageUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "`news` 时作为封面图 URL（不传则自动提取文章中第一张图片）；`newspic` 时可作为单张图片消息的兜底图片来源。必须为 HTTP/HTTPS 链接。",
                    "example": "https://example.com/cover.jpg"
                  },
                  "imageUrls": {
                    "type": "array",
                    "description": "仅 `article_type=newspic` 使用。图片 URL 列表，服务端会自动上传成微信永久素材。兼容 `image_urls` 下划线写法。",
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "example": ["https://example.com/1.jpg", "https://example.com/2.jpg"]
                  },
                  "imageMediaIds": {
                    "type": "array",
                    "description": "仅 `article_type=newspic` 使用。已上传到微信素材库的永久图片 media_id 列表。兼容 `image_media_ids` 下划线写法。",
                    "items": {
                      "type": "string"
                    },
                    "example": ["MEDIA_ID_IMG_1", "MEDIA_ID_IMG_2"]
                  },
                  "coverInfo": {
                    "type": "object",
                    "description": "仅 `article_type=newspic` 使用。图片消息封面裁剪信息。兼容 `cover_info` 下划线写法。",
                    "properties": {
                      "crop_percent_list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "ratio": { "type": "string", "example": "1_1" },
                            "x1": { "type": "string", "example": "0" },
                            "y1": { "type": "string", "example": "0" },
                            "x2": { "type": "string", "example": "1" },
                            "y2": { "type": "string", "example": "1" }
                          }
                        }
                      }
                    }
                  },
                  "productInfo": {
                    "type": "object",
                    "description": "仅 `article_type=newspic` 使用。图片消息挂载商品信息。兼容 `product_info` 下划线写法。",
                    "properties": {
                      "footer_product_info": {
                        "type": "object",
                        "properties": {
                          "product_key": {
                            "type": "string",
                            "example": "shop_product_key_xxx"
                          }
                        }
                      }
                    }
                  },
                  "sourceUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "阅读原文链接",
                    "maxLength": 2048,
                    "example": "https://example.com/original-article"
                  },
                  "showCoverPic": {
                    "type": "boolean",
                    "description": "是否在文章内显示封面图片",
                    "default": true
                  },
                  "openComment": {
                    "type": "boolean",
                    "description": "是否打开评论功能",
                    "default": true
                  },
                  "fansOnlyComment": {
                    "type": "boolean",
                    "description": "是否仅粉丝可评论",
                    "default": false
                  },
                  "themeConfig": {
                    "$ref": "#/components/schemas/StyleConfig"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "微信草稿和后台文章同步成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "message": { "type": "string", "example": "草稿发布成功，已同步到后台文章管理" },
                    "articleId": {
                      "type": "string",
                      "description": "系统本地文章 ID，可用于后台文章管理和后续正式发布",
                      "example": "cm9abc123def456ghi789jkl"
                    },
                    "mediaId": {
                      "type": "string",
                      "description": "微信草稿的 media_id，可用于后续操作",
                      "example": "MEDIA_ID_xxxx"
                    },
                    "account": {
                      "type": "object",
                      "properties": {
                        "appid": { "type": "string", "example": "wx1234567890abcdef" },
                        "nickName": { "type": "string", "example": "我的公众号" }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "草稿发布成功，已同步到后台文章管理",
                  "articleId": "cm9abc123def456ghi789jkl",
                  "mediaId": "MEDIA_ID_xxxx",
                  "account": {
                    "appid": "wx1234567890abcdef",
                    "nickName": "我的公众号"
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数错误",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "examples": {
                  "missing_title": {
                    "summary": "缺少标题",
                    "value": { "success": false, "code": "MISSING_PARAM", "message": "缺少必填参数 title", "details": { "field": "title" } }
                  },
                  "title_too_long": {
                    "summary": "标题过长",
                    "value": { "success": false, "code": "PARAM_TOO_LONG", "message": "title 最长 64 个字符", "details": { "field": "title", "maxLength": 64 } }
                  },
                  "content_too_large": {
                    "summary": "内容过大",
                    "value": { "success": false, "code": "CONTENT_TOO_LARGE", "message": "content 内容过长，最大 1000000 个字符", "details": { "field": "content", "maxLength": 1000000 } }
                  },
                  "invalid_url": {
                    "summary": "URL 格式无效",
                    "value": { "success": false, "code": "INVALID_PARAM", "message": "coverImageUrl 必须是有效的 HTTP/HTTPS URL", "details": { "field": "coverImageUrl" } }
                  },
                  "missing_newspic_images": {
                    "summary": "图片消息缺少图片",
                    "value": { "success": false, "code": "MISSING_PARAM", "message": "图片消息至少需要提供 imageUrls、imageMediaIds 或 coverImageUrl", "details": { "field": "imageUrls" } }
                  },
                  "no_account": {
                    "summary": "无可用公众号",
                    "value": { "success": false, "code": "NO_ACCOUNT", "message": "没有可用的公众号，请先授权绑定" }
                  },
                  "account_token_invalid": {
                    "summary": "公众号令牌无效",
                    "value": { "success": false, "code": "ACCOUNT_TOKEN_INVALID", "message": "公众号令牌不存在或已过期，请重新授权" }
                  },
                  "wechat_error": {
                    "summary": "微信 API 错误",
                    "value": { "success": false, "code": "WECHAT_API_ERROR", "message": "微信草稿创建失败: invalid media_id", "details": { "wechatErrorCode": 40007, "wechatErrorMsg": "invalid media_id" } }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "公众号不存在",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "code": "NOT_FOUND", "message": "未找到公众号 wx1234567890abcdef 或无权限访问", "details": { "appid": "wx1234567890abcdef" } }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用 `mp_` 前缀的 API Token 进行认证。\n\n在「系统设置 → API Token」页面创建 Token。"
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": ["success", "code", "message"],
        "properties": {
          "success": { "type": "boolean", "example": false },
          "code": {
            "type": "string",
            "description": "标准化错误代码",
            "enum": [
              "UNAUTHORIZED",
              "TOKEN_INVALID_FORMAT",
              "TOKEN_NOT_FOUND",
              "TOKEN_EXPIRED",
              "MISSING_PARAM",
              "INVALID_PARAM",
              "PARAM_TOO_LONG",
              "CONTENT_TOO_LARGE",
              "NOT_FOUND",
              "NO_ACCOUNT",
              "ACCOUNT_TOKEN_INVALID",
              "WECHAT_API_ERROR",
              "INTERNAL_ERROR"
            ],
            "example": "MISSING_PARAM"
          },
          "message": { "type": "string", "description": "人类可读的错误描述", "example": "缺少必填参数 title" },
          "details": {
            "type": "object",
            "description": "额外的错误详情（如哪个字段出错、最大长度等）",
            "additionalProperties": true,
            "example": { "field": "title", "maxLength": 64 }
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "appid": {
            "type": "string",
            "description": "公众号 AppID",
            "example": "wx1234567890abcdef"
          },
          "nickName": {
            "type": "string",
            "description": "公众号名称",
            "example": "我的公众号"
          },
          "headImg": {
            "type": "string",
            "nullable": true,
            "description": "公众号头像 URL",
            "example": "https://wx.qlogo.cn/mmopen/xxx/0"
          },
          "verified": {
            "type": "boolean",
            "description": "是否通过微信认证",
            "example": true
          },
          "hasStyleConfig": {
            "type": "boolean",
            "description": "是否已配置默认文章样式",
            "example": true
          }
        }
      },
      "StyleConfig": {
        "type": "object",
        "nullable": true,
        "description": "Markdown 文章样式配置",
        "properties": {
          "theme": {
            "type": "string",
            "enum": ["default", "grace", "simple"],
            "description": "主题名称：default（经典）、grace（优雅）、simple（简洁）",
            "default": "default"
          },
          "primaryColor": {
            "type": "string",
            "description": "主题色（CSS 颜色值）",
            "default": "#FA5151",
            "example": "#1890ff"
          },
          "fontFamily": {
            "type": "string",
            "description": "字体",
            "default": "-apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif"
          },
          "fontSize": {
            "type": "string",
            "description": "正文字号",
            "default": "16px",
            "enum": ["14px", "15px", "16px", "17px", "18px"]
          },
          "codeBlockTheme": {
            "type": "string",
            "description": "代码块高亮主题（支持 70+ Highlight.js 主题）",
            "default": "github",
            "example": "atom-one-dark"
          },
          "isMacCodeBlock": {
            "type": "boolean",
            "description": "是否使用 Mac 风格代码块",
            "default": true
          },
          "isShowLineNumber": {
            "type": "boolean",
            "description": "代码块是否显示行号",
            "default": false
          },
          "isCiteStatus": {
            "type": "boolean",
            "description": "是否启用脚注/引用",
            "default": false
          },
          "legend": {
            "type": "string",
            "description": "图片注释显示方式",
            "enum": ["title-alt", "alt-title", "title", "alt", "none"],
            "default": "alt"
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "认证失败",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" },
            "examples": {
              "missing_header": {
                "summary": "缺少认证头",
                "value": { "success": false, "code": "UNAUTHORIZED", "message": "缺少 Authorization 头，格式：Bearer <token>" }
              },
              "invalid_format": {
                "summary": "Token 格式无效",
                "value": { "success": false, "code": "TOKEN_INVALID_FORMAT", "message": "无效的 Token 格式，Token 应以 mp_ 开头" }
              },
              "token_not_found": {
                "summary": "Token 不存在",
                "value": { "success": false, "code": "TOKEN_NOT_FOUND", "message": "Token 不存在或已被删除" }
              },
              "token_expired": {
                "summary": "Token 已过期",
                "value": { "success": false, "code": "TOKEN_EXPIRED", "message": "Token 已过期，请重新创建" }
              }
            }
          }
        }
      }
    }
  }
}
