# SearchWork API AI-powered UK graduate job tracker. All endpoints require a Bearer token in the Authorization header unless noted. ## Authentication POST /auth/register Body: {"email": "string", "password": "string (min 8 chars)"} Response: {"access_token": "string", "token_type": "bearer"} Sets httpOnly refresh_token cookie. POST /auth/login Body: {"email": "string", "password": "string"} Response: {"access_token": "string", "token_type": "bearer"} Sets httpOnly refresh_token cookie. POST /auth/refresh (no Bearer required — uses refresh_token cookie) Response: {"access_token": "string", "token_type": "bearer"} Rotates the refresh token. POST /auth/logout (no Bearer required — uses refresh_token cookie) Response: 204 No Content Invalidates the refresh token. GET /auth/me Response: {"id": int, "email": "string"} GET /auth/google/url (no Bearer required) Response: {"url": "string"} — redirect the user here to start Google OAuth. GET /auth/google/callback?code=&state= Exchanges the OAuth code, creates/links the user account, redirects to {FRONTEND_URL}/auth/callback?access_token= with refresh_token cookie set. ## CV GET /cv Response: CVProfile object or null if no CV uploaded yet. CVProfile: {"id": int, "skills": [str], "job_titles": [str], "keywords": [str], "updated_at": "ISO datetime"} POST /cv (multipart/form-data, field: "file") Accepts PDF or plain text. Extracts skills, job titles, and keywords via Claude AI. Response: CVProfile POST /cv/review Body: {"target_role": "string"} Response: {"strengths": [str], "gaps": [str], "suggestions": [str], "overall": "string"} POST /cv/cover-letter Body: {"external_id": "string", "source": "string", "job_title": "string", "company": "string", "description": "string", "force_regenerate": bool} Returns cached letter if one exists for (user, external_id, source) unless force_regenerate=true. Response: {"content": "string"} ## Jobs GET /jobs?q=&locations=&locations= Rate limited: 10/minute per IP. Searches Adzuna, Reed, JSearch, Remotive, WeWorkRemotely, Jobicy, Arbeitnow, Gradcracker, Totaljobs, CWJobs, Prospects in parallel. Small towns (Dumfries, Carlisle) are searched with a 40-mile radius on Adzuna/Reed; other cities use each API's default radius. Filters to UK-only, junior-level, no security clearance. Scores each job against CV skills via Claude AI. Response: list of JobSearchResult, sorted by match_score descending. JobSearchResult: {"external_id": str, "source": str, "title": str, "company": str, "location": str, "salary_min": int|null, "salary_max": int|null, "url": str, "description": str, "match_score": int (0-100), "matched_skills": [str], "missing_skills": [str]} ## Applications GET /applications Response: list of Application (with nested job object), ordered by updated_at desc. Application: {"id": int, "status": str, "applied_at": str|null, "job": JobSearchResult} Status values: saved | in_progress | applied | interview | offer | rejected POST /applications Body: {"job": JobSearchResult, "status": "string"} Creates a SavedJob record if not already saved, then creates an Application. Returns 409 if application already exists for this job. Response: Application PATCH /applications/{app_id} Body: {"status": "string"} Updates application status. Sets applied_at when status becomes "applied". Response: Application DELETE /applications/{app_id} Response: 204 No Content ## Job alerts Push notifications through ntfy (https://ntfy.sh) for new jobs that match the user's CV. A background scan re-runs each enabled user's search every ALERT_SCAN_INTERVAL_HOURS (default 6), scores only jobs it has not seen before and pushes those with match_score >= min_score (top 5 individually, plus one "+N more" push). The first scan only records current jobs, no pushes. Users without an uploaded CV are skipped. GET /alerts Response: AlertSettings object or null if never saved. AlertSettings: {"enabled": bool, "query": str, "locations": [str], "min_score": int (0-100), "ntfy_topic": str, "last_scan_at": "ISO datetime"|null} PUT /alerts Body: {"enabled": bool, "query": str (1-200 chars), "locations": [str] (max 10, empty = default cities), "min_score": int (0-100), "ntfy_topic": str (8-64 chars of A-Z a-z 0-9 _ -)} Creates or replaces the user's settings. Response: AlertSettings. 422 on invalid input (validation errors do not echo submitted values). Each location is at most 100 chars. Changing query or locations restarts the silent first-scan baseline. POST /alerts/test Rate limited: 3/minute per IP. Sends one "SearchWork test" push to the user's topic. Response: 204 No Content. 404 if no settings saved, 502 if ntfy cannot be reached. ## Utility GET / Response: {"status": "ok"} GET /health Response: {"status": "ok"} GET /llms.txt Response: this document (text/plain)