# Spotter training and exam

> Lesson progress for the spotter course, and the certification exam, from checking standing to starting a sitting, saving answers and submitting.

API reference · Reference · https://wxalerts.org/docs/api/training/

Base URL: `https://api.wxalerts.org`

The spotter course is lessons plus a certification exam. These routes record lesson
progress and run the exam. A pass issues a credential, which is on
[Spotter certificates](/docs/api/certificates/). The course itself, and what the
credential is for, are in [Spotter reports](/docs/spotter-reports/) and
[Spotter accounts](/docs/accounts/spotter/).

All routes are signed in, using the app's Bearer token or the site's session cookie.
There is no signed out sitting. A request that carries a cookie needs the
`X-Requested-With: wxalerts` header on the routes marked below. Bearer requests
never need it.

### Errors common to every route

| Status | Body | When |
| --- | --- | --- |
| `401` | `{"detail": "Not signed in."}` or `{"detail": "Session expired."}` | no valid credential |
| `401` | `{"detail": {"code": "api_key_not_accepted", "message": "..."}}` | an API key was used. Keys work on `/v1` reads only |
| `403` | `{"detail": "Missing X-Requested-With header."}` | a cookie write without the header, on routes that require it |
| `403` | `{"detail": {"code": "account_disabled" or "account_deleted", "message": "..."}}` |  |
| `422` | `{"detail": [{"type": "...", "loc": [...], "msg": "...", "input": ...}]}` | the request failed validation. Default format |

## `GET /training/progress`

Signed in. Everything the training pages need about one person. A new account gets
`200` with zeros, never `404`.

### Response

`200`:

| Field | Type | Notes |
| --- | --- | --- |
| `certified` | boolean | the account holds a current credential |
| `certified_until` | string or null | `YYYY-MM-DD`, only while certified |
| `attempts_used` | integer | exam sittings used |
| `modules` | array | one entry per module with completed lessons: `slug`, `lessons_done` (count), `lessons` (array of lesson slugs) |
| `scenarios` | array | continuing education scenarios: `slug`, `state`, `questions_done`, `score`. Currently always empty |

```json
{"certified": false, "certified_until": null, "attempts_used": 0, "modules": [{"slug": "storm-structure", "lessons_done": 2, "lessons": ["inflow", "updrafts"]}], "scenarios": []}
```

The API does not know the syllabus. Module and lesson slugs are stored as sent and
handed back, and the website works out percentages and what is next.

## `POST /training/progress/lessons`

Signed in. Mark a lesson complete. Idempotent: marking a finished lesson again does
nothing. This route does not need the CSRF header.

### Request body (JSON)

| Field | Type | Required | Bounds |
| --- | --- | --- | --- |
| `module` | string | yes | 1 to 64 characters |
| `lesson` | string | yes | 1 to 96 characters |

### Response

`200`:

| Field | Type | Notes |
| --- | --- | --- |
| `module`, `lesson` | string | as sent |
| `created` | boolean | false when it was already complete |
| `lessons_done` | integer | lessons complete in that module |

```json
{"module": "storm-structure", "lesson": "inflow", "created": true, "lessons_done": 1}
```

## `DELETE /training/progress/lessons/{module_slug}/{lesson_slug}`

Signed in. Un-mark a lesson. Silent when it was not marked. Returns `204 No Content`. This route does not need the CSRF header.

### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `module_slug` | path | string | yes |
| `lesson_slug` | path | string | yes |

## The exam

A sitting deals 40 questions from the bank, 10 to a page, in 90 minutes. The pass
mark is 80 percent. An account gets 3 sittings, counted since its last pass, so renewing starts
from a full allowance. A finished sitting, pass or fail, is followed by a 48 hour
cooldown. A credential is good for 12 months and continuing
education extends it. The clock belongs to the server: `expires_at` is absolute, and every response carries `server_time` so a client can work out its offset once.

The answer key never leaves the server, and the same goes for any identifier a
question has in the bank. Questions and choices are addressed by tokens and ids that
mean nothing outside the one attempt. A wrong answer is never revealed, and the
result gives the score and a score per module only.

Every exam response carries `Cache-Control: no-store`, except the picture route.

### The attempt object

| Field | Type | Notes |
| --- | --- | --- |
| `attempt_id` | string |  |
| `started_at`, `expires_at`, `server_time` | string | UTC |
| `seconds_remaining` | integer |  |
| `items_per_page` | integer | 10 |
| `passing_score` | integer | 80 |
| `total` | integer | 40 |
| `state` | string | `open`, `expired` or `submitted` |
| `items` | array | the questions, in order |
| `responses` | array | answers saved so far: `token`, `choice_ids` |
| `flags` | array of string | tokens of questions flagged for review |

Each item has `token` (this attempt's handle for the question), `position`, `module` (a module slug), `kind` (`single` for one answer, `multi` for several), `stem` (the question), `choices` (`id`, `text`, in this attempt's own order) and `media`. `media` is null, a chart (`kind: chart`, `spec`, `caption`) the client draws from the data, or a photograph (`kind: photo`, `url`, `alt`, `caption`, `credit` with `label` and `href`). The `url` is `GET /training/exam/media/{item_token}`. The `alt` text says what is visible and does not name the answer.

## `GET /training/exam/status`

Signed in. Where the account stands, without dealing a sitting. Asking is never what
starts one.

### Response

`200`:

| Field | Type | Notes |
| --- | --- | --- |
| `server_time` | string | UTC |
| `attempt` | object or null | the open sitting: `attempt_id`, `started_at`, `expires_at`, `seconds_remaining`, `answered`, `total`, `state` |
| `attempts_used`, `attempts_remaining`, `attempt_limit` | integer | the limit is 3 |
| `cooldown_until` | string or null | UTC |
| `certified` | boolean |  |
| `certified_until` | string or null | `YYYY-MM-DD` |
| `may_start` | boolean | false while a sitting is open |
| `reason` | string or null | `cooldown` or `exhausted` when `may_start` is false for those reasons |

## `POST /training/exam/attempts`

Signed in, CSRF header for cookie requests. Start a sitting. No request body.

### Response

`201 Created` with the attempt object.

### Errors

| Status | Body | When |
| --- | --- | --- |
| `409` | `{"detail": {"attempt_id": "..."}}` | a sitting is already open. Resume that one |
| `429` | `{"detail": {"reason": "cooldown" or "exhausted", "retry_after": "2026-11-25T19:00:00+00:00", "attempts_used": 1}}` | no sitting may start now. `retry_after` is null when the reason is `exhausted`. Here the time ends in `+00:00` |
| `503` | `{"detail": "The exam item bank is not fully loaded on this deployment."}` |  |

## `GET /training/exam/attempts/{public_id}`

Signed in. Resume an open sitting, or read back a submitted one. Everything needed
to pick up on another device is held on the server.

### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `public_id` | path | string | yes |

### Response

`200` with the attempt object while it has not been submitted, and with the result
object, below, once it has.

### Errors

| Status | Body | When |
| --- | --- | --- |
| `404` | `{"detail": "No such attempt."}` | no such attempt, or it is not yours |

## `GET /training/exam/media/{item_token}`

Signed in. The picture for one dealt question. The path is the per attempt token, so
it names nothing and cannot be guessed. The file carries its type and no filename.

### Response

`200`, an image (`image/webp`, `image/jpeg` or `image/png`), `Cache-Control: private, max-age=600`.

### Errors

| Status | Body | When |
| --- | --- | --- |
| `404` | `{"detail": "No such item."}` | not your token, no picture, or the picture is missing |

## `PATCH /training/exam/attempts/{public_id}/responses`

Signed in, CSRF header for cookie requests. Save progress. Partial, idempotent, last
write wins. Limited to 60 saves a minute with a burst of 20, per attempt.

### Request body (JSON)

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `responses` | array | no | each `token` and `choice_ids` (array of string). An empty `choice_ids` clears the answer. An entry with an unknown token, an unknown choice id, or several choices on a `single` question is skipped |
| `flags` | array of string or null | no | the complete set of flagged tokens, not a change. Null leaves flags alone |

### Response

`200`:

| Field | Type | Notes |
| --- | --- | --- |
| `saved` | integer | entries applied |
| `seconds_remaining` | integer |  |
| `server_time` | string | UTC |

### Errors

| Status | Body | When |
| --- | --- | --- |
| `404` | `{"detail": "No such attempt."}` |  |
| `409` | `{"detail": "This attempt has been submitted."}` |  |
| `410` | `{"detail": "Time is up on this attempt."}` | the clock ran out |
| `429` | `{"detail": "Saving too often. Coalesce changes and retry."}` and `Retry-After` |  |

## `POST /training/exam/attempts/{public_id}/submit`

Signed in, CSRF header for cookie requests. Score the sitting. Idempotent: a second
submit returns the stored result. A submission after the clock ran out is accepted
and scored as of expiry. A pass issues or refreshes the account's credential.

### Response

`200`, the result:

| Field | Type | Notes |
| --- | --- | --- |
| `attempt_id` | string |  |
| `submitted_at` | string | UTC |
| `score_pct` | integer |  |
| `correct`, `total` | integer |  |
| `passed` | boolean |  |
| `passing_score` | integer |  |
| `breakdown` | array | per module in teaching order: `module`, `correct`, `total`. The most specific feedback given |
| `attempts_used`, `attempts_remaining` | integer |  |
| `cooldown_until` | string or null | UTC |
| `certified` | boolean |  |
| `certified_until` | string or null | `YYYY-MM-DD` |
| `state` | string | `submitted` |

```json
{"attempt_id": "ex_k3j9", "submitted_at": "2026-11-23T20:30:00Z", "score_pct": 85, "correct": 34, "total": 40, "passed": true, "passing_score": 80, "breakdown": [{"module": "storm-structure", "correct": 9, "total": 10}], "attempts_used": 1, "attempts_remaining": 2, "cooldown_until": null, "certified": true, "certified_until": "2027-11-23", "state": "submitted"}
```

### Errors

`404` with `No such attempt.`
