Skip to main content
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

string
required
The MongoDB ObjectId of the course

Response

Returns a PDF certificate file with appropriate headers.

Success Response (200)

The response body contains the PDF binary data.

Certificate Contents

The generated certificate includes:
string
The authenticated user’s full name from Clerk
string
The completed course title
date
The date when the course was completed (last lecture marked as completed)
string
A unique identifier stored in the database for verification
A URL that can be used to verify the certificate’s authenticity

Error Responses

  • User is not enrolled in the course
  • Course does not exist
  • User has not completed the course
Error generating the PDF certificate

Implementation Details

Certificate Generation Process

  1. Verify enrollment: Check that the user is enrolled in the course
  2. Check completion: Verify that all lectures are marked as completed
  3. Retrieve certificate record: Look up the Certificate model entry
  4. Generate PDF: Use Puppeteer to render HTML template as PDF
  5. Return file: Stream the PDF to the client

Database Model

Certificates are stored in the Certificate collection:

Code Examples

Use Cases

  1. Student downloads certificate after completing a course
  2. Share on LinkedIn by uploading the generated PDF
  3. Verify certificate authenticity using the certificate ID
  4. Track student achievements via the Certificate collection