openapi: 3.1.0 info: title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: learning description: Learning program operations - name: admin description: Admin lesson and quiz operations - name: payments description: Premium access operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /me: get: operationId: getMe tags: [learning] summary: Current learner profile responses: "200": description: Learner profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" patch: operationId: updateMe tags: [learning] summary: Update current learner profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateProfileRequest" responses: "200": description: Updated profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" /settings/contact: get: operationId: getContactSettings tags: [learning] summary: Public contact info responses: "200": description: Contact info content: application/json: schema: $ref: "#/components/schemas/ContactSettings" /admin/settings/contact: put: operationId: adminUpdateContactSettings tags: [admin] summary: Admin update contact info requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ContactSettings" responses: "200": description: Updated contact info content: application/json: schema: $ref: "#/components/schemas/ContactSettings" /placement-test: get: operationId: getPlacementTest tags: [learning] summary: Get the signup placement test responses: "200": description: Placement test content: application/json: schema: $ref: "#/components/schemas/PlacementTestDetail" post: operationId: submitPlacementTest tags: [learning] summary: Submit the signup placement test requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubmitPlacementTestRequest" responses: "200": description: Placement result content: application/json: schema: $ref: "#/components/schemas/PlacementTestResult" /dashboard: get: operationId: getDashboard tags: [learning] summary: Learner dashboard summary responses: "200": description: Dashboard summary content: application/json: schema: $ref: "#/components/schemas/Dashboard" /lessons: get: operationId: listLessons tags: [learning] summary: List lessons responses: "200": description: Lessons grouped by day and level content: application/json: schema: type: array items: $ref: "#/components/schemas/LessonSummary" /lessons/{lessonId}: get: operationId: getLesson tags: [learning] summary: Get lesson details parameters: - name: lessonId in: path required: true schema: type: string responses: "200": description: Lesson details content: application/json: schema: $ref: "#/components/schemas/LessonDetail" /lessons/{lessonId}/quiz-attempts: post: operationId: submitLessonQuiz tags: [learning] summary: Submit a lesson quiz attempt parameters: - name: lessonId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubmitQuizRequest" responses: "200": description: Quiz result content: application/json: schema: $ref: "#/components/schemas/QuizAttemptResult" /final-tests/{level}: get: operationId: getFinalTest tags: [learning] summary: Get a level final test parameters: - name: level in: path required: true schema: type: integer minimum: 1 maximum: 3 responses: "200": description: Final test content: application/json: schema: $ref: "#/components/schemas/FinalTestDetail" /final-tests/{level}/attempts: post: operationId: submitFinalTest tags: [learning] summary: Submit a final test attempt parameters: - name: level in: path required: true schema: type: integer minimum: 1 maximum: 3 requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubmitQuizRequest" responses: "200": description: Final test result content: application/json: schema: $ref: "#/components/schemas/QuizAttemptResult" /final-tests/{level}/self-report: post: operationId: selfReportFinalTest tags: [learning] summary: Self-report a final test score taken on the static page parameters: - name: level in: path required: true schema: type: integer minimum: 1 maximum: 3 requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SelfReportRequest" responses: "200": description: Self-reported result content: application/json: schema: $ref: "#/components/schemas/SelfReportResult" /test-history: get: operationId: getTestHistory tags: [learning] summary: Get quiz and test history responses: "200": description: Test history content: application/json: schema: type: array items: $ref: "#/components/schemas/TestHistoryItem" /payments/status: get: operationId: getPaymentStatus tags: [payments] summary: Get premium status responses: "200": description: Payment status content: application/json: schema: $ref: "#/components/schemas/PaymentStatus" /payments/checkout: post: operationId: createCheckoutSession tags: [payments] summary: Create premium checkout session requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCheckoutRequest" responses: "200": description: Checkout information content: application/json: schema: $ref: "#/components/schemas/CheckoutResponse" /payments/qpay/invoices: post: operationId: createQpayInvoice tags: [payments] summary: Create QPay invoice and QR data requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateQpayInvoiceRequest" responses: "200": description: QPay invoice content: application/json: schema: $ref: "#/components/schemas/QpayInvoice" /payments/qpay/invoices/{invoiceId}: get: operationId: getQpayInvoice tags: [payments] summary: Get QPay invoice status data parameters: - name: invoiceId in: path required: true schema: type: string responses: "200": description: QPay invoice content: application/json: schema: $ref: "#/components/schemas/QpayInvoice" /payments/qpay/invoices/{invoiceId}/check: post: operationId: checkQpayInvoice tags: [payments] summary: Check QPay invoice payment status parameters: - name: invoiceId in: path required: true schema: type: string responses: "200": description: Updated QPay invoice content: application/json: schema: $ref: "#/components/schemas/QpayInvoice" /payments/qpay/callback: post: operationId: handleQpayCallback tags: [payments] summary: Handle QPay payment webhook callback requestBody: required: false content: application/json: schema: $ref: "#/components/schemas/QpayCallbackRequest" responses: "200": description: Callback handled content: application/json: schema: type: object properties: success: { type: boolean } required: [success] /payments/requests: get: operationId: listMyPaymentRequests tags: [payments] summary: List my manual payment requests responses: "200": description: Requests content: application/json: schema: type: array items: $ref: "#/components/schemas/PaymentRequest" post: operationId: createPaymentRequest tags: [payments] summary: Submit a manual Khan Bank payment proof requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePaymentRequestPayload" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/PaymentRequest" /admin/payment-requests: get: operationId: adminListPaymentRequests tags: [admin] summary: Admin list manual payment requests parameters: - name: status in: query required: false schema: { type: string, enum: [pending, approved, rejected, all] } responses: "200": description: Requests content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminPaymentRequest" /admin/payment-requests/{requestId}/decide: post: operationId: adminDecidePaymentRequest tags: [admin] summary: Approve or reject a manual payment request parameters: - name: requestId in: path required: true schema: { type: string } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DecidePaymentRequestPayload" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/AdminPaymentRequest" /admin/students: get: operationId: adminListStudents tags: [admin] summary: Admin list all students responses: "200": description: Students content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminStudentSummary" /admin/students/{userId}: get: operationId: adminGetStudent tags: [admin] summary: Admin student detail parameters: - name: userId in: path required: true schema: { type: string } responses: "200": description: Student detail content: application/json: schema: $ref: "#/components/schemas/AdminStudentDetail" /admin/students/{userId}/unlock: post: operationId: adminUnlockStudentProduct tags: [admin] summary: Manually unlock a product for a student parameters: - name: userId in: path required: true schema: { type: string } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUnlockStudentPayload" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/MutationResult" /admin/students/{userId}/reset-progress: post: operationId: adminResetStudentProgress tags: [admin] summary: Reset a student's lesson progress parameters: - name: userId in: path required: true schema: { type: string } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/MutationResult" /admin/placement-questions: get: operationId: adminListPlacementQuestions tags: [admin] summary: List placement test questions responses: "200": description: Questions content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminPlacementQuestion" post: operationId: adminCreatePlacementQuestion tags: [admin] summary: Create a placement question requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpsertPlacementQuestionRequest" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/AdminPlacementQuestion" /admin/placement-questions/{questionId}: put: operationId: adminUpdatePlacementQuestion tags: [admin] summary: Update a placement question parameters: - name: questionId in: path required: true schema: { type: string } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpsertPlacementQuestionRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/AdminPlacementQuestion" delete: operationId: adminDeletePlacementQuestion tags: [admin] summary: Delete a placement question parameters: - name: questionId in: path required: true schema: { type: string } responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/MutationResult" /admin/lessons/{lessonId}/duplicate: post: operationId: adminDuplicateLesson tags: [admin] summary: Duplicate a lesson into a new day parameters: - name: lessonId in: path required: true schema: { type: string } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminDuplicateLessonPayload" responses: "200": description: Created content: application/json: schema: $ref: "#/components/schemas/AdminLesson" /admin/lessons: get: operationId: adminListLessons tags: [admin] summary: Admin list lessons responses: "200": description: Lessons content: application/json: schema: type: array items: $ref: "#/components/schemas/AdminLesson" post: operationId: adminCreateLesson tags: [admin] summary: Create a lesson requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpsertLessonRequest" responses: "200": description: Created lesson content: application/json: schema: $ref: "#/components/schemas/AdminLesson" /admin/lessons/{lessonId}: put: operationId: adminUpdateLesson tags: [admin] summary: Update a lesson parameters: - name: lessonId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpsertLessonRequest" responses: "200": description: Updated lesson content: application/json: schema: $ref: "#/components/schemas/AdminLesson" delete: operationId: adminDeleteLesson tags: [admin] summary: Delete a lesson parameters: - name: lessonId in: path required: true schema: type: string responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/MutationResult" components: schemas: HealthStatus: type: object properties: status: type: string required: [status] ContactSettings: type: object properties: adminName: { type: string } phone: { type: string } email: { type: string } messenger: { type: string } facebook: { type: string } workingHours: { type: string } bankName: { type: string } bankIban: { type: string } bankHolder: { type: string } notes: { type: string } required: [adminName, phone, email, messenger, facebook, workingHours, bankName, bankIban, bankHolder, notes] UserProfile: type: object properties: id: { type: string } email: { type: string } name: { type: string } phone: { type: string, nullable: true } role: { type: string, enum: [learner, admin] } premium: { type: boolean } currentDay: { type: integer } placementCompleted: { type: boolean } placementLevel: { type: integer } createdAt: { type: string, format: date-time } required: [id, email, name, role, premium, currentDay, placementCompleted, placementLevel, createdAt] UpdateProfileRequest: type: object properties: name: { type: string, minLength: 1, maxLength: 100 } phone: { type: string, maxLength: 30, nullable: true } PlacementTestDetail: type: object properties: titleEn: { type: string } titleMn: { type: string } questions: type: array items: $ref: "#/components/schemas/QuizQuestion" required: [titleEn, titleMn, questions] SubmitPlacementTestRequest: type: object properties: answers: type: array items: type: object properties: questionId: { type: string } answer: { type: string } required: [questionId, answer] required: [answers] PlacementTestResult: type: object properties: score: { type: integer } total: { type: integer } percentage: { type: integer } level: { type: integer } startingDay: { type: integer } messageEn: { type: string } messageMn: { type: string } correctAnswers: type: array items: type: object properties: questionId: { type: string } correctAnswer: { type: string } isCorrect: { type: boolean } required: [questionId, correctAnswer, isCorrect] required: [score, total, percentage, level, startingDay, messageEn, messageMn, correctAnswers] LessonSummary: type: object properties: id: { type: string } day: { type: integer } level: { type: integer } titleEn: { type: string } titleMn: { type: string } durationMinutes: { type: integer } isPremium: { type: boolean } isUnlocked: { type: boolean } completed: { type: boolean } bestScore: { type: integer, nullable: true } required: [id, day, level, titleEn, titleMn, durationMinutes, isPremium, isUnlocked, completed, bestScore] LessonDetail: allOf: - $ref: "#/components/schemas/LessonSummary" - type: object properties: objectiveEn: { type: string } objectiveMn: { type: string } contentEn: { type: string } contentMn: { type: string } lessonContent: $ref: "#/components/schemas/LessonTemplateContent" pdfUrl: { type: string, nullable: true } audioUrl: { type: string, nullable: true } vocabulary: type: array items: $ref: "#/components/schemas/VocabularyItem" quiz: type: array items: $ref: "#/components/schemas/QuizQuestion" required: [objectiveEn, objectiveMn, contentEn, contentMn, lessonContent, pdfUrl, audioUrl, vocabulary, quiz] LessonTemplateContent: type: object additionalProperties: true VocabularyItem: type: object properties: english: { type: string } pronunciation: { type: string } mongolian: { type: string } example: { type: string } required: [english, mongolian, example] QuizQuestion: type: object properties: id: { type: string } promptEn: { type: string } promptMn: { type: string } options: type: array items: { type: string } required: [id, promptEn, promptMn, options] SubmitQuizRequest: type: object properties: answers: type: array items: type: object properties: questionId: { type: string } answer: { type: string } required: [questionId, answer] required: [answers] QuizAttemptResult: type: object properties: id: { type: string } score: { type: integer } total: { type: integer } percentage: { type: integer } passed: { type: boolean } completedDay: { type: integer, nullable: true } correctAnswers: type: array items: type: object properties: questionId: { type: string } correctAnswer: { type: string } isCorrect: { type: boolean } required: [questionId, correctAnswer, isCorrect] required: [id, score, total, percentage, passed, completedDay, correctAnswers] SelfReportRequest: type: object properties: score: { type: integer, minimum: 0, maximum: 50 } total: { type: integer, minimum: 1, maximum: 50 } required: [score, total] SelfReportResult: type: object properties: id: { type: string } score: { type: integer } total: { type: integer } percentage: { type: integer } passed: { type: boolean } required: [id, score, total, percentage, passed] FinalTestDetail: type: object properties: id: { type: string } level: { type: integer } titleEn: { type: string } titleMn: { type: string } passingScore: { type: integer } questions: type: array items: $ref: "#/components/schemas/QuizQuestion" required: [id, level, titleEn, titleMn, passingScore, questions] TestHistoryItem: type: object properties: id: { type: string } type: { type: string, enum: [lesson, final] } titleEn: { type: string } titleMn: { type: string } day: { type: integer, nullable: true } level: { type: integer } score: { type: integer } total: { type: integer } percentage: { type: integer } createdAt: { type: string } required: [id, type, titleEn, titleMn, day, level, score, total, percentage, createdAt] Dashboard: type: object properties: completedDays: { type: integer } totalDays: { type: integer } currentLevel: { type: integer } averageScore: { type: integer } premium: { type: boolean } nextLesson: anyOf: - $ref: "#/components/schemas/LessonSummary" - type: "null" recentHistory: type: array items: $ref: "#/components/schemas/TestHistoryItem" levelProgress: type: array items: type: object properties: level: { type: integer } completed: { type: integer } total: { type: integer } required: [level, completed, total] required: [completedDays, totalDays, currentLevel, averageScore, premium, nextLesson, recentHistory, levelProgress] PaymentStatus: type: object properties: premium: { type: boolean } providerConnected: { type: boolean } message: { type: string } recentInvoices: type: array items: $ref: "#/components/schemas/QpayInvoice" products: type: array items: type: object properties: productId: { type: string } name: { type: string } amount: { type: integer } currency: { type: string } required: [productId, name, amount, currency] required: [premium, providerConnected, message, recentInvoices, products] CreateCheckoutRequest: type: object properties: plan: { type: string, enum: [program] } required: [plan] CheckoutResponse: type: object properties: checkoutUrl: { type: string, nullable: true } providerConnected: { type: boolean } message: { type: string } required: [checkoutUrl, providerConnected, message] CreateQpayInvoiceRequest: type: object properties: productId: type: string examples: ["lesson:LESSON_UUID", "level:1", "course:full"] required: [productId] QpayCallbackRequest: type: object additionalProperties: true QpayInvoice: type: object properties: id: { type: string } invoiceCode: { type: string } qpayInvoiceId: { type: string, nullable: true } paymentStatus: { type: string, enum: [pending, paid, failed, expired] } productId: { type: string } productName: { type: string } amount: { type: integer } currency: { type: string } unlockStatus: { type: string, enum: [locked, unlocked] } qrText: { type: string, nullable: true } qrImage: { type: string, nullable: true } paymentUrl: { type: string, nullable: true } providerConnected: { type: boolean } message: { type: string, nullable: true } createdAt: { type: string } updatedAt: { type: string } required: [id, invoiceCode, paymentStatus, productId, productName, amount, currency, unlockStatus, providerConnected, createdAt, updatedAt] AdminLesson: allOf: - $ref: "#/components/schemas/LessonDetail" - type: object properties: correctAnswers: type: array items: type: object properties: questionId: { type: string } answer: { type: string } required: [questionId, answer] required: [correctAnswers] UpsertLessonRequest: type: object properties: day: { type: integer, minimum: 1, maximum: 90 } level: { type: integer, minimum: 1, maximum: 3 } titleEn: { type: string } titleMn: { type: string } objectiveEn: { type: string } objectiveMn: { type: string } contentEn: { type: string } contentMn: { type: string } lessonContent: $ref: "#/components/schemas/LessonTemplateContent" pdfUrl: { type: string, nullable: true } audioUrl: { type: string, nullable: true } durationMinutes: { type: integer } isPremium: { type: boolean } vocabulary: type: array items: $ref: "#/components/schemas/VocabularyItem" quiz: type: array items: type: object properties: id: { type: string } promptEn: { type: string } promptMn: { type: string } options: type: array items: { type: string } correctAnswer: { type: string } required: [id, promptEn, promptMn, options, correctAnswer] required: [day, level, titleEn, titleMn, objectiveEn, objectiveMn, contentEn, contentMn, durationMinutes, isPremium, vocabulary, quiz] AdminPlacementQuestion: type: object properties: id: { type: string } position: { type: integer } band: { type: string, enum: [a1, a2, b1] } promptEn: { type: string } promptMn: { type: string } options: type: array items: { type: string } correctAnswer: { type: string } required: [id, position, band, promptEn, promptMn, options, correctAnswer] UpsertPlacementQuestionRequest: type: object properties: position: { type: integer, minimum: 1 } band: { type: string, enum: [a1, a2, b1] } promptEn: { type: string, minLength: 1 } promptMn: { type: string } options: type: array items: { type: string, minLength: 1 } minItems: 2 correctAnswer: { type: string, minLength: 1 } required: [position, band, promptEn, options, correctAnswer] MutationResult: type: object properties: success: { type: boolean } required: [success] PaymentRequest: type: object properties: id: { type: string } productId: { type: string } productName: { type: string } amount: { type: integer } currency: { type: string } bankName: { type: string } transactionRef: { type: string, nullable: true } payerName: { type: string, nullable: true } screenshotUrl: { type: string, nullable: true } note: { type: string, nullable: true } status: { type: string, enum: [pending, approved, rejected] } adminNote: { type: string, nullable: true } reviewedAt: { type: string, nullable: true } createdAt: { type: string } required: [id, productId, productName, amount, currency, bankName, transactionRef, payerName, screenshotUrl, note, status, adminNote, reviewedAt, createdAt] AdminPaymentRequest: allOf: - $ref: "#/components/schemas/PaymentRequest" - type: object properties: userId: { type: string } userEmail: { type: string } userName: { type: string } required: [userId, userEmail, userName] CreatePaymentRequestPayload: type: object properties: productId: { type: string } transactionRef: { type: string } payerName: { type: string } screenshotUrl: { type: string, nullable: true } note: { type: string, nullable: true } required: [productId, transactionRef, payerName] DecidePaymentRequestPayload: type: object properties: decision: { type: string, enum: [approve, reject] } adminNote: { type: string, nullable: true } required: [decision] AdminUnlockStudentPayload: type: object properties: productId: { type: string } required: [productId] AdminDuplicateLessonPayload: type: object properties: day: { type: integer, minimum: 1, maximum: 90 } titleEn: { type: string } titleMn: { type: string } required: [day] AdminStudentSummary: type: object properties: id: { type: string } email: { type: string } name: { type: string } role: { type: string } premium: { type: boolean } placementLevel: { type: integer } completedLessons: { type: integer } unlocks: type: array items: { type: string } pendingPaymentRequests: { type: integer } createdAt: { type: string } required: [id, email, name, role, premium, placementLevel, completedLessons, unlocks, pendingPaymentRequests, createdAt] AdminStudentDetail: allOf: - $ref: "#/components/schemas/AdminStudentSummary" - type: object properties: history: type: array items: $ref: "#/components/schemas/TestHistoryItem" paymentRequests: type: array items: $ref: "#/components/schemas/PaymentRequest" invoices: type: array items: $ref: "#/components/schemas/QpayInvoice" required: [history, paymentRequests, invoices]