Skip to main content

Existing student class enrollment API

Learn how to use the Class Enrollment API to enrol an existing student into a class in Teach ’n Go.

Abdullah Al-Hussein avatar
Written by Abdullah Al-Hussein
Updated this week

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:

Course ID

You can find the course (class) ID in two ways:


Required authentication

An API key is required to authenticate your request.

How to generate an API key

  1. Go to School settings.

  2. Open the Developers tab.

  3. 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.

Did this answer your question?