{"openapi": "3.0.3", "info": {"title": "润心工作台 · 集成 API", "version": "2.2.0", "description": "润心工作台对外集成 API（/api/v1）。用「我的 → AI 接入」生成的个人令牌鉴权：Authorization: Bearer <token>，或 X-Api-Key: <token>。令牌权限分 read / write 两档；POST/PUT/PATCH 需 create/update 权限、DELETE 需 delete 权限，权限不足返回 403 且 code=token_no_write。响应统一为 JSON 信封（顶层 ok 字段）；失败时 code 为机器可读类型。"}, "servers": [{"url": "https://workbench.crrx.net", "description": "生产"}], "security": [{"bearerAuth": []}, {"apiKeyAuth": []}], "tags": [{"name": "集成", "description": "供 AI 助手 / CLI / 自动化调用"}], "components": {"securitySchemes": {"bearerAuth": {"type": "http", "scheme": "bearer", "description": "个人 API 令牌；服务端仅存 sha256，明文只在生成时展示一次"}, "apiKeyAuth": {"type": "apiKey", "in": "header", "name": "X-Api-Key", "description": "同上令牌的备选传法（部分工具不便自定义 Authorization 头）"}}, "schemas": {"Envelope": {"type": "object", "required": ["ok"], "properties": {"ok": {"type": "boolean"}, "msg": {"type": "string"}, "code": {"type": "string"}}}, "Task": {"type": "object", "properties": {"id": {"type": "integer"}, "title": {"type": "string"}, "kind": {"type": "string", "enum": ["todo", "plan"]}, "done": {"type": "integer", "enum": [0, 1]}, "priority": {"type": "string", "enum": ["low", "mid", "high"]}, "due": {"type": "string", "description": "YYYY-MM-DD，可空"}, "visibility": {"type": "string", "enum": ["private", "team", "public"]}}}, "Note": {"type": "object", "properties": {"id": {"type": "integer"}, "text": {"type": "string"}, "created": {"type": "integer", "description": "Unix 秒"}}}, "Project": {"type": "object", "properties": {"id": {"type": "integer"}, "name": {"type": "string"}, "step": {"type": "string"}, "next": {"type": "string"}, "blocker": {"type": "string"}, "content": {"type": "string"}, "due_date": {"type": "string"}, "importance": {"type": "string", "enum": ["high", "mid", "low"]}, "urgency": {"type": "string", "enum": ["high", "mid", "low"]}, "progress_pct": {"type": "integer"}}}}}, "paths": {"/api/v1/whoami": {"get": {"tags": ["集成"], "operationId": "whoami", "summary": "校验令牌并返回归属人与权限范围", "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "429": {"description": "触发限流（code=rate_limited）"}}}}, "/api/v1/me": {"get": {"tags": ["集成"], "operationId": "getMe", "summary": "当前令牌对应用户的资料", "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}}, "/api/v1/inbox": {"get": {"tags": ["集成"], "operationId": "listInbox", "summary": "收件箱（本人）", "parameters": [{"name": "limit", "in": "query", "schema": {"type": "integer", "default": 100, "maximum": 500}}, {"name": "page", "in": "query", "schema": {"type": "integer", "default": 1}}, {"name": "size", "in": "query", "schema": {"type": "integer"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}}, "/api/v1/events": {"get": {"tags": ["集成"], "operationId": "listEvents", "summary": "日程（来自钉钉；未绑定时返回空并附 error 说明）", "parameters": [{"name": "range", "in": "query", "schema": {"type": "string", "enum": ["today", "week"], "default": "today"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}}, "/api/v1/export": {"get": {"tags": ["集成"], "operationId": "exportRange", "summary": "周报素材：区间内的待办与笔记", "parameters": [{"name": "from", "in": "query", "schema": {"type": "string"}, "description": "时间戳或 YYYY-MM-DD；缺省近 7 天"}, {"name": "to", "in": "query", "schema": {"type": "string"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}}, "/api/v1/tasks": {"get": {"tags": ["集成"], "operationId": "listTasks", "summary": "任务列表（本人）", "parameters": [{"name": "done", "in": "query", "schema": {"type": "integer", "enum": [0, 1]}}, {"name": "q", "in": "query", "schema": {"type": "string"}, "description": "标题关键字"}, {"name": "limit", "in": "query", "schema": {"type": "integer", "default": 200, "maximum": 1000}}, {"name": "page", "in": "query", "schema": {"type": "integer", "default": 1}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}, "post": {"tags": ["集成"], "operationId": "createTask", "summary": "创建任务（需 create 权限）", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Task"}}}}, "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}}}}, "/api/v1/tasks/{id}": {"get": {"tags": ["集成"], "operationId": "getTask", "summary": "读取单个任务", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "400": {"description": "参数非法（如 id 非数字）"}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "404": {"description": "资源不存在或不属于本人"}}}, "put": {"tags": ["集成"], "operationId": "updateTask", "summary": "更新任务（需 update 权限）", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Task"}}}}, "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "400": {"description": "参数非法（如 id 非数字）"}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}, "404": {"description": "资源不存在或不属于本人"}}}, "delete": {"tags": ["集成"], "operationId": "deleteTask", "summary": "删除任务（需 delete 权限）", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}, "404": {"description": "资源不存在或不属于本人"}}}}, "/api/v1/notes": {"get": {"tags": ["集成"], "operationId": "listNotes", "summary": "速记列表（本人）", "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}, "post": {"tags": ["集成"], "operationId": "createNote", "summary": "新建速记（需 create 权限）", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Note"}}}}, "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}}}}, "/api/v1/notes/{id}": {"delete": {"tags": ["集成"], "operationId": "deleteNote", "summary": "删除速记（需 delete 权限）", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}, "404": {"description": "资源不存在或不属于本人"}}}}, "/api/v1/projects": {"get": {"tags": ["集成"], "operationId": "listProjects", "summary": "项目列表（本人）", "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}}}, "post": {"tags": ["集成"], "operationId": "createProject", "summary": "新建项目（需 create 权限）", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Project"}}}}, "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "403": {"description": "令牌无写权限（code=token_no_write）"}}}}, "/api/v1/projects/{id}": {"get": {"tags": ["集成"], "operationId": "getProject", "summary": "读取单个项目（含进展）", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "成功（JSON 信封 ok=true）", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Envelope"}}}}, "400": {"description": "参数非法（如 id 非数字）"}, "401": {"description": "令牌无效/已吊销（code=token_invalid）"}, "404": {"description": "资源不存在或不属于本人"}}}}}}