{"openapi":"3.1.0","info":{"title":"LightNotify 设备消息推送 API","version":"0.13.24","description":"支持文字、语音、音乐、图片和视频的推送、上传、回执与在线查询；设备可为自己的音乐和视频生成独立在线播放链接。推送接口与设备接口使用不同凭据。"},"servers":[{"url":"https://notify.c2345.com"}],"security":[{"PushKey":[]},{"PushBearer":[]}],"components":{"securitySchemes":{"PushKey":{"type":"apiKey","in":"query","name":"key","description":"ab_l_ 开头的设备专属密钥，不与 Bearer 同时使用"},"PushBearer":{"type":"http","scheme":"bearer","description":"同一设备推送密钥，不是 App 登录凭据"},"DeviceSession":{"type":"http","scheme":"bearer","description":"App 绑定返回的 access_token，不是第三方推送链接密钥"}},"schemas":{"Message":{"type":"object","required":["title","body"],"properties":{"title":{"type":"string","maxLength":160,"minLength":1},"body":{"type":"string","maxLength":16000,"minLength":1},"source":{"type":"string","maxLength":80},"target_url":{"type":"string","maxLength":2048,"format":"uri","pattern":"^https://"},"link_title":{"type":"string","maxLength":60},"footnote":{"type":"string","maxLength":160},"tts_text":{"type":"string","maxLength":1000},"tts_voice":{"type":"string","maxLength":40,"description":"GET /api/v1/push/voices 中的音色 ID；必须与 tts_text 同时使用，不传则使用默认音色。"},"page_html":{"type":"string","maxLength":131072,"description":"语音页模板，UTF-8 总大小最多 131072 字节。"},"video_url":{"type":"string","maxLength":2048,"format":"uri","pattern":"^https://","description":"HTTPS H.264/AAC MP4；不能与 tts_text 混用。"},"body_format":{"type":"string","enum":["plain","html"],"default":"plain"},"needs_confirmation":{"type":"boolean","default":false,"description":"仅用于文字、图片、语音消息；音乐和视频忽略此参数。"},"fullscreen":{"type":"boolean","default":false},"media_id":{"type":"string","format":"uuid","description":"通过同一推送链接上传并已就绪的图片、音频或视频，不能与 media_ids/video_url 同用；音频不能与 tts_text 混用。"},"media_ids":{"type":"array","minItems":1,"maxItems":9,"uniqueItems":true,"items":{"type":"string","format":"uuid"},"description":"本链接上传的已就绪图片，按显示顺序。"},"cover_media_id":{"type":"string","format":"uuid","description":"音乐或上传视频的可选封面，必须为同一推送链接的已就绪图片；media_id 为音频或视频。手工指定优先，否则继承自动专辑封面。不能与 media_ids 混用。"},"music":{"$ref":"#/components/schemas/MusicMetadata"}},"not":{"anyOf":[{"required":["recipient_id"]},{"required":["recipient_ids"]},{"required":["media_id","media_ids"]},{"required":["video_url","media_id"]},{"required":["video_url","media_ids"]},{"required":["video_url","tts_text"]}]},"description":"链接固定收件人。媒体资源必须来自同一推送链接，已转换完成。视频不能与语音混用。"},"SendResult":{"type":"object","required":["message_id","batch_id","messages","status","apns"],"properties":{"message_id":{"type":"string","format":"uuid"},"batch_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["persisted"]},"apns":{"type":"string"},"messages":{"type":"array","items":{"type":"object","properties":{"message_id":{"type":"string","format":"uuid"},"recipient_id":{"type":"string","format":"uuid"},"status":{"type":"string"}}}}}},"Delivery":{"type":"object","properties":{"message_id":{"type":"string","format":"uuid"},"recipient_id":{"type":"string","format":"uuid"},"received":{"type":"boolean"},"apns":{"type":"string"},"audio_state":{"type":"string","enum":["none","pending","ready","failed"]},"persisted_at":{"type":["string","null"],"format":"date-time"},"received_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"first_read_at":{"type":["string","null"],"format":"date-time"},"confirmed_at":{"type":["string","null"],"format":"date-time"},"deleted_at":{"type":["string","null"],"format":"date-time"},"apns_deliveries":{"type":"array","description":"逐设备系统推送任务；Apple 受理不等于手机收到","items":{"type":"object","properties":{"device_id":{"type":"string","format":"uuid"},"state":{"type":"string"},"attempts":{"type":"integer"},"reason":{"type":["string","null"]},"accepted_at":{"type":["string","null"],"format":"date-time"}}}}}},"Upload":{"type":"object","required":["id","kind","status","error"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["image","video","audio"]},"status":{"type":"string","enum":["uploading","pending","processing","ready","failed"]},"width":{"type":["integer","null"]},"height":{"type":["integer","null"]},"duration":{"type":["number","null"],"description":"音频或视频时长（秒），图片为 null"},"size":{"type":"integer","description":"字节数"},"error":{"type":["string","null"]},"music":{"anyOf":[{"$ref":"#/components/schemas/MusicMetadata"},{"type":"null"}]},"cover_media_id":{"type":["string","null"],"format":"uuid","description":"本链接媒体自动匹配并保存的封面图片，可直接用于发布；无封面为 null。"}}},"Voices":{"type":"object","required":["default_voice","voices"],"properties":{"default_voice":{"type":"string"},"voices":{"type":"array","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"sample_url":{"type":"string","format":"uri"}}}}}},"MusicMetadata":{"type":"object","description":"音乐或上传视频的歌曲资料与歌词。按标签匹配，资料不足时进行多片段音频指纹识别，自动发布前完成。手工字段优先；LRC 只在对应当前音轨时填写。","properties":{"title":{"type":"string","maxLength":160},"artist":{"type":"string","maxLength":80},"album":{"type":"string","maxLength":160},"release_date":{"type":"string","maxLength":40},"description":{"type":"string","maxLength":2000},"plain_lyrics":{"type":"string","maxLength":30000},"synced_lyrics":{"type":"string","maxLength":40000},"lyrics_offset":{"type":"number","minimum":-600,"maximum":600,"default":0,"description":"秒，正数延后显示歌词，负数提前。"},"source_url":{"type":"string","format":"uri","pattern":"^https://","maxLength":2048},"lyrics_source_url":{"type":"string","format":"uri","pattern":"^https://","maxLength":2048},"artwork_url":{"type":"string","format":"uri","pattern":"^https://","maxLength":2048,"description":"匹配目录的原封面来源，仅供溯源；实际媒体封面使用服务器保存并授权的图片。自定义封面应上传后填写 cover_media_id。"},"match_status":{"type":"string","maxLength":40,"description":"自动匹配状态：matched / unmatched / ambiguous / unavailable。未通过音频核验的候选不作为 matched 返回。"},"recognition_status":{"type":"string","maxLength":40,"description":"音频核验结果：matched / preview_matched / catalog_matched / unmatched / ambiguous / unavailable。catalog_matched 表示明确歌名歌手经两个曲库核对版本和时长，仅补资料、封面及普通歌词，未经音频核验不提供同步时间轴。preview_matched 表示本机与官方试听波形一致，不提供整首录音偏移。合集或指纹结果冲突为 ambiguous。"},"recognition_checked_at":{"type":"string","format":"date-time","maxLength":40,"description":"最近一次指纹识别的 UTC 时间；识别成功或明确未匹配的结果随素材缓存。"},"recognition_retry_status":{"type":"string","maxLength":40,"description":"复查失败原因：unmatched / ambiguous / unavailable。保留之前已核验资料，由后台到期重试。"},"artwork_checked_at":{"type":"string","format":"date-time","maxLength":40,"description":"最近一次自动下载专辑封面的 UTC 时间；失败至少隔一天重试。"},"recognition_offset":{"type":"number","minimum":-600,"maximum":600,"description":"服务端保留的录音时间偏移（秒），用于后续匹配歌词；显示使用 lyrics_offset。"},"lyrics_status":{"type":"string","maxLength":40,"description":"补充歌词查询结果：matched / plain / unmatched / unavailable。已有手工歌词不查询。"},"lyrics_checked_at":{"type":"string","format":"date-time","maxLength":40,"description":"最近一次补充歌词查询的 UTC 时间。故障至少隔一小时重试，未收录至少隔七天重试。"}}}}},"paths":{"/api/v1/push":{"post":{"operationId":"sendMessage","summary":"发送给推送链接绑定的设备","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","pattern":"^[A-Za-z0-9._-]{1,128}$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"},"example":{"title":"新订单","body":"订单已支付，请及时处理。"}}}},"responses":{"201":{"description":"服务器已保存","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendResult"}}}},"default":{"description":"请求失败；error 给出原因","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/push/status/{message_id}":{"get":{"operationId":"getDeliveryStatus","summary":"仅查询同一推送链接发送的消息","parameters":[{"name":"message_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"消息回执","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Delivery"}}}},"default":{"description":"请求失败；error 给出原因","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/.well-known/ackbell.json":{"get":{"operationId":"getServer","security":[],"summary":"公开服务器名称、简介、Logo 与能力信息","responses":{"200":{"description":"服务器公开信息","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/push/device":{"get":{"operationId":"getPushDeviceStatus","summary":"查询当前推送链接对应设备的编号和在线状态","description":"在线指最近 60 秒 App 与服务器通信，不等于 APNs 可达；查询不会刷新在线时间。沿用 PushKey 或 PushBearer，仅查询链接拥有者设备。","responses":{"200":{"description":"设备状态","content":{"application/json":{"schema":{"type":"object","properties":{"device_id":{"type":"string","format":"uuid"},"device_code":{"type":["string","null"],"maxLength":36,"description":"iOS 0.6.14 起使用 Apple IDFV，完整 UUID；可变且不可用于鉴权。旧 AB 编号仍兼容，未上报为 null。"},"name":{"type":"string"},"online":{"type":"boolean"},"last_seen_at":{"type":["string","null"],"format":"date-time"},"online_window_seconds":{"type":"integer","const":60}}}}}},"401":{"description":"链接无效、已撤销或设备停用"},"429":{"description":"查询过于频繁"}}}},"/api/v1/device/apns":{"get":{"operationId":"getDevicePushHealth","summary":"设备查询自己的系统推送异常","security":[{"DeviceSession":[]}],"responses":{"200":{"description":"state 为 not_configured / not_registered / configuration_error / worker_unavailable / failed / retrying / ready；可含受控 reason，ready 不是送达保证"},"401":{"description":"设备未授权"}}},"post":{"operationId":"registerDevicePush","summary":"登记、刷新或撤销 APNs Token","security":[{"DeviceSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["enabled"],"properties":{"enabled":{"type":"boolean"},"token":{"type":"string","description":"enabled=true 时必填，变长十六进制 APNs Token"},"topic":{"type":"string"},"environment":{"enum":["sandbox","production"]}}}}}},"responses":{"200":{"description":"registered 或 disabled"},"400":{"description":"格式错误"},"401":{"description":"设备未授权"},"409":{"description":"topic / 环境不匹配"},"503":{"description":"服务器尚未启用系统推送"}}}},"/api/v1/messages/{message_id}":{"get":{"operationId":"getDeviceMessage","summary":"通知点击后鉴权读取自己的一条消息","security":[{"DeviceSession":[]}],"parameters":[{"name":"message_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"设备同步消息结构（含媒体路径）"},"401":{"description":"设备未授权"},"404":{"description":"不存在、不属于当前收件人或已删除"}}}},"/api/v1/push/voices":{"get":{"operationId":"listVoices","summary":"查询当前服务器可用音色及默认音色","responses":{"200":{"description":"可选音色","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Voices"}}}},"default":{"description":"请求失败；error 给出原因","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/push/uploads":{"post":{"operationId":"uploadMedia","summary":"上传图片、音频或视频，由服务器异步处理","description":"同一个 Secret API Key 仅访问自己的资源。图片 20 MiB/2500 万像素，视频 100 MiB/10 分钟/900 万像素，音频 20 MiB/10 分钟。音频支持 MP3、M4A、AAC、WAV、FLAC、Ogg：兼容 MP3 保留音轨，其余转 AAC/M4A，生成真实波形；App 0.6.17 起可播放上传音频。每链接 10 次/分钟、60 个/24 小时，每来源 30 次/分钟，队列最多 20 个。失败上传计入配额；未发布资源 24 小时后清理。上传不保证幂等。","parameters":[{"name":"kind","in":"query","required":true,"schema":{"type":"string","enum":["image","video","audio"]}}],"requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"responses":{"202":{"description":"上传已接受；需轮询 ready 后发送","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Upload"}}}},"default":{"description":"请求失败；error 给出原因","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/push/uploads/{id}":{"get":{"operationId":"getUploadStatus","summary":"查询本链接资源的转换状态","description":"每链接每分钟 60 次，建议间隔 2 秒。未知或其他链接资源返回 404。撤销或停用返回 401；重置后的新密钥继承本链接资源。","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"资源状态，失败时 error 给出原因","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Upload"}}}},"default":{"description":"请求失败；error 给出原因","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/v1/messages/{message_id}/share":{"post":{"operationId":"createMediaShare","summary":"设备分享自己收到的音乐或视频","description":"链接长期有效，重复请求复用仍有效的链接。可主动撤销；删除消息、资源或停用设备后失效。公开播放不影响送达或阅读回执。","security":[{"DeviceSession":[]}],"parameters":[{"name":"message_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","maxProperties":0}}}},"responses":{"200":{"description":"独立的公开播放链接","content":{"application/json":{"schema":{"type":"object","required":["url","expires_at"],"properties":{"url":{"type":"string","format":"uri"},"expires_at":{"type":["string","null"],"format":"date-time","description":"当前返回 null，表示不设到期时间。"}}}}}},"401":{"description":"设备未授权"},"404":{"description":"消息不存在、不属于当前用户或不是可分享媒体"},"429":{"description":"每个设备每分钟最多 30 次"}}}},"/api/v1/messages/{message_id}/share/revoke":{"post":{"operationId":"revokeMediaShare","summary":"撤销此设备为该消息生成的分享链接","security":[{"DeviceSession":[]}],"parameters":[{"name":"message_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","maxProperties":0}}}},"responses":{"200":{"description":"已撤销"},"401":{"description":"设备未授权"}}}}}}