openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: TrustField API — trust-scoring engine for crowdsourced field reports servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: reports description: Field reports - name: admin description: Admin operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/user: get: operationId: getCurrentAuthUser tags: [auth] summary: Get current authenticated user parameters: - $ref: "#/components/parameters/AuthorizationSessionHeader" - $ref: "#/components/parameters/SessionCookie" responses: "200": description: Current auth state content: application/json: schema: $ref: "#/components/schemas/AuthUserEnvelope" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /login: get: operationId: beginBrowserLogin tags: [auth] summary: Start the browser OIDC login flow parameters: - name: returnTo in: query required: false schema: type: string responses: "302": description: Redirect to the OIDC authorization endpoint. /callback: get: operationId: handleBrowserLoginCallback tags: [auth] summary: Complete the browser OIDC login flow parameters: - name: code in: query required: false schema: type: string - name: state in: query required: false schema: type: string responses: "302": description: Redirect to returnTo path on success or /api/login on failure. /logout: get: operationId: logoutBrowserSession tags: [auth] summary: Clear the session and begin OIDC logout parameters: - $ref: "#/components/parameters/AuthorizationSessionHeader" - $ref: "#/components/parameters/SessionCookie" responses: "302": description: Redirect to OIDC provider logout URL. /mobile-auth/token-exchange: post: operationId: exchangeMobileAuthorizationCode tags: [auth] summary: Exchange a mobile OIDC code for a session token requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MobileTokenExchangeRequest" responses: "200": description: Session created successfully. content: application/json: schema: $ref: "#/components/schemas/MobileTokenExchangeSuccess" "400": description: Missing or invalid required fields. content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Token did not contain usable claims. content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /mobile-auth/logout: post: operationId: logoutMobileSession tags: [auth] summary: Delete a mobile session token parameters: - $ref: "#/components/parameters/AuthorizationSessionHeader" responses: "200": description: Logout processed. content: application/json: schema: $ref: "#/components/schemas/LogoutSuccess" /reports: get: operationId: listReports tags: [reports] summary: Get all reports (feed view, newest first) responses: "200": description: List of reports content: application/json: schema: type: array items: $ref: "#/components/schemas/Report" post: operationId: createReport tags: [reports] summary: Submit a new field report and compute trust score requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReportInput" responses: "201": description: Report created with trust score content: application/json: schema: $ref: "#/components/schemas/Report" "400": description: Invalid input content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reports/map: get: operationId: getMapReports tags: [reports] summary: Get reports with travel-check data for map rendering responses: "200": description: Map-ready reports with geo-velocity lines content: application/json: schema: type: array items: $ref: "#/components/schemas/MapReport" /reports/stats: get: operationId: getReportStats tags: [reports] summary: Aggregate stats for dashboard header responses: "200": description: Feed statistics content: application/json: schema: $ref: "#/components/schemas/ReportStats" /reports/{id}: get: operationId: getReport tags: [reports] summary: Get a single report by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Report detail content: application/json: schema: $ref: "#/components/schemas/Report" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reporters/{id}: get: operationId: getReporter tags: [reports] summary: Get reporter profile parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Reporter profile content: application/json: schema: $ref: "#/components/schemas/Reporter" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/flags: get: operationId: listFlaggedReports tags: [admin] summary: Get all flagged reports for admin review responses: "200": description: Flagged reports content: application/json: schema: type: array items: $ref: "#/components/schemas/Report" /admin/reports/{id}/dismiss: patch: operationId: dismissReportFlag tags: [admin] summary: Dismiss flags on a report and mark it reviewed parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Updated report content: application/json: schema: $ref: "#/components/schemas/Report" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /storage/uploads/request-url: post: operationId: requestUploadUrl tags: [reports] summary: Request a presigned URL for photo upload requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UploadUrlRequest" responses: "200": description: Presigned upload URL content: application/json: schema: $ref: "#/components/schemas/UploadUrlResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: parameters: AuthorizationSessionHeader: name: Authorization in: header required: false description: Opaque session token — `Bearer `. schema: type: string SessionCookie: name: sid in: cookie required: false description: Browser session cookie. schema: type: string schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error AuthUser: type: object required: [id] properties: id: type: string email: type: ["string", "null"] firstName: type: ["string", "null"] lastName: type: ["string", "null"] profileImageUrl: type: ["string", "null"] AuthUserEnvelope: type: object required: [user] properties: user: oneOf: - $ref: "#/components/schemas/AuthUser" - type: "null" MobileTokenExchangeRequest: type: object required: [code, code_verifier, redirect_uri, state] properties: code: type: string minLength: 1 code_verifier: type: string minLength: 1 redirect_uri: type: string minLength: 1 state: type: string minLength: 1 nonce: type: string minLength: 1 MobileTokenExchangeSuccess: type: object required: [token] properties: token: type: string LogoutSuccess: type: object required: [success] properties: success: type: boolean Reporter: type: object properties: id: type: integer displayName: type: string createdAt: type: string format: date-time reputationScore: type: number reportCount: type: integer required: - id - displayName - createdAt - reputationScore - reportCount TrustFlag: type: object properties: type: type: string severity: type: string enum: [hard, soft, positive] description: > hard — strong negative signal (e.g. impossible travel); soft — weak negative signal (e.g. new account); positive — trust-boosting signal (e.g. corroboration_boost). detail: type: string required: - type - severity - detail TravelCheck: type: object properties: prevReportId: type: ["integer", "null"] distanceKm: type: number deltaHours: type: number impliedSpeedKmh: type: number verdict: type: string required: - prevReportId - distanceKm - deltaHours - impliedSpeedKmh - verdict Report: type: object properties: id: type: integer reporterId: type: integer text: type: string photoUrl: type: ["string", "null"] lat: type: number lon: type: number capturedAt: type: string format: date-time submittedAt: type: string format: date-time trustScore: type: integer flags: type: array items: $ref: "#/components/schemas/TrustFlag" status: type: string reporter: $ref: "#/components/schemas/Reporter" travelCheck: $ref: "#/components/schemas/TravelCheck" required: - id - reporterId - text - lat - lon - capturedAt - submittedAt - trustScore - flags - status - reporter MapReport: type: object properties: id: type: integer reporterId: type: integer lat: type: number lon: type: number trustScore: type: integer status: type: string capturedAt: type: string format: date-time text: type: string flags: type: array items: $ref: "#/components/schemas/TrustFlag" reporter: $ref: "#/components/schemas/Reporter" travelCheck: $ref: "#/components/schemas/TravelCheck" required: - id - reporterId - lat - lon - trustScore - status - capturedAt - text - flags - reporter ReportInput: type: object properties: text: type: string minLength: 1 photoUrl: type: ["string", "null"] lat: type: number lon: type: number capturedAt: type: string format: date-time required: - text - lat - lon - capturedAt ReportStats: type: object properties: totalReports: type: integer flaggedReports: type: integer trustedReports: type: integer uncertainReports: type: integer avgTrustScore: type: number required: - totalReports - flaggedReports - trustedReports - uncertainReports - avgTrustScore UploadUrlRequest: type: object properties: name: type: string size: type: integer contentType: type: string required: - name - size - contentType UploadUrlResponse: type: object properties: uploadURL: type: string objectPath: type: string required: - uploadURL - objectPath