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: SarthakSetu API - Food donation platform connecting donors with NGOs and volunteers servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: users description: User profile management - name: donations description: Food donation listings - name: claims description: NGO/volunteer claim system - name: stats description: Dashboard analytics - name: verify description: License and ID verification - name: admin description: Admin registry management 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" /users/me: get: operationId: getMyProfile tags: [users] summary: Get current user profile responses: "200": description: Current user profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" "404": description: Profile not found put: operationId: upsertMyProfile tags: [users] summary: Create or update current user profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserProfileInput" responses: "200": description: Profile updated content: application/json: schema: $ref: "#/components/schemas/UserProfile" /users/me/active-role: patch: operationId: switchActiveRole tags: [users] summary: Switch the currently active role requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SwitchRoleInput" responses: "200": description: Active role updated content: application/json: schema: $ref: "#/components/schemas/UserProfile" "400": description: Role not in user's roles list /donations: get: operationId: listDonations tags: [donations] summary: List food donations parameters: - name: status in: query schema: type: string enum: [available, claimed, picked_up, completed] - name: foodType in: query schema: type: string enum: [veg, non_veg, both] - name: donorCategory in: query schema: type: string enum: [restaurant, hotel, caterer, event_org, household] - name: lat in: query schema: type: number - name: lng in: query schema: type: number - name: radiusKm in: query schema: type: number - name: limit in: query schema: type: integer default: 50 - name: offset in: query schema: type: integer default: 0 responses: "200": description: List of donations content: application/json: schema: type: array items: $ref: "#/components/schemas/Donation" post: operationId: createDonation tags: [donations] summary: Create a new food donation listing requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DonationInput" responses: "201": description: Donation created content: application/json: schema: $ref: "#/components/schemas/Donation" /donations/{id}: get: operationId: getDonation tags: [donations] summary: Get a single donation by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Donation detail content: application/json: schema: $ref: "#/components/schemas/Donation" "404": description: Not found patch: operationId: updateDonation tags: [donations] summary: Update a donation listing parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DonationUpdate" responses: "200": description: Updated donation content: application/json: schema: $ref: "#/components/schemas/Donation" delete: operationId: deleteDonation tags: [donations] summary: Delete a donation listing parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /donations/{id}/claim: post: operationId: claimDonation tags: [claims] summary: NGO/volunteer claims a donation parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ClaimDonationInput" responses: "200": description: Claim created with a one-time pickup QR token content: application/json: schema: $ref: "#/components/schemas/Claim" /donations/{id}/verify: post: operationId: verifyPickup tags: [claims] summary: Verify pickup with OTP parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OtpVerifyInput" responses: "200": description: Pickup verified, donation marked completed content: application/json: schema: $ref: "#/components/schemas/Donation" "400": description: Invalid OTP /donations/{id}/verify-qr: post: operationId: verifyPickupQr tags: [claims] summary: Verify a pickup QR code and complete a donation description: The authenticated donor scans the QR shown by the claimant or pickup representative. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PickupQrVerifyInput" responses: "200": description: Pickup QR verified, donation marked completed content: application/json: schema: $ref: "#/components/schemas/Donation" "400": description: Invalid, expired, or already used QR "403": description: Only the donation owner can verify pickup /donations/{id}/unclaim: post: operationId: unclaimDonation tags: [claims] summary: Release a claim on a donation parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Claim released content: application/json: schema: $ref: "#/components/schemas/Donation" /stats/donor: get: operationId: getDonorStats tags: [stats] summary: Get stats for current donor responses: "200": description: Donor analytics content: application/json: schema: $ref: "#/components/schemas/DonorStats" /stats/ngo: get: operationId: getNgoStats tags: [stats] summary: Get stats for current NGO/volunteer responses: "200": description: NGO analytics content: application/json: schema: $ref: "#/components/schemas/NgoStats" /stats/platform: get: operationId: getPlatformStats tags: [stats] summary: Get platform-wide aggregate stats (public) responses: "200": description: Platform stats content: application/json: schema: $ref: "#/components/schemas/PlatformStats" /donations/my: get: operationId: getMyDonations tags: [donations] summary: Get donations created by the current user parameters: - name: status in: query schema: type: string enum: [available, claimed, picked_up, completed] responses: "200": description: My donation listings content: application/json: schema: type: array items: $ref: "#/components/schemas/Donation" /claims/my: get: operationId: getMyClaims tags: [claims] summary: Get claims made by the current NGO/volunteer responses: "200": description: My claims content: application/json: schema: type: array items: $ref: "#/components/schemas/Claim" /verify/fssai: post: operationId: verifyFssai tags: [verify] summary: Verify an FSSAI license number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/FssaiVerifyRequest" responses: "200": description: Verification result content: application/json: schema: $ref: "#/components/schemas/FssaiVerifyResult" /verify/darpan: post: operationId: verifyDarpan tags: [verify] summary: Verify a NITI Aayog Darpan ID requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DarpanVerifyRequest" responses: "200": description: Verification result content: application/json: schema: $ref: "#/components/schemas/DarpanVerifyResult" /verify/admin-code: post: operationId: verifyAdminCode tags: [verify] summary: Verify a platform admin access code requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminCodeVerifyRequest" responses: "200": description: Verification result content: application/json: schema: $ref: "#/components/schemas/AdminCodeVerifyResult" /admin/registry/fssai: get: operationId: listFssaiLicenses tags: [admin] summary: List all FSSAI licenses in the registry responses: "200": description: List of FSSAI licenses content: application/json: schema: type: array items: $ref: "#/components/schemas/FssaiLicense" post: operationId: addFssaiLicense tags: [admin] summary: Add a new FSSAI license to the registry requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/FssaiLicenseInput" responses: "201": description: License added content: application/json: schema: $ref: "#/components/schemas/FssaiLicense" /admin/registry/fssai/{id}: delete: operationId: deleteFssaiLicense tags: [admin] summary: Remove an FSSAI license from the registry parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/SuccessMessage" /admin/registry/darpan: get: operationId: listDarpanIds tags: [admin] summary: List all Darpan IDs in the registry responses: "200": description: List of Darpan IDs content: application/json: schema: type: array items: $ref: "#/components/schemas/DarpanIdEntry" post: operationId: addDarpanId tags: [admin] summary: Add a new Darpan ID to the registry requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DarpanIdInput" responses: "201": description: Darpan ID added content: application/json: schema: $ref: "#/components/schemas/DarpanIdEntry" /admin/registry/darpan/{id}: delete: operationId: deleteDarpanId tags: [admin] summary: Remove a Darpan ID from the registry parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/SuccessMessage" /admin/registry/codes: get: operationId: listAdminCodes tags: [admin] summary: List all admin access codes responses: "200": description: List of admin codes content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminCodeEntry" post: operationId: addAdminCode tags: [admin] summary: Add a new admin access code requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminCodeInput" responses: "201": description: Code added content: application/json: schema: $ref: "#/components/schemas/AdminCodeEntry" /admin/registry/codes/{id}: delete: operationId: deleteAdminCode tags: [admin] summary: Remove an admin access code parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/SuccessMessage" components: schemas: HealthStatus: type: object properties: status: type: string description: Overall API status example: ok database: type: string enum: [ok, error] description: Database connectivity status example: ok uptime: type: number description: Server uptime in seconds example: 1234.56 version: type: string description: Application version from package.json example: 0.0.0 gitCommit: type: string description: Git commit hash the image was built from, if available example: abc1234 required: - status - database - uptime - version - gitCommit SwitchRoleInput: type: object required: [role] properties: role: type: string enum: [donor, ngo, volunteer, admin] UserProfile: type: object required: [id, clerkId, role, roles, name, phone] properties: id: type: integer clerkId: type: string role: type: string enum: [donor, ngo, volunteer, admin] roles: type: array items: type: string enum: [donor, ngo, volunteer, admin] name: type: string phone: type: string address: type: ["string", "null"] city: type: ["string", "null"] lat: type: ["number", "null"] lng: type: ["number", "null"] donorCategory: type: ["string", "null"] enum: [restaurant, hotel, caterer, event_org, household, null] licenseNumber: type: ["string", "null"] orgName: type: ["string", "null"] registrationNumber: type: ["string", "null"] operatingRadiusKm: type: ["number", "null"] vehicleType: type: ["string", "null"] availabilityStatus: type: ["string", "null"] darpanId: type: ["string", "null"] createdAt: type: string format: date-time UserProfileInput: type: object required: [role, name, phone] properties: role: type: string enum: [donor, ngo, volunteer, admin] roles: type: array items: type: string enum: [donor, ngo, volunteer, admin] name: type: string phone: type: string address: type: string city: type: string lat: type: number lng: type: number donorCategory: type: string enum: [restaurant, hotel, caterer, event_org, household] licenseNumber: type: string orgName: type: string registrationNumber: type: string operatingRadiusKm: type: number vehicleType: type: string availabilityStatus: type: string darpanId: type: string Donation: type: object required: [id, donorId, foodName, foodType, quantityPlates, status, createdAt] properties: id: type: integer donorId: type: integer donor: $ref: "#/components/schemas/UserProfile" foodName: type: string foodType: type: string enum: [veg, non_veg, both] quantityPlates: type: integer estimatedServings: type: ["integer", "null"] preparedAt: type: ["string", "null"] format: date-time pickupDeadline: type: string format: date-time description: type: ["string", "null"] imageUrl: type: ["string", "null"] address: type: ["string", "null"] lat: type: ["number", "null"] lng: type: ["number", "null"] status: type: string enum: [available, claimed, picked_up, completed] claimedByUserId: type: ["integer", "null"] claimedBy: oneOf: - $ref: "#/components/schemas/UserProfile" - type: "null" otp: oneOf: - type: string - type: "null" pickupMode: oneOf: - type: string enum: [self, representative] - type: "null" pickupPersonName: type: ["string", "null"] pickupPersonPhone: type: ["string", "null"] createdAt: type: string format: date-time updatedAt: type: string format: date-time DonationInput: type: object required: [foodName, foodType, quantityPlates, pickupDeadline] properties: foodName: type: string foodType: type: string enum: [veg, non_veg, both] quantityPlates: type: integer minimum: 1 estimatedServings: type: integer preparedAt: type: string format: date-time pickupDeadline: type: string format: date-time description: type: string imageUrl: type: string address: type: string lat: type: number lng: type: number DonationUpdate: type: object properties: foodName: type: string foodType: type: string enum: [veg, non_veg, both] quantityPlates: type: integer estimatedServings: type: integer preparedAt: type: string format: date-time pickupDeadline: type: string format: date-time description: type: string imageUrl: type: string address: type: string lat: type: number lng: type: number status: type: string enum: [available, claimed, picked_up, completed] Claim: type: object required: [id, donationId, claimedByUserId, pickupMode, pickupPersonName, pickupPersonPhone, pickupQrToken, createdAt] properties: id: type: integer donationId: type: integer claimedByUserId: type: integer claimedBy: $ref: "#/components/schemas/UserProfile" otp: type: ["string", "null"] pickupMode: type: string enum: [self, representative] pickupPersonName: type: string pickupPersonPhone: type: string pickupQrToken: type: string otpVerified: type: boolean createdAt: type: string format: date-time completedAt: type: ["string", "null"] format: date-time donation: oneOf: - $ref: "#/components/schemas/Donation" - type: "null" OtpVerifyInput: type: object required: [otp] properties: otp: type: string ClaimDonationInput: type: object required: [pickupMode] properties: pickupMode: type: string enum: [self, representative] pickupPersonName: type: string description: Required when pickupMode is representative pickupPersonPhone: type: string description: Required when pickupMode is representative PickupQrVerifyInput: type: object required: [token] properties: token: type: string minLength: 20 DonorStats: type: object required: [totalDonations, totalPlates, completedDonations, activeDonations, claimedDonations] properties: totalDonations: type: integer totalPlates: type: integer completedDonations: type: integer activeDonations: type: integer claimedDonations: type: integer recentDonations: type: array items: $ref: "#/components/schemas/Donation" NgoStats: type: object required: [totalClaims, completedPickups, totalPlatesCollected, activeClaims] properties: totalClaims: type: integer completedPickups: type: integer totalPlatesCollected: type: integer activeClaims: type: integer recentClaims: type: array items: $ref: "#/components/schemas/Claim" PlatformStats: type: object required: [totalDonors, totalNgos, totalDonations, totalPlatesSaved, activeDonations] properties: totalDonors: type: integer totalNgos: type: integer totalDonations: type: integer totalPlatesSaved: type: integer activeDonations: type: integer SuccessMessage: type: object required: [message] properties: message: type: string FssaiVerifyRequest: type: object required: [licenseNumber] properties: licenseNumber: type: string FssaiVerifyResult: type: object required: [valid] properties: valid: type: boolean businessName: type: ["string", "null"] city: type: ["string", "null"] state: type: ["string", "null"] category: type: ["string", "null"] DarpanVerifyRequest: type: object required: [darpanId] properties: darpanId: type: string DarpanVerifyResult: type: object required: [valid] properties: valid: type: boolean orgName: type: ["string", "null"] city: type: ["string", "null"] state: type: ["string", "null"] AdminCodeVerifyRequest: type: object required: [code] properties: code: type: string AdminCodeVerifyResult: type: object required: [valid] properties: valid: type: boolean FssaiLicense: type: object required: [id, licenseNumber, businessName, city, state, category, isActive, addedAt] properties: id: type: integer licenseNumber: type: string businessName: type: string city: type: string state: type: string category: type: string isActive: type: boolean addedAt: type: string format: date-time FssaiLicenseInput: type: object required: [licenseNumber, businessName, city, state, category] properties: licenseNumber: type: string businessName: type: string city: type: string state: type: string category: type: string DarpanIdEntry: type: object required: [id, darpanId, orgName, city, state, isActive, addedAt] properties: id: type: integer darpanId: type: string orgName: type: string city: type: string state: type: string isActive: type: boolean addedAt: type: string format: date-time DarpanIdInput: type: object required: [darpanId, orgName, city, state] properties: darpanId: type: string orgName: type: string city: type: string state: type: string AdminCodeEntry: type: object required: [id, code, label, isActive, createdAt] properties: id: type: integer code: type: string label: type: string isActive: type: boolean usedByClerkId: type: ["string", "null"] createdAt: type: string format: date-time AdminCodeInput: type: object required: [code, label] properties: code: type: string label: type: string