The class enrollment API allows you to enrol an existing student into a class programmatically. Make sure you have the correct student ID, course ID, and API authentication before sending the request.
Prerequisites
Before calling the API, you will need:
Student ID
You can find the student ID (TnG ID) in two ways:
In the application:
Go to People > Students and open the student profile to view the TnG ID.
Via API:
Course ID
You can find the course (class) ID in two ways:
In the application:
Go to Classes, open the class, and locate the TnG ID.
Via API:
Required authentication
An API key is required to authenticate your request.
How to generate an API key
Go to School settings.
Open the Developers tab.
Click Create API key.
You can pass the API key in either of the following ways:
In the header:
X-API-KEY: yourapikey
OR
As a query parameter:
?apikey=yourapikey
Class enrollment API details
Request URL
https://app.teachngo.com/api/enrollclass
Method
POST
Body format
JSON
Example request body
{
"course_id": "56505",
"student_id": "141711",
"enrolment_date": "2024-02-11",
"unenrolment_date": "2024-02-11"
}
Field description
course_id – The class ID
student_id – The student ID
enrolment_date – The date the student is enrolled
unenrolment_date – Optional date if the student will leave the class
API responses
Success
{
"status": "success",
"message": "student have been added to enroll-unenroll Class"
}
Validation error (example 1)
{
"status": "fail",
"message": "validation Error.",
"errors": {
"student_id": "Student already enrolled"
}
}
Validation error (example 2)
{
"status": "fail",
"message": "validation Error.",
"errors": {
"student_id": "student id must be required",
"enrolment_date": "enrolment date field is missing."
}
}
401 Unauthorized
{
"status": "fail",
"message": "unauthorized user"
}
This API allows you to automate student enrolments into classes while maintaining accurate class records inside Teach ’n Go.