Get Certificate
User API
Get Certificate
Retrieve a course completion certificate
GET
Get Certificate
Overview
Generates and returns a PDF certificate for a completed course. The certificate includes the student’s name, course title, completion date, and a unique certificate ID.Certificates are automatically generated when a user completes 100% of a course’s lectures.
Authentication
Requires Clerk authentication. The user must be enrolled in the course and have completed all lectures.Path Parameters
The MongoDB ObjectId of the course
Response
Returns a PDF certificate file with appropriate headers.Success Response (200)
Certificate Contents
The generated certificate includes:The authenticated user’s full name from Clerk
The completed course title
The date when the course was completed (last lecture marked as completed)
A unique identifier stored in the database for verification
A URL that can be used to verify the certificate’s authenticity
Error Responses
404 Not Found
- User is not enrolled in the course
- Course does not exist
- User has not completed the course
500 Internal Server Error
Error generating the PDF certificate
Implementation Details
Certificate Generation Process
- Verify enrollment: Check that the user is enrolled in the course
- Check completion: Verify that all lectures are marked as completed
- Retrieve certificate record: Look up the Certificate model entry
- Generate PDF: Use Puppeteer to render HTML template as PDF
- Return file: Stream the PDF to the client
Database Model
Certificates are stored in theCertificate collection:
Code Examples
Use Cases
- Student downloads certificate after completing a course
- Share on LinkedIn by uploading the generated PDF
- Verify certificate authenticity using the certificate ID
- Track student achievements via the Certificate collection
Related Endpoints
- Update Course Progress - Mark lectures as completed
- Get Enrolled Courses - Check course completion status