{"openapi":"3.1.0","info":{"title":"Maintenance Mate Attachments API","version":"0.1.0"},"paths":{"/attachments":{"post":{"summary":"Upload Attachment","description":"Upload a file. At most one of log_entry_id / note_id / todo_id /\nsystem_id may be set; none of the four means a boat-level manual.","operationId":"upload_attachment_attachments_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_attachment_attachments_post"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/attachments/{log_entry_id}":{"get":{"summary":"List Attachments","description":"List all attachments for a log entry.","operationId":"list_attachments_attachments__log_entry_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"log_entry_id","in":"path","required":true,"schema":{"type":"string","title":"Log Entry Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/note/{note_id}":{"get":{"summary":"List Note Attachments","description":"List all attachments for a note.","operationId":"list_note_attachments_attachments_note__note_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"string","title":"Note Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/todo/{todo_id}":{"get":{"summary":"List Todo Attachments","description":"List all attachments for a to-do.","operationId":"list_todo_attachments_attachments_todo__todo_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"todo_id","in":"path","required":true,"schema":{"type":"string","title":"Todo Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/boat/{boat_id}":{"get":{"summary":"List Boat Manuals","description":"List boat-level manuals (i.e. not tied to a specific system, real or suggested).","operationId":"list_boat_manuals_attachments_boat__boat_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/boat/{boat_id}/system-manuals":{"get":{"summary":"List Boat System Manuals","description":"List manuals attached to ANY system of this boat — real or suggested —\nall in one query.\n\nLets the systems list show each system's manual links directly on its card\n(issue #185) without a per-system request; the client groups the flat list\nby system_id itself. Suggested systems (system_candidate_id, migration 049)\ncome back on the same list so their cards can show the same links without a\nsecond request; the client groups those by system_candidate_id.","operationId":"list_boat_system_manuals_attachments_boat__boat_id__system_manuals_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/system/{system_id}":{"get":{"summary":"List System Manuals","description":"List manuals attached to a specific system.","operationId":"list_system_manuals_attachments_system__system_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"system_id","in":"path","required":true,"schema":{"type":"string","title":"System Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/boats/{boat_id}/manuals/search":{"post":{"summary":"Search Web For Manuals","description":"Kick off the manual web-search workflow for this boat (fire-and-forget).\n\nReturns 202 with a run id; poll GET /manuals/search/{run_id} for progress.\n\nonboarding=true: this search belongs to the boat's guided-setup flow — the\nboat_onboarding row (migration 052) is stamped 'searching' with the run id\nserver-side, so the flow's state is durable even if the triggering device\ndies before its own PowerSync write syncs, and every other device's modal\nfollows the run. The plain \"Search web\" button doesn't pass it, so a\nnon-onboarding search never touches the row. Onboarding searches are also\ngated by the flow-run limits (one successful flow / two attempts per boat\n— see _gate_onboarding_attempt).\n\nA NON-onboarding search is available to the AI_TESTING_USER account only:\nregular users reach the boat-level search exclusively through the guided\nsetup flow, whose limits are enforced above — an unlimited side door would\ndefeat them. The client hides the \"Search web\" button for everyone else\n(GET /me), so a 403 here only meets direct API calls.","operationId":"search_web_for_manuals_boats__boat_id__manuals_search_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}},{"name":"onboarding","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Onboarding"}}],"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/systems/{system_id}/manuals/search":{"post":{"summary":"Search Web For System Manuals","description":"Kick off the manual web-search workflow for a single system's own\nequipment (engine, generator, chartplotter, ...) — issue #189. Mirrors\nPOST /boats/{boat_id}/manuals/search (fire-and-forget, 202 + run id),\njust scoped to one system's `search_manuals` `target` instead of the\nwhole boat.\n\nReturns 202 with a run id; poll GET /manuals/search/{run_id} for progress\n(shared with the boat-level search — the poll endpoint is owner-agnostic).\n\nAvailable to the AI_TESTING_USER account only — for regular users,\nper-system searches run exclusively inside the accepted-manual chain /\nonboarding flow, whose limits are enforced at their own triggers. (The\nworkflow's internal chained searches don't go through this endpoint, so\nthey are unaffected.) The client hides the \"Search web\" button for\neveryone else (GET /me).","operationId":"search_web_for_system_manuals_systems__system_id__manuals_search_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"system_id","in":"path","required":true,"schema":{"type":"string","title":"System Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/manuals/search/{run_id}":{"get":{"summary":"Get Manual Search Run","description":"Poll a manual-search workflow run. Returns status and, once done, the\nrun's {found, saved, skipped} summary. `done` is a convenience flag for the\nclient so it doesn't have to know the full status vocabulary.\n\nNote: run ids are opaque and unguessable, and the summary is just counts +\nalready-owned manual metadata, so this only requires authentication rather\nthan re-deriving boat ownership from the run — the authoritative,\naccess-controlled manuals list is refetched separately once `done`.","operationId":"get_manual_search_run_manuals_search__run_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"string","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/scan":{"post":{"summary":"Scan Manual","description":"Kick off the manual extraction workflow (Docling convert + Claude table\nclassification) for this manual — issue #91 \"Scaffolding Tasks\" extraction\nprocess, triggered from the \"Scan manual\" button next to a manual.\n\nWith chain=true (boat-level manuals only), runs process_accepted_manual\ninstead of a plain scan — the same scan followed by per-system manual\nsearches and their extractions, exactly what accepting a candidate via\n/select starts. Used by the onboarding flow's upload path so an uploaded\nmanual drives the full setup chain.\n\nReturns 202 with a run id; poll GET /manuals/scan/{run_id} for progress.\nResults land in extraction_runs/manual_sections/manual_extraction_items\n(browsable in the admin app's /extractions view) — this endpoint doesn't\nreturn them directly.","operationId":"scan_manual_attachments_item__attachment_id__scan_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}},{"name":"chain","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Chain"}},{"name":"onboarding","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Onboarding"}}],"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/manuals/scan/{run_id}":{"get":{"summary":"Get Manual Scan Run","description":"Poll a manual-scan workflow run. Mirrors GET /manuals/search/{run_id} —\nsee that endpoint's docstring for why this only requires authentication\nrather than re-deriving boat ownership from the run id.","operationId":"get_manual_scan_run_manuals_scan__run_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"string","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/me":{"get":{"summary":"Get Me","description":"The caller's identity plus server-side account flags the client can't\nderive itself. `ai_testing_user`: whether this account is the designated\nAI-testing account (AI_TESTING_USER env var) — the client uses it to show\nthe testing-only \"Search web\" buttons (ManualsSection), which are hidden\nfor everyone else; the search triggers 403 non-testing callers regardless,\nso this is presentation, not enforcement.","operationId":"get_me_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"HTTPBearer":[]}]}},"/active-tasks":{"get":{"summary":"List Active Tasks","description":"List in-flight manual search/scan runs across every boat the caller\nowns — issue #168. A client polls this once on load (see\nuseResumeManualTasks.ts) so a run started on one device resumes polling\non another once loaded there, instead of only ever resuming via this\ndevice's own AsyncStorage.","operationId":"list_active_tasks_active_tasks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"HTTPBearer":[]}]}},"/boats/{boat_id}/onboarding/progress":{"get":{"summary":"Get Onboarding Progress","description":"Read-only aggregate of what the search/extraction pipelines are doing\nfor this boat RIGHT NOW — the onboarding modal's live-progress feed.\n\nThe workflow run payloads (GET /manuals/{search,scan}/{run_id}) only carry\nresults at terminal status, so mid-run visibility has to come from the DB\ntables the workflows already write incrementally: manual_search_runs +\nmanual_search_queries (a batch of query rows lands after each Claude\nround), extraction_runs (status transitions + shards_done per completed\nshard), and manual_entity_candidates (rows trickle in during the extract\nfan-out). This endpoint just reads those; it never writes.\n\n`since` (ISO timestamp, default now-6h) scopes everything to the current\nonboarding session so an old search from last week doesn't pollute the\nfeed. The `phase` field is a server-side convenience roll-up; the client's\nown state machine stays authoritative for its modal lifecycle. Phase\nderivation deliberately does NOT require active_tasks rows —\n_record_active_task is best-effort — falling back to run-table statuses.\n\nThe one write this makes is the flow reconciliation below: a run that died\nwithout reporting leaves the row unfinished forever, and being polled is\nthe only moment anyone looks. It self-limits to rows that have gone quiet\n(see _ONBOARDING_STALE_AFTER), so the common case is still read-only.","operationId":"get_onboarding_progress_boats__boat_id__onboarding_progress_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}},{"name":"since","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Since"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/onboarding/templates/match":{"get":{"summary":"Match Onboarding Template","description":"The published onboarding template matching an asset's details, if any\n— `{\"template\": null}` otherwise (the AI testing account is also matched\nagainst drafts, see _template_statuses). Deliberately takes the details\nrather than a boat id: the boat the modal is checking for was just\ncreated as a local PowerSync insert and may not have reached Postgres\nyet.","operationId":"match_onboarding_template_onboarding_templates_match_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"}},{"name":"manufacturer","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Manufacturer"}},{"name":"model","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model"}},{"name":"year","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Year"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/boats/{boat_id}/onboarding/template/apply":{"post":{"summary":"Apply Onboarding Template","description":"Seed the boat from a published template: its systems, parts and\nmaintenance as PENDING entity suggestions (reviewed and promoted through\nthe exact same path an AI extraction's are), copies of its manuals as the\nboat's own manuals (scoped to the seeded system suggestion where the\ntemplate scoped them — the 056 hand-over trigger re-points them when the\nsuggestion is promoted), and the onboarding flow landed on 'done'.\n\nIdempotent: candidates dedupe on uq_mec_dedup and manuals on the\ncontent-addressed attachment index, so a retry adds nothing twice. 403\nuntil the boat has synced (the client retries), 404 for an unpublished\ntemplate (a draft counts as published for the AI testing account, see\n_template_statuses), 409 for one that isn't this boat's make/model.","operationId":"apply_onboarding_template_boats__boat_id__onboarding_template_apply_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplyTemplateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/review":{"post":{"summary":"Review Manual","description":"Accept or reject a (typically web-search-generated) manual, optionally\nwith feedback on what could be better — issue #91 \"Other notes\" #4.","operationId":"review_manual_attachments_item__attachment_id__review_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_review_manual_attachments_item__attachment_id__review_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/select":{"post":{"summary":"Select Manual Candidate","description":"Keep this candidate and discard its rivals.\n\nMarks it accepted, then deletes every OTHER still-pending web_search manual\nof the same type for the same owner (boat, or the same system). Returns the\nkept manual plus the ids that were deleted so the client can drop them from\nits list without a refetch.\n\nAccepting a TOP-LEVEL (whole-vessel) manual also kicks off the chained\npipeline — extract it, then search for manuals for each system that\nextraction surfaces with a manufacturer and model, extracting those in turn\n(workflows/main.py's process_accepted_manual). `run_id` comes back with the\nresponse so the client can follow it in the task banner; it is null when\nthe chain wasn't started (a system-scoped manual, or the workflow service\nbeing unreachable — a failure to start the follow-up must not fail the\naccept the owner just made).","operationId":"select_manual_candidate_attachments_item__attachment_id__select_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}}],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_select_manual_candidate_attachments_item__attachment_id__select_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/discard":{"post":{"summary":"Discard Manual Candidate","description":"Reject ONE candidate: archive its feedback, then delete it. Its rivals\nare untouched, so the owner can keep reviewing the rest of the group.","operationId":"discard_manual_candidate_attachments_item__attachment_id__discard_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}}],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_discard_manual_candidate_attachments_item__attachment_id__discard_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/manual-entity-candidates/{candidate_id}/review":{"post":{"summary":"Review Entity Candidate","description":"Accept or reject one extracted entity candidate, optionally with feedback —\nmirrors the manual review endpoint. Accepting does NOT create the entity yet;\nthat happens on the boat-wide apply/promote call below.","operationId":"review_entity_candidate_manual_entity_candidates__candidate_id__review_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"candidate_id","in":"path","required":true,"schema":{"type":"string","title":"Candidate Id"}}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_review_entity_candidate_manual_entity_candidates__candidate_id__review_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/boats/{boat_id}/manual-entity-candidates/apply":{"post":{"summary":"Apply Entity Candidates","description":"Promote every accepted, not-yet-promoted candidate for this boat into the\nreal systems/parts/routine_maintenance tables — one transaction, in\ndependency order (systems → parts → routine_maintenance + its parts).\n\nIdempotent: the `promoted_entity_id IS NULL` guard + existing-entity dedup by\nnormalized name/part-number mean re-running never double-creates. Parts are\nboat-level (no system). A maintenance task whose owning system can't be\nresolved (no system name at all) is skipped and reported rather than\nmis-filed.","operationId":"apply_entity_candidates_boats__boat_id__manual_entity_candidates_apply_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/download":{"get":{"summary":"Download Attachment","description":"Stream a file (attachment or manual) from Render Object Storage to the client.","operationId":"download_attachment_attachments_item__attachment_id__download_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}},{"name":"access_token","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Bearer token as query param (for browser downloads)","title":"Access Token"},"description":"Bearer token as query param (for browser downloads)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}/thumbnail":{"get":{"summary":"Thumbnail Attachment","description":"Stream the small JPEG thumbnail for an attachment or manual (inline).","operationId":"thumbnail_attachment_attachments_item__attachment_id__thumbnail_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}},{"name":"access_token","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Bearer token as query param (for browser downloads)","title":"Access Token"},"description":"Bearer token as query param (for browser downloads)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/file/{attachment_id}/{filename}":{"get":{"summary":"Serve Attachment File Cached","description":"Serve an attachment file with Cache-Control: public so Render's edge CDN can cache it.\n\nURL format: /file/{attachment_id}/{token}.{ext}\nThe token is a daily-rotating HMAC signed by ATTACHMENT_SIGNING_SECRET.\nNo Authorization header is required — the signed token is the credential.","operationId":"serve_attachment_file_cached_file__attachment_id___filename__get","parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}},{"name":"filename","in":"path","required":true,"schema":{"type":"string","title":"Filename"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/thumb/{attachment_id}/{filename}":{"get":{"summary":"Serve Thumbnail Cached","description":"Serve a thumbnail with Cache-Control: public so Render's edge CDN can cache it.\n\nURL format: /thumb/{attachment_id}/{token}.jpg\nThe token is a daily-rotating HMAC signed by ATTACHMENT_SIGNING_SECRET.\nNo Authorization header is required — the signed token is the credential.","operationId":"serve_thumbnail_cached_thumb__attachment_id___filename__get","parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}},{"name":"filename","in":"path","required":true,"schema":{"type":"string","title":"Filename"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/attachments/item/{attachment_id}":{"delete":{"summary":"Delete Attachment","description":"Delete an attachment or manual from storage and the database.\n\nStorage may be content-addressed (manuals — see the module-level comment\nabove the Routes section), so another row can point at the exact same\nobject. Only delete from storage if no other row still references it.","operationId":"delete_attachment_attachments_item__attachment_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"attachment_id","in":"path","required":true,"schema":{"type":"string","title":"Attachment Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/log-entries/{log_entry_id}/attachments":{"delete":{"summary":"Delete Log Entry Attachments","operationId":"delete_log_entry_attachments_log_entries__log_entry_id__attachments_delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"log_entry_id","in":"path","required":true,"schema":{"type":"string","title":"Log Entry Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/notes/{note_id}/attachments":{"delete":{"summary":"Delete Note Attachments","operationId":"delete_note_attachments_notes__note_id__attachments_delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"note_id","in":"path","required":true,"schema":{"type":"string","title":"Note Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/todos/{todo_id}/attachments":{"delete":{"summary":"Delete Todo Attachments","operationId":"delete_todo_attachments_todos__todo_id__attachments_delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"todo_id","in":"path","required":true,"schema":{"type":"string","title":"Todo Id"}},{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/boats/{boat_id}/attachments":{"delete":{"summary":"Delete Boat Attachments","description":"Delete all attachments and manuals (storage objects + DB rows) for a boat.\n\nCalled before cascade-deleting a boat so that orphaned objects are not left\nin Render Object Storage. Storage deletions are best-effort — individual\nfailures are logged but do not abort the request. Unlike\n_bulk_delete_attachments, this scope can include manuals, whose storage may\nbe content-addressed and shared across rows (e.g. a boat-level manual and a\nsystem manual on the same boat with identical content) — dedupe by\nstorage_key so a shared object is only deleted once.\n\nA manual key is `manuals/{sha256}{ext}` with no boat in it, so the same\nobject is also shared across BOATS — including boats belonging to other\nusers. Deleting it here would strand their still-live attachments row on a\nmissing object, so keys still referenced from outside this boat are skipped,\nsame rule as _delete_attachment_row's per-row guard. This boat's rows are\ndeleted either way.","operationId":"delete_boat_attachments_boats__boat_id__attachments_delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"path","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/billing":{"get":{"summary":"Get Billing","description":"The caller's entitlements. The first call for an account creates its\nrow — i.e. starts the 30-day trial — so the client calls this at launch.","operationId":"get_billing_billing_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"HTTPBearer":[]}]}},"/billing/checkout":{"post":{"summary":"Create Checkout Session","description":"Start the subscription on Stripe's hosted Checkout page: the $6/month\nbase line (3 items) plus, when `addon_packs` > 0, the \"3 more items\" line\nat $4/month per pack with Stripe's own quantity picker enabled. Returns\n`{url, kind: \"checkout\"}`; the client navigates to it (web) or opens it in\nthe system browser (native). Billing anchors to the checkout date, so the\nrenewal lands on that day each month with no proration involved. Already\nsubscribed → 409; add-on changes go through POST /billing/addons.","operationId":"create_checkout_session_billing_checkout_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/billing/addons":{"post":{"summary":"Set Addon Packs","description":"Set the number of \"3 more items\" packs on the existing subscription.\n\nApplied directly on the Stripe subscription with `proration_behavior=\n\"none\"`: the new cap is effective immediately and the new monthly amount\nbills from the next renewal — never a partial-month charge or credit (the\nCustomer Portal can't add a NEW line to a subscription, which is why this\nisn't a portal flow). Refuses to drop below the items the account already\nmaintains unless an admin override covers them. Returns the fresh\nentitlements plus `kind: \"updated\"`.","operationId":"set_addon_packs_billing_addons_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonsRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/billing/portal":{"post":{"summary":"Create Portal Session","description":"Open Stripe's hosted Customer Portal (update card, invoices, cancel at\nperiod end). Requires the portal to be activated once in the Stripe\nDashboard (Settings → Billing → Customer portal) — see BILLING_SETUP.md.","operationId":"create_portal_session_billing_portal_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/billing/refresh":{"post":{"summary":"Refresh Billing","description":"Re-read the subscription from Stripe, then return entitlements. The\nclient calls this when it comes back from Checkout/the Portal, so a\nlagging (or unconfigured) webhook never strands a paying user.","operationId":"refresh_billing_billing_refresh_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"HTTPBearer":[]}]}},"/billing/return":{"get":{"summary":"Billing Return","description":"No-auth landing page for the NATIVE app's Checkout/Portal round trip:\nStripe redirects here, and this page deep-links straight back into the app\n(maintenance-mate://account?checkout=...). Nothing sensitive is shown or\ntrusted — the app re-reads its entitlements from /billing/refresh.","operationId":"billing_return_billing_return_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","default":"success","title":"Status"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/stripe/webhook":{"post":{"summary":"Stripe Webhook","description":"Stripe → user_billing. No JWT — authenticity comes from the signature\nover the RAW body (read it before anything parses it). Every handler\nre-retrieves the subscription from Stripe rather than trusting the event\npayload, so delivery order across our two workers doesn't matter and a\nreplayed event is a no-op.","operationId":"stripe_webhook_stripe_webhook_post","parameters":[{"name":"Stripe-Signature","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stripe-Signature"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/push-tokens":{"post":{"summary":"Register Push Token","description":"Register (or re-point) a device's Expo push token for the calling user.\n\nUpserts on the token itself: a device re-registering under a different\naccount moves the row to that account, so pushes never go to a previous\nowner of a shared device. The tokens are read by the boat-scaffolding\nworkflow to send onboarding-flow notifications (workflows/push.py);\ndead tokens are pruned there when Expo reports DeviceNotRegistered.","operationId":"register_push_token_push_tokens_post","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_register_push_token_push_tokens_post"}}},"required":true},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/push-tokens/test":{"post":{"summary":"Send Test Push","description":"Schedule a test push to every device the calling user has registered —\ndelayed (default 10 s) so they can background the app first, since the\nclient deliberately shows no foreground notifications. Exercises the real\ndelivery path (push_tokens → Expo push API → APNs/FCM), unlike a local\nnotification. Self-serve only: a caller can never push to another account.","operationId":"send_test_push_push_tokens_test_post","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_send_test_push_push_tokens_test_post"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/calendar/subscriptions":{"post":{"summary":"Create Calendar Subscription","description":"Create a new calendar subscription for a boat.","operationId":"create_calendar_subscription_calendar_subscriptions_post","security":[{"HTTPBearer":[]}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_create_calendar_subscription_calendar_subscriptions_post"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"summary":"List Calendar Subscriptions","description":"List calendar subscriptions for a boat.","operationId":"list_calendar_subscriptions_calendar_subscriptions_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"boat_id","in":"query","required":true,"schema":{"type":"string","title":"Boat Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/calendar/subscriptions/{subscription_id}":{"delete":{"summary":"Delete Calendar Subscription","description":"Delete a calendar subscription.","operationId":"delete_calendar_subscription_calendar_subscriptions__subscription_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"subscription_id","in":"path","required":true,"schema":{"type":"string","title":"Subscription Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/calendar/{subscription_id}.ics":{"get":{"summary":"Get Calendar Feed","description":"Stream an iCalendar (.ics) feed for a boat's maintenance history and schedule.\nNo authentication required — the subscription_id is the secret token.","operationId":"get_calendar_feed_calendar__subscription_id__ics_get","parameters":[{"name":"subscription_id","in":"path","required":true,"schema":{"type":"string","title":"Subscription Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AddonsRequest":{"properties":{"packs":{"type":"integer","title":"Packs"}},"type":"object","required":["packs"],"title":"AddonsRequest"},"ApplyTemplateRequest":{"properties":{"template_id":{"type":"string","title":"Template Id"}},"type":"object","required":["template_id"],"title":"ApplyTemplateRequest"},"Body_create_calendar_subscription_calendar_subscriptions_post":{"properties":{"boat_id":{"type":"string","title":"Boat Id"}},"type":"object","required":["boat_id"],"title":"Body_create_calendar_subscription_calendar_subscriptions_post"},"Body_discard_manual_candidate_attachments_item__attachment_id__discard_post":{"properties":{"feedback":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Feedback"}},"type":"object","title":"Body_discard_manual_candidate_attachments_item__attachment_id__discard_post"},"Body_register_push_token_push_tokens_post":{"properties":{"token":{"type":"string","title":"Token"},"platform":{"type":"string","title":"Platform","default":""}},"type":"object","required":["token"],"title":"Body_register_push_token_push_tokens_post"},"Body_review_entity_candidate_manual_entity_candidates__candidate_id__review_post":{"properties":{"review_status":{"type":"string","title":"Review Status"},"feedback":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Feedback"},"feedback_batch_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Feedback Batch Id"}},"type":"object","required":["review_status"],"title":"Body_review_entity_candidate_manual_entity_candidates__candidate_id__review_post"},"Body_review_manual_attachments_item__attachment_id__review_post":{"properties":{"review_status":{"type":"string","title":"Review Status"},"feedback":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Feedback"}},"type":"object","required":["review_status"],"title":"Body_review_manual_attachments_item__attachment_id__review_post"},"Body_select_manual_candidate_attachments_item__attachment_id__select_post":{"properties":{"feedback":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Feedback"}},"type":"object","title":"Body_select_manual_candidate_attachments_item__attachment_id__select_post"},"Body_send_test_push_push_tokens_test_post":{"properties":{"delay_seconds":{"type":"number","title":"Delay Seconds","default":10}},"type":"object","title":"Body_send_test_push_push_tokens_test_post"},"Body_upload_attachment_attachments_post":{"properties":{"boat_id":{"type":"string","title":"Boat Id"},"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"},"log_entry_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Log Entry Id"},"note_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note Id"},"todo_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Todo Id"},"system_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"System Id"}},"type":"object","required":["boat_id","file"],"title":"Body_upload_attachment_attachments_post"},"CheckoutRequest":{"properties":{"email":{"type":"string","title":"Email","default":""},"platform":{"type":"string","title":"Platform","default":"web"},"addon_packs":{"type":"integer","title":"Addon Packs","default":0}},"type":"object","title":"CheckoutRequest"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"PortalRequest":{"properties":{"platform":{"type":"string","title":"Platform","default":"web"}},"type":"object","title":"PortalRequest"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}