Files
ops-assistant/docs/API_RESPONSE_CONVENTION.md
2026-03-19 21:23:28 +08:00

37 lines
809 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# API Response Convention
统一响应格式JSON 接口):
- 成功:
```json
{
"code": "OK",
"message": "ok|success|...",
"data": { }
}
```
- 失败:
```json
{
"code": "ERR_...",
"message": "..."
}
```
## 约定
1. 所有 `/api/v1/*` JSON 接口使用统一结构。
2. 文件流接口(如 CSV 导出)成功时返回文件内容;失败时返回统一错误 JSON。
3. 权限失败统一 `ERR_PERMISSION_DENIED`
4. 执行失败统一至少返回一个业务错误码(例如 `ERR_STEP_FAILED`)。
5. `message` 用于人类可读,`code` 用于前端逻辑分支。
## 已接入范围2026-03-10
- Ops: jobs/list/detail/cancel/retry
- Flags: list/patch
- Channels: list/patch/publish/reload/enable/disable/disable-all/test/apply
- Records: list/delete
- Audit: list