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: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication and registration - name: emergencies description: Emergency lifecycle (create, list, respond, deactivate) - name: reviewer description: Reviewer-only operations (verifying vulnerable accounts) - name: volunteer description: Volunteer-only operations (location share) - name: vulnerable description: Vulnerable-only operations (profile + location) - name: nok description: Next-of-kin operations (linked vulnerable's profile + SOS feed) paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/signup: post: operationId: signup tags: [auth] summary: Sign up as Volunteer and/or Vulnerable requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SignupRequest" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/SessionUser" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Email already registered for the chosen role content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/login: post: operationId: login tags: [auth] summary: Log in to a specific role vault requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/SessionUser" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Log out responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/OkResponse" /auth/verify: get: operationId: verifyEmail tags: [auth] summary: Verify an email address using the token sent in the signup email parameters: - in: query name: token required: true schema: type: string - in: query name: role required: true schema: type: string enum: [volunteer, vulnerable] responses: "200": description: Verified content: application/json: schema: $ref: "#/components/schemas/EmailVerified" "400": description: Invalid or expired token content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/resend-verification: post: operationId: resendVerification tags: [auth] summary: Resend the verification email for the signed-in user responses: "200": description: Sent content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Already verified or wrong role content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/users: post: operationId: adminCreateUser tags: [auth] summary: Admin-only — create a Reviewer or Admin account requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminCreateUserRequest" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/AdminCreatedUser" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Email already registered for that role content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /emergencies: get: operationId: listEmergencies tags: [emergencies] summary: List emergencies — scope depends on caller's role responses: "200": description: Emergencies content: application/json: schema: $ref: "#/components/schemas/EmergencyList" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" post: operationId: createEmergency tags: [emergencies] summary: Create an emergency. Vulnerable creates Minor; Reviewer/Admin creates Major. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateEmergencyRequest" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/Emergency" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Role not permitted to create this emergency type content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /emergencies/{id}/deactivate: post: operationId: deactivateEmergency tags: [emergencies] summary: Admin only — deactivate an emergency parameters: - in: path name: id required: true schema: type: integer responses: "200": description: Deactivated content: application/json: schema: $ref: "#/components/schemas/Emergency" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /emergencies/{id}/respond: post: operationId: respondEmergency tags: [emergencies] summary: Volunteer (or Admin/Reviewer for testing) accepts or declines an emergency parameters: - in: path name: id required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RespondEmergencyRequest" responses: "200": description: Recorded content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Volunteer role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /emergencies/{id}/arrive: post: operationId: arriveEmergency tags: [emergencies] summary: Volunteer marks themselves as arrived on-scene parameters: - in: path name: id required: true schema: type: integer responses: "200": description: Recorded content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Must be an accepted Volunteer for this emergency content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Response not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reviewer/pending-vulnerable: get: operationId: listPendingVulnerable tags: [reviewer] summary: Reviewer/Admin — list vulnerable accounts awaiting verification responses: "200": description: List content: application/json: schema: $ref: "#/components/schemas/PendingVulnerableList" "403": description: Reviewer role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reviewer/users-overview: get: operationId: reviewerListUsers tags: [auth] summary: Reviewer — list every Volunteer and Vulnerable account (read-only) responses: "200": description: All Volunteer + Vulnerable accounts content: application/json: schema: $ref: "#/components/schemas/ReviewerUsersOverview" "403": description: Reviewer or Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reviewer/volunteer/{id}/verify: post: operationId: verifyVolunteer tags: [auth] summary: Reviewer — mark a Volunteer account verified parameters: - in: path name: id required: true schema: type: integer responses: "200": description: Verified content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Reviewer or Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reviewer/vulnerable/{id}/verify: post: operationId: verifyVulnerable tags: [reviewer] summary: Reviewer/Admin — mark a vulnerable account as verified parameters: - in: path name: id required: true schema: type: integer responses: "200": description: Verified content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Reviewer role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reviewer/users/{role}/{id}: post: operationId: reviewerUpdateUser tags: [reviewer] summary: Reviewer/Admin — edit a Volunteer or Vulnerable account (partial) parameters: - in: path name: role required: true schema: type: string enum: [volunteer, vulnerable] - in: path name: id required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUpdateUserRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Reviewer role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Email already registered in this vault content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /volunteer/location: post: operationId: updateVolunteerLocation tags: [volunteer] summary: Volunteer — share current GPS location requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateLocationRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Volunteer role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /nok/me: get: operationId: getNokMe tags: [nok] summary: NOK — fetch own profile + linked vulnerable details responses: "200": description: NOK profile with linked vulnerable content: application/json: schema: $ref: "#/components/schemas/NokMe" "403": description: NOK role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /vulnerable/me: get: operationId: getVulnerableMe tags: [vulnerable] summary: Vulnerable — fetch own profile (NOK + address) responses: "200": description: Profile content: application/json: schema: $ref: "#/components/schemas/VulnerableMe" "403": description: Vulnerable role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /vulnerable/location: post: operationId: updateVulnerableLocation tags: [vulnerable] summary: Vulnerable — share current GPS location requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateLocationRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Vulnerable role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/volunteer-locations: get: operationId: adminListVolunteerLocations tags: [auth] summary: Reviewer/Admin — live locations of volunteers (for the live-emergencies map) responses: "200": description: Volunteer locations content: application/json: schema: type: object properties: volunteers: type: array items: $ref: "#/components/schemas/VolunteerLocation" required: [volunteers] "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/users-overview: get: operationId: adminListAllUsers tags: [auth] summary: Admin — list every user across all four vaults responses: "200": description: All users content: application/json: schema: $ref: "#/components/schemas/AdminUsersOverview" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/users/{role}/{id}/disable: post: operationId: adminDisableUser tags: [auth] summary: Admin — disable a user (cannot sign in until enabled) parameters: - in: path name: role required: true schema: $ref: "#/components/schemas/ManagedUserRole" - in: path name: id required: true schema: type: integer responses: "200": description: Disabled content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Cannot disable yourself content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/users/{role}/{id}/enable: post: operationId: adminEnableUser tags: [auth] summary: Admin — re-enable a previously disabled user parameters: - in: path name: role required: true schema: $ref: "#/components/schemas/ManagedUserRole" - in: path name: id required: true schema: type: integer responses: "200": description: Enabled content: application/json: schema: $ref: "#/components/schemas/OkResponse" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /admin/users/{role}/{id}: post: operationId: adminUpdateUser tags: [auth] summary: Admin — update a user's profile fields parameters: - in: path name: role required: true schema: $ref: "#/components/schemas/ManagedUserRole" - in: path name: id required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUpdateUserRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Email already in use within this vault content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: adminDeleteUser tags: [auth] summary: Admin — permanently remove a user from their vault parameters: - in: path name: role required: true schema: $ref: "#/components/schemas/ManagedUserRole" - in: path name: id required: true schema: type: integer responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/OkResponse" "400": description: Cannot delete yourself or last remaining admin content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Admin role required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get the current session user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/SessionUser" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: schemas: HealthStatus: type: object properties: status: type: string required: - status OkResponse: type: object properties: ok: type: boolean required: - ok ErrorResponse: type: object properties: message: type: string required: - message Role: type: string enum: [admin, reviewer, volunteer, vulnerable, nok] ManagedUserRole: type: string description: Roles that can be administered via /admin/users (NOK is auto-managed via its linked Vulnerable, hence excluded). enum: [admin, reviewer, volunteer, vulnerable] SignupRole: type: string enum: [volunteer, vulnerable] VolunteerProfileInput: type: object properties: skills: type: string gpsConsent: type: boolean required: - gpsConsent VulnerableProfileInput: type: object properties: address: type: string nokName: type: string nokRelation: type: string nokContact: type: string required: - address - nokName - nokRelation - nokContact NokAccountInput: type: object description: Optional NOK login credentials when registering a Vulnerable. When supplied, a linked nok_users row is created so the next-of-kin can log in and receive SOS notifications. properties: email: type: string password: type: string minLength: 8 required: - email - password SignupRequest: type: object properties: email: type: string password: type: string minLength: 8 name: type: string roles: type: array minItems: 1 items: $ref: "#/components/schemas/SignupRole" volunteer: $ref: "#/components/schemas/VolunteerProfileInput" vulnerable: $ref: "#/components/schemas/VulnerableProfileInput" nokAccount: $ref: "#/components/schemas/NokAccountInput" required: - email - password - name - roles LoginRequest: type: object properties: email: type: string password: type: string role: $ref: "#/components/schemas/Role" required: - email - password EmailVerified: type: object properties: ok: type: boolean email: type: string role: type: string enum: [volunteer, vulnerable] required: - ok - email - role AdminRole: type: string enum: [reviewer, admin] AdminCreateUserRequest: type: object properties: email: type: string password: type: string minLength: 8 name: type: string role: $ref: "#/components/schemas/AdminRole" required: - email - password - name - role AdminUpdateUserRequest: type: object description: All fields optional. Only provided fields are updated. Per-role extras are ignored when not applicable. properties: name: type: string email: type: string password: type: string minLength: 8 skills: type: string nullable: true description: Volunteer only. address: type: string description: Vulnerable only. nokName: type: string description: Vulnerable only. nokRelation: type: string description: Vulnerable only. nokContact: type: string description: Vulnerable only. AdminCreatedUser: type: object properties: id: type: integer email: type: string name: type: string role: $ref: "#/components/schemas/AdminRole" required: - id - email - name - role AdminListAdmin: type: object properties: id: type: integer email: type: string name: type: string disabled: type: boolean createdAt: type: string format: date-time required: [id, email, name, disabled, createdAt] AdminListReviewer: type: object properties: id: type: integer email: type: string name: type: string disabled: type: boolean createdAt: type: string format: date-time required: [id, email, name, disabled, createdAt] VolunteerLocation: type: object properties: id: type: integer name: type: string lat: type: number lng: type: number lastSeenAt: type: string format: date-time nullable: true required: [id, name, lat, lng, lastSeenAt] AdminListVolunteer: type: object properties: id: type: integer email: type: string name: type: string disabled: type: boolean skills: type: string nullable: true gpsConsent: type: boolean emailVerified: type: boolean verified: type: boolean lastSeenAt: type: string format: date-time nullable: true createdAt: type: string format: date-time required: [id, email, name, disabled, gpsConsent, emailVerified, verified, createdAt] AdminListVulnerable: type: object properties: id: type: integer email: type: string name: type: string disabled: type: boolean verified: type: boolean emailVerified: type: boolean address: type: string nokName: type: string nokRelation: type: string nokContact: type: string createdAt: type: string format: date-time required: - id - email - name - disabled - verified - emailVerified - address - nokName - nokRelation - nokContact - createdAt ReviewerUsersOverview: type: object properties: volunteers: type: array items: $ref: "#/components/schemas/AdminListVolunteer" vulnerables: type: array items: $ref: "#/components/schemas/AdminListVulnerable" required: [volunteers, vulnerables] AdminUsersOverview: type: object properties: admins: type: array items: $ref: "#/components/schemas/AdminListAdmin" reviewers: type: array items: $ref: "#/components/schemas/AdminListReviewer" volunteers: type: array items: $ref: "#/components/schemas/AdminListVolunteer" vulnerables: type: array items: $ref: "#/components/schemas/AdminListVulnerable" required: [admins, reviewers, volunteers, vulnerables] EmergencyType: type: string enum: [minor, major] EmergencyStatus: type: string enum: [active, deactivated, resolved] Emergency: type: object properties: id: type: integer type: $ref: "#/components/schemas/EmergencyType" status: $ref: "#/components/schemas/EmergencyStatus" creatorRole: $ref: "#/components/schemas/Role" creatorUserId: type: integer creatorName: type: string description: type: string nullable: true lat: type: number nullable: true lng: type: number nullable: true address: type: string nullable: true createdAt: type: string format: date-time deactivatedAt: type: string format: date-time nullable: true distanceM: type: integer nullable: true description: Volunteer-relative distance in metres, only present in volunteer scope. myResponse: type: string nullable: true enum: [accepted, declined] myArrivedAt: type: string format: date-time nullable: true description: When the current Volunteer marked themselves arrived (volunteer scope only). responseStats: $ref: "#/components/schemas/EmergencyResponseStats" nullable: true responders: type: array nullable: true description: Per-volunteer responder rows with name, distance and live ETA. Returned to Reviewer/Admin (all emergencies) and to the Vulnerable creator + their NOK (their own emergency only). items: $ref: "#/components/schemas/EmergencyResponder" required: - id - type - status - creatorRole - creatorUserId - creatorName - createdAt EmergencyResponseStats: type: object properties: accepted: type: integer declined: type: integer arrived: type: integer total: type: integer required: [accepted, declined, arrived, total] EmergencyResponder: type: object properties: volunteerId: type: integer name: type: string status: type: string enum: [accepted, declined] respondedAt: type: string format: date-time arrivedAt: type: string format: date-time nullable: true distanceM: type: integer nullable: true description: Current straight-line distance from volunteer's last GPS to the emergency. etaSeconds: type: integer nullable: true description: Estimated time to arrival (walking 5 km/h). Null if no GPS or already arrived. required: [volunteerId, name, status, respondedAt] EmergencyList: type: object properties: emergencies: type: array items: $ref: "#/components/schemas/Emergency" required: - emergencies CreateEmergencyRequest: type: object properties: type: $ref: "#/components/schemas/EmergencyType" description: type: string lat: type: number lng: type: number address: type: string required: - type RespondEmergencyRequest: type: object properties: status: type: string enum: [accepted, declined] required: - status PendingVulnerable: type: object properties: id: type: integer email: type: string name: type: string address: type: string nokName: type: string nokRelation: type: string nokContact: type: string emailVerified: type: boolean createdAt: type: string format: date-time required: - id - email - name - address - nokName - nokRelation - nokContact - emailVerified - createdAt PendingVulnerableList: type: object properties: items: type: array items: $ref: "#/components/schemas/PendingVulnerable" required: - items NokMe: type: object properties: id: { type: integer } name: { type: string } email: { type: string } contact: { type: string } linkedVulnerable: type: object properties: id: { type: integer } name: { type: string } address: { type: string } verified: { type: boolean } lastLat: { type: number, nullable: true } lastLng: { type: number, nullable: true } lastSeenAt: { type: string, nullable: true, format: date-time } required: [id, name, address, verified, lastLat, lastLng, lastSeenAt] required: [id, name, email, contact, linkedVulnerable] VulnerableMe: type: object properties: id: { type: integer } name: { type: string } email: { type: string } address: { type: string } nokName: { type: string } nokRelation: { type: string } nokContact: { type: string } verified: { type: boolean } emailVerified: { type: boolean } required: [id, name, email, address, nokName, nokRelation, nokContact, verified, emailVerified] UpdateLocationRequest: type: object properties: lat: type: number lng: type: number required: - lat - lng SessionUser: type: object properties: id: type: integer email: type: string name: type: string role: $ref: "#/components/schemas/Role" verified: type: boolean emailVerified: type: boolean sessionToken: type: string description: Signed session token returned on signup/login/me. Mobile clients send it as an Authorization Bearer header on subsequent requests. required: - id - email - name - role - emailVerified