Skip to main content
TaskNeo 会在任务发布和截止日期前发送通知。你可以查看通知收件箱,并为每个渠道(邮件、webhook、Telegram)配置投递偏好。
所有通知接口都需要有效的 Authorization: Bearer <token> 头。

通知类型

类型触发条件接收者
TASK_PUBLISHED班级中发布了任务所有班级成员
TASK_DUE_REMINDER任务截止日期临近尚未提交的成员
通知会异步送达 - 无论邮件是否已送达,任务发布都会立即完成。投递渠道:EMAILWEBHOOKTELEGRAM

GET /users/me/notifications

按游标分页、按最新优先顺序获取你的通知收件箱。仅返回 SENT 通知。 Query parameters
limit
number
default:"20"
返回通知数量。最小 1,最大 50
cursor
string
上一页最后一条通知的 UUID。省略则从头开始获取。
unreadOnly
boolean
default:"false"
true 时,仅返回 readAtnull 的通知。
Response — 200 OK
items
object[]
required
通知项列表。
nextCursor
string
当前页最后一项的 id。将其作为 cursor 传入即可获取下一页。若没有更多分页则为 null
unreadCount
integer
required
所有分页中的未读通知总数。
curl "https://api.yourdomain.com/users/me/notifications?limit=10&unreadOnly=false" \
  -H "Authorization: Bearer <token>"

GET /users/me/notifications/unread-count

仅返回未读通知数量。可用这个轻量接口更新通知徽标,而无需拉取完整收件箱。 Response — 200 OK
unreadCount
integer
required
未读通知数量。
curl https://api.yourdomain.com/users/me/notifications/unread-count \
  -H "Authorization: Bearer <token>"

PATCH /users/me/notifications/:id/read

将单条通知标记为已读。会把 readAt 设为当前时间。如果 readAt 已经存在,则不会产生任何变化。 Path parameters
id
string
required
要标记为已读的通知 UUID。
Response — 200 OK
id
string
required
已更新通知的 UUID。
Error codes
状态何时发生
404 Not Found通知不存在或不属于你。
curl -X PATCH https://api.yourdomain.com/users/me/notifications/n1a2b3c4-.../read \
  -H "Authorization: Bearer <token>"

POST /users/me/notifications/read-all

一次性将你所有通知标记为已读。 Response — 200 OK
updated
integer
required
已标记为已读的通知数量。
curl -X POST https://api.yourdomain.com/users/me/notifications/read-all \
  -H "Authorization: Bearer <token>"

GET /users/me/notification-prefs

获取你的通知渠道偏好。每条记录控制某个渠道是否启用,以及通知发送到哪里。 Response — 200 OK 通知偏好对象数组。
id
string
required
偏好记录 UUID。
channel
string
required
投递渠道:EMAILWEBHOOKTELEGRAM
address
string
required
投递地址(邮箱地址、webhook URL 或 Telegram 聊天 ID)。
isEnabled
boolean
required
此渠道是否启用。设为 false 可在不删除记录的情况下取消订阅。
如果你没有 EMAIL 偏好记录,系统会回退到你的注册邮箱接收邮件通知,因此新用户会自动收到通知。
curl https://api.yourdomain.com/users/me/notification-prefs \
  -H "Authorization: Bearer <token>"

PUT /users/me/notification-prefs

为某个渠道创建或更新通知偏好(upsert)。如果该渠道已有记录,则更新;否则创建新记录。 Request body
channel
string
required
投递渠道:EMAILWEBHOOKTELEGRAM
address
string
required
该渠道的投递地址。EMAIL 使用邮箱地址,WEBHOOK 使用 URL,TELEGRAM 使用 Telegram 聊天 ID。
isEnabled
boolean
default:"true"
设为 false 可暂停该渠道的投递,但不删除偏好记录。
Response — 200 OK 返回创建或更新后的偏好对象。
id
string
required
偏好记录 UUID。
channel
string
required
渠道名称。
address
string
required
投递地址。
isEnabled
boolean
required
渠道是否启用。
curl -X PUT https://api.yourdomain.com/users/me/notification-prefs \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "EMAIL",
    "address": "newemail@example.com",
    "isEnabled": true
  }'