@@ -51,6 +51,142 @@ authenticating PAT. |
| 51 | 51 | |
| 52 | 52 | > **Planned.** `GET /api/v1/user/repos` is not shipped yet. |
| 53 | 53 | |
| 54 | +## Email addresses |
| 55 | + |
| 56 | +### List the authenticated user's emails |
| 57 | + |
| 58 | +``` |
| 59 | +GET /api/v1/user/emails |
| 60 | +``` |
| 61 | + |
| 62 | +Required scope: `user:read`. |
| 63 | + |
| 64 | +Returns every email address attached to the authenticating user. |
| 65 | +Use `?verified=true` (or `?verified=false`) to filter to a single |
| 66 | +verification state. Omit the query parameter to list both. |
| 67 | + |
| 68 | +#### Response |
| 69 | + |
| 70 | +```json |
| 71 | +[ |
| 72 | + { |
| 73 | + "id": 7, |
| 74 | + "email": "alice+primary@example.test", |
| 75 | + "primary": true, |
| 76 | + "verified": true |
| 77 | + }, |
| 78 | + { |
| 79 | + "id": 8, |
| 80 | + "email": "alice+work@example.test", |
| 81 | + "primary": false, |
| 82 | + "verified": false |
| 83 | + } |
| 84 | +] |
| 85 | +``` |
| 86 | + |
| 87 | +| Field | Type | Notes | |
| 88 | +|------------|--------|---------------------------------------------------| |
| 89 | +| `id` | int64 | Stable per-row id. | |
| 90 | +| `email` | string | The email address as stored. | |
| 91 | +| `primary` | bool | Marks the account's primary delivery address. | |
| 92 | +| `verified` | bool | `true` once a verification link has been clicked. | |
| 93 | + |
| 94 | +#### Errors |
| 95 | + |
| 96 | +| Status | When | |
| 97 | +|-------:|-------------------------------------| |
| 98 | +| 401 | PAT missing/invalid/expired/revoked. | |
| 99 | +| 403 | PAT lacks `user:read` scope. | |
| 100 | + |
| 101 | +> **Planned.** `POST` and `DELETE /api/v1/user/emails` are not |
| 102 | +> shipped yet — use `/settings/account` in the web UI to add or |
| 103 | +> remove addresses for now. |
| 104 | + |
| 105 | +## SSH keys |
| 106 | + |
| 107 | +SSH authentication keys for git-over-SSH. Signing keys live at a |
| 108 | +separate `/user/ssh_signing_keys` surface (not yet shipped). |
| 109 | + |
| 110 | +### List SSH keys |
| 111 | + |
| 112 | +``` |
| 113 | +GET /api/v1/user/keys |
| 114 | +``` |
| 115 | + |
| 116 | +Required scope: `user:read`. |
| 117 | + |
| 118 | +Returns the authenticated user's authentication keys (signing |
| 119 | +keys are not returned here). Paginated via `?per_page=` and |
| 120 | +`?page=`; the response carries the standard `Link:` header. |
| 121 | + |
| 122 | +#### Response |
| 123 | + |
| 124 | +```json |
| 125 | +[ |
| 126 | + { |
| 127 | + "id": 12, |
| 128 | + "title": "laptop", |
| 129 | + "key": "ssh-ed25519 AAAA…", |
| 130 | + "fingerprint": "SHA256:abc…", |
| 131 | + "key_type": "ssh-ed25519", |
| 132 | + "verified": true, |
| 133 | + "read_only": false, |
| 134 | + "created_at": "2026-05-12T04:00:00Z" |
| 135 | + } |
| 136 | +] |
| 137 | +``` |
| 138 | + |
| 139 | +### Get a single SSH key |
| 140 | + |
| 141 | +``` |
| 142 | +GET /api/v1/user/keys/{id} |
| 143 | +``` |
| 144 | + |
| 145 | +Required scope: `user:read`. |
| 146 | + |
| 147 | +404 when the id does not belong to the authenticating user, or |
| 148 | +when it is a signing key (use the signing-key surface). |
| 149 | + |
| 150 | +### Add an SSH key |
| 151 | + |
| 152 | +``` |
| 153 | +POST /api/v1/user/keys |
| 154 | +``` |
| 155 | + |
| 156 | +Required scope: `user:write`. |
| 157 | + |
| 158 | +#### Request body |
| 159 | + |
| 160 | +```json |
| 161 | +{ "title": "laptop", "key": "ssh-ed25519 AAAA…" } |
| 162 | +``` |
| 163 | + |
| 164 | +| Field | Type | Notes | |
| 165 | +|---------|--------|--------------------------------------------------------------------------| |
| 166 | +| `title` | string | 1–80 characters; user-visible label. | |
| 167 | +| `key` | string | The contents of your `.pub` file (no leading comment, no trailing data). | |
| 168 | + |
| 169 | +Returns `201` on success with the same shape as the list endpoint. |
| 170 | + |
| 171 | +#### Errors |
| 172 | + |
| 173 | +| Status | When | |
| 174 | +|-------:|------------------------------------------------------------------------------| |
| 175 | +| 401 | PAT missing/invalid. | |
| 176 | +| 403 | PAT lacks `user:write` scope. | |
| 177 | +| 422 | Title invalid, blob unparseable, key already registered, or per-user cap hit. | |
| 178 | + |
| 179 | +### Delete an SSH key |
| 180 | + |
| 181 | +``` |
| 182 | +DELETE /api/v1/user/keys/{id} |
| 183 | +``` |
| 184 | + |
| 185 | +Required scope: `user:write`. |
| 186 | + |
| 187 | +Returns `204 No Content` on success, `404` when the id does not |
| 188 | +belong to the authenticating user. |
| 189 | + |
| 54 | 190 | ## Stars |
| 55 | 191 | |
| 56 | 192 | The starred-repos surface for the authenticating user. |