@@ -0,0 +1,90 @@ |
| 1 | +# Notifications |
| 2 | + |
| 3 | +User-scoped inbox for the authenticated PAT. Mirrors GitHub's |
| 4 | +`/notifications` API; each "thread" in the GitHub sense maps to |
| 5 | +one row in shithub's `notifications` table. |
| 6 | + |
| 7 | +Scopes: |
| 8 | + |
| 9 | +- `user:read` — list and fetch |
| 10 | +- `user:write` — mark read/unread, mark all read |
| 11 | + |
| 12 | +All endpoints are implicitly scoped to the authenticated user. |
| 13 | +There is no admin-level "read another user's inbox" surface. |
| 14 | + |
| 15 | +## List notifications |
| 16 | + |
| 17 | +``` |
| 18 | +GET /api/v1/notifications[?all=true|false&page=&per_page=] |
| 19 | +``` |
| 20 | + |
| 21 | +- `all` (default `false`) returns **unread only**. Pass |
| 22 | + `all=true` to include read notifications. |
| 23 | +- Standard `page` / `per_page` pagination (per_page ≤ 100, |
| 24 | + default 30). `Link:` headers emit `first`/`prev`/`next`/`last`. |
| 25 | +- Sorted by `last_event_at DESC`. |
| 26 | + |
| 27 | +```json |
| 28 | +[ |
| 29 | + { |
| 30 | + "id": 5142, |
| 31 | + "unread": true, |
| 32 | + "reason": "mention", |
| 33 | + "kind": "issue_comment", |
| 34 | + "updated_at": "2026-05-12T15:00:00Z", |
| 35 | + "last_event_at": "2026-05-12T15:00:00Z", |
| 36 | + "subject": { |
| 37 | + "title": "fix race in fanout worker", |
| 38 | + "type": "issue", |
| 39 | + "number": 42 |
| 40 | + }, |
| 41 | + "repository": { |
| 42 | + "owner_login": "alice", |
| 43 | + "name": "demo", |
| 44 | + "full_name": "alice/demo" |
| 45 | + } |
| 46 | + } |
| 47 | +] |
| 48 | +``` |
| 49 | + |
| 50 | +`subject.type` is one of `issue` / `pull_request`, or empty for |
| 51 | +threadless system notifications. |
| 52 | + |
| 53 | +## Get a single notification |
| 54 | + |
| 55 | +``` |
| 56 | +GET /api/v1/notifications/threads/{id} |
| 57 | +``` |
| 58 | + |
| 59 | +Cross-user probes return 404 (existence-leak guard) so a caller |
| 60 | +can't enumerate other users' notification ids. |
| 61 | + |
| 62 | +## Mark a notification read / unread |
| 63 | + |
| 64 | +```http |
| 65 | +PATCH /api/v1/notifications/threads/5142 |
| 66 | +Content-Type: application/json |
| 67 | + |
| 68 | +{ "unread": false } |
| 69 | +``` |
| 70 | + |
| 71 | +- Empty body or `unread: false` → mark **read** (gh's default). |
| 72 | +- `unread: true` → flip back to unread (shithub extension — |
| 73 | + useful for "I'll come back to this"). |
| 74 | + |
| 75 | +Returns `204 No Content`. |
| 76 | + |
| 77 | +## Mark all read |
| 78 | + |
| 79 | +``` |
| 80 | +PUT /api/v1/notifications |
| 81 | +``` |
| 82 | + |
| 83 | +Returns `204 No Content` once every unread row for the caller |
| 84 | +has been flipped to read. Idempotent. |
| 85 | + |
| 86 | +## Errors |
| 87 | + |
| 88 | +- `404` — notification id doesn't exist, or belongs to another |
| 89 | + user. |
| 90 | +- `403` — PAT lacks the required scope. |