# Reset Relay

> Real-time AI quota reset monitor and standardized notification relay built on Cloudflare Workers & D1. Tracks quota reset events across 8 AI platforms and delivers verified Standard Webhooks (HMAC-SHA256), native team-chat bots, REST JSON, Atom 1.0, and JSON Feed 1.1.

## Machine-Readable Endpoints

- [Full Documentation & Live Snapshot](https://reset.damue.fun/llms-full.txt): Complete protocol reference, all 10 official channel setup guides (including QQ Official Bot v2 API), HMAC verification code, and latest reset events.
- [OpenAPI 3.1 Specification](https://reset.damue.fun/api/v1/openapi.json): Machine-readable HTTP API schema.
- [Global Status & Health](https://reset.damue.fun/api/v1/status): Aggregate metrics, Codex snapshot, and upstream source health.
- [Normalized Event Stream](https://reset.damue.fun/api/v1/events): Query reset events (`?vendor=<id>&type=<type>&since=<iso>&limit=30`).
- [Monitored Platforms Directory](https://reset.damue.fun/api/v1/vendors): All supported AI platforms with latest reset record.
- [Atom 1.0 Feed (All)](https://reset.damue.fun/feeds/all.xml): Zero-config XML feed (replace `all` with any vendor ID).
- [JSON Feed 1.1 (All)](https://reset.damue.fun/feeds/all.json): Zero-config JSON feed (replace `all` with any vendor ID).
- [Health Check](https://reset.damue.fun/api/v1/health): Operational status and per-source poll telemetry.

## Monitored AI Platforms (`vendor` IDs)

- `openai`: OpenAI Codex
- `google`: Google Gemini
- `anthropic`: Anthropic Claude
- `moonshot`: 月之暗面 Kimi
- `deepseek`: DeepSeek
- `zhipu`: 智谱 GLM
- `xai`: xAI Grok
- `qoder`: Qoder

## Supported Native Webhook Formats (`POST /api/v1/webhooks`)

- `feishu`: 飞书群机器人 — 原生交互卡片，支持签名校验密钥
- `standard`: Standard Webhooks (JSON) — 标准 JSON + HMAC-SHA256 签名请求头
- `dingtalk`: 钉钉机器人 — 钉钉 Markdown 通知消息
- `wecom`: 企业微信机器人 — 企业微信 Markdown 群消息
- `telegram`: Telegram 官方 Bot — Telegram Bot API sendMessage（URL 需附 ?chat_id=...）
- `discord`: Discord Webhook — Discord Embed 通知卡片
- `slack`: Slack Webhook — Slack Block Kit 消息
- `bark`: Bark (iOS 推送) — 官方 APNs 推送，支持自建 Bark 服务
- `qq` (via `standard`): Tencent QQ Official Bot (`q.qq.com`) via Standard Webhooks relay to `POST https://bots.qq.com/app/getAppAccessToken` + `POST https://api.sgroup.qq.com/v2/groups/{group_openid}/messages`.
- `atom` / `json-feed`: Zero-config pull subscriptions at `/feeds/{vendor}.xml` and `/feeds/{vendor}.json`.

## Quick Start for AI Agents

1. Poll latest resets: `GET https://reset.damue.fun/api/v1/events?limit=20`
2. Subscribe via self-service Webhook:
   `POST https://reset.damue.fun/api/v1/webhooks` with JSON `{"url":"https://...","format":"standard","vendors":["openai","anthropic"]}`
   Returns one-time `signing_secret` (`whsec_...`) and `manage_token` (`whm_...`).
3. Verify incoming webhook signatures using Standard Webhooks headers:
   `webhook-id`, `webhook-timestamp`, `webhook-signature` (`v1,<base64(HMAC-SHA256(key, id + "." + ts + "." + rawBody))>`).
4. Manage or test an existing subscription with `Authorization: Bearer <whm_token>`:
   - `POST https://reset.damue.fun/api/v1/webhooks/{id}/test`
   - `GET https://reset.damue.fun/api/v1/webhooks/{id}/deliveries`
   - `PATCH https://reset.damue.fun/api/v1/webhooks/{id}`
   - `DELETE https://reset.damue.fun/api/v1/webhooks/{id}`
