itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询消息列表与当前用户阅读状态

GET/v1/messages

分页查询站内消息摘要和当前查询用户的已读状态,按 sort 降序、消息 ID 降序返回。普通用户只可查询展示中的、按当前服务端 receive 条件归属自己的消息;管理员可查询全部消息,也可用 receive 切换为指定接收用户视角。列表响应不包含消息正文 content,正文需通过 GET /v1/messages/{message_id} 获取。

身份认证

access-token

api-key + api-secret

认证定义
{
  "AccessToken": {
    "type": "apiKey",
    "in": "header",
    "name": "access-token",
    "description": "通过登录接口获得的短期访问令牌。"
  },
  "ApiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "api-key",
    "description": "API Key;必须和 api-secret 同时发送。"
  },
  "ApiSecret": {
    "type": "apiKey",
    "in": "header",
    "name": "api-secret",
    "description": "API Secret;必须和 api-key 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
pagequeryinteger (int32)可选

页码,默认 1。服务端仅校验为数字,分页偏移为 (page - 1) × limit。

完整参数定义
{
  "name": "page",
  "in": "query",
  "required": false,
  "description": "页码,默认 1。服务端仅校验为数字,分页偏移为 (page - 1) × limit。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 1,
    "default": 1
  }
}
limitqueryinteger (int32)可选

每页记录数,默认 10;传 0 时返回全部匹配记录。

完整参数定义
{
  "name": "limit",
  "in": "query",
  "required": false,
  "description": "每页记录数,默认 10;传 0 时返回全部匹配记录。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 0,
    "default": 10
  }
}
typequerystring可选

精确筛选消息类型。当前消息创建接口只允许 announcement;服务端对非 announcement 类型会在普通用户或指定 receive 时额外按接收用户过滤。

完整参数定义
{
  "name": "type",
  "in": "query",
  "required": false,
  "description": "精确筛选消息类型。当前消息创建接口只允许 announcement;服务端对非 announcement 类型会在普通用户或指定 receive 时额外按接收用户过滤。",
  "schema": {
    "type": "string",
    "example": "announcement"
  }
}
receivequeryinteger (int64)可选

仅管理员可用。指定消息接收用户 ID,并按该用户视角关联已读状态;普通用户传入会被拒绝。

完整参数定义
{
  "name": "receive",
  "in": "query",
  "required": false,
  "description": "仅管理员可用。指定消息接收用户 ID,并按该用户视角关联已读状态;普通用户传入会被拒绝。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  }
}
is_showqueryinteger可选

仅管理员有效:精确筛选展示状态,必须为数字。普通用户始终只查询 is_show=1 的消息。

完整参数定义
{
  "name": "is_show",
  "in": "query",
  "required": false,
  "description": "仅管理员有效:精确筛选展示状态,必须为数字。普通用户始终只查询 is_show=1 的消息。",
  "schema": {
    "type": "integer",
    "enum": [
      0,
      1
    ]
  }
}
user_package_idqueryinteger (int64)可选

精确筛选关联的用户套餐 ID。

完整参数定义
{
  "name": "user_package_id",
  "in": "query",
  "required": false,
  "description": "精确筛选关联的用户套餐 ID。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  }
}
site_idqueryinteger (int64)可选

精确筛选关联的网站 ID。

完整参数定义
{
  "name": "site_id",
  "in": "query",
  "required": false,
  "description": "精确筛选关联的网站 ID。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  }
}

响应

HTTP 200

业务结果使用 HTTP 200 返回。成功响应包含 code、count、data,不含 msg;页码、每页数量、is_show 格式或 receive 权限错误时返回业务错误封装。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
countinteger (int64)必填

当前权限和筛选条件下、未应用分页前的消息总数。

约束 / 默认值 / 示例
{
  "format": "int64",
  "minimum": 0
}
dataarray <object>必填

当前页消息摘要,按 sort 降序、id 降序排列。

展开字段结构

当前页消息摘要,按 sort 降序、id 降序排列。

数组元素 · object

消息列表项(不含 content 正文)。

字段类型必填说明与约束
user_package_idinteger (int64)可选

关联的用户套餐 ID;未关联时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
site_idinteger (int64)可选

关联的网站 ID;未关联时为 null。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
receiveinteger (int64)可选

消息指定接收用户 ID;null 表示未指定单个接收者。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
uidinteger (int64)可选

当前查询用户在 message_read 中的用户 ID;非 null 表示该用户已读此消息,null 表示未读。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
idinteger (int64)必填

消息 ID。

约束 / 默认值 / 示例
{
  "format": "int64"
}
typestring必填

消息类型。

约束 / 默认值 / 示例
{
  "nullable": true
}
titlestring必填

消息标题。

约束 / 默认值 / 示例
{
  "nullable": true
}
is_showboolean必填

是否在消息列表中展示。

约束 / 默认值 / 示例
{
  "nullable": true
}
is_redboolean必填

是否使用红色强调样式。

约束 / 默认值 / 示例
{
  "nullable": true
}
is_boldboolean必填

是否使用粗体强调样式。

约束 / 默认值 / 示例
{
  "nullable": true
}
urlstring必填

外部消息跳转地址;非外部消息通常为空字符串。

约束 / 默认值 / 示例
{
  "nullable": true
}
is_externalboolean必填

是否为外部链接消息;为 true 时客户端应使用 url,不使用正文。

约束 / 默认值 / 示例
{
  "nullable": true
}
is_popupboolean必填

是否要求客户端以弹窗方式展示。

约束 / 默认值 / 示例
{
  "nullable": true
}
sortinteger (int32)必填

排序值,值越大越靠前。

约束 / 默认值 / 示例
{
  "format": "int32",
  "nullable": true
}
create_at2string必填

格式化后的创建时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true
}
update_at2string必填

格式化后的更新时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

page、limit、is_show 参数错误,receive 需要管理员权限或认证失败的业务错误码。

约束 / 默认值 / 示例
{
  "enum": [
    "message-19",
    "message-20",
    "message-21",
    "message-33",
    "login_required"
  ]
}
msgstring必填

具体错误原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "count",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "成功状态码,固定为 0。"
        },
        "count": {
          "type": "integer",
          "format": "int64",
          "minimum": 0,
          "description": "当前权限和筛选条件下、未应用分页前的消息总数。"
        },
        "data": {
          "type": "array",
          "description": "当前页消息摘要,按 sort 降序、id 降序排列。",
          "items": {
            "type": "object",
            "required": [
              "id",
              "type",
              "title",
              "is_show",
              "is_red",
              "is_bold",
              "url",
              "is_external",
              "is_popup",
              "sort",
              "create_at2",
              "update_at2"
            ],
            "properties": {
              "user_package_id": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "关联的用户套餐 ID;未关联时为 null。"
              },
              "site_id": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "关联的网站 ID;未关联时为 null。"
              },
              "receive": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "消息指定接收用户 ID;null 表示未指定单个接收者。"
              },
              "uid": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "当前查询用户在 message_read 中的用户 ID;非 null 表示该用户已读此消息,null 表示未读。"
              },
              "id": {
                "type": "integer",
                "format": "int64",
                "description": "消息 ID。"
              },
              "type": {
                "type": "string",
                "nullable": true,
                "description": "消息类型。"
              },
              "title": {
                "type": "string",
                "nullable": true,
                "description": "消息标题。"
              },
              "is_show": {
                "type": "boolean",
                "nullable": true,
                "description": "是否在消息列表中展示。"
              },
              "is_red": {
                "type": "boolean",
                "nullable": true,
                "description": "是否使用红色强调样式。"
              },
              "is_bold": {
                "type": "boolean",
                "nullable": true,
                "description": "是否使用粗体强调样式。"
              },
              "url": {
                "type": "string",
                "nullable": true,
                "description": "外部消息跳转地址;非外部消息通常为空字符串。"
              },
              "is_external": {
                "type": "boolean",
                "nullable": true,
                "description": "是否为外部链接消息;为 true 时客户端应使用 url,不使用正文。"
              },
              "is_popup": {
                "type": "boolean",
                "nullable": true,
                "description": "是否要求客户端以弹窗方式展示。"
              },
              "sort": {
                "type": "integer",
                "format": "int32",
                "nullable": true,
                "description": "排序值,值越大越靠前。"
              },
              "create_at2": {
                "type": "string",
                "nullable": true,
                "description": "格式化后的创建时间,格式为 YYYY-MM-DD HH:mm:ss。"
              },
              "update_at2": {
                "type": "string",
                "nullable": true,
                "description": "格式化后的更新时间,格式为 YYYY-MM-DD HH:mm:ss。"
              }
            },
            "additionalProperties": false,
            "description": "消息列表项(不含 content 正文)。"
          }
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "message-19",
            "message-20",
            "message-21",
            "message-33",
            "login_required"
          ],
          "description": "page、limit、is_show 参数错误,receive 需要管理员权限或认证失败的业务错误码。"
        },
        "msg": {
          "type": "string",
          "description": "具体错误原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "user_package_id": null,
      "site_id": null,
      "receive": 12,
      "uid": 12,
      "id": 101,
      "type": "announcement",
      "title": "服务通知",
      "is_show": true,
      "is_red": false,
      "is_bold": false,
      "url": "",
      "is_external": false,
      "is_popup": false,
      "sort": 100,
      "create_at2": "2026-01-01 12:00:00",
      "update_at2": "2026-01-01 12:00:00"
    }
  ]
}

查询成功

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "user_package_id": null,
      "site_id": null,
      "receive": 12,
      "uid": 12,
      "id": 101,
      "type": "announcement",
      "title": "服务通知",
      "is_show": true,
      "is_red": false,
      "is_bold": false,
      "url": "",
      "is_external": false,
      "is_popup": false,
      "sort": 100,
      "create_at2": "2026-01-01 12:00:00",
      "update_at2": "2026-01-01 12:00:00"
    }
  ]
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/messages" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON