POST /classes/{classId}/students

Creates a new student and enrolls them in the specified class.

Path parameters

  • classId string Required

    The class ID

application/json

Body Required

Request payload for creating a new student. The endpoint will create the student and enroll them in the class.

  • firstName string Required

    First name of the student

    Maximum length is 100.

  • lastName string Required

    Last name of the student

    Maximum length is 100.

  • email string(email) Required

    Email address of the student

  • phoneNumber string | null

    Phone number of student

  • avatarUrl string | null

    Avatar image URL

Responses

  • 200 application/json

    Student created and enrolled successfully

    Hide response attributes Show response attributes object
    • success boolean
    • code integer(int32)
    • message string
    • data object

      API response schema for student returned by student endpoints (includes profile and credentials when applicable)

      Hide data attributes Show data attributes object
      • id string

        Unique identifier for the student record

      • userId string

        Associated user/profile id

      • enrollmentDate string(date) | null

        Enrollment date

      • address string | null

        Student address

      • parentContactEmail string | null

        Parent contact email

      • status string | null

        Student status

        Values are active, transferred, graduated, or dropped.

      • createdAt string(date-time) | null

        Record creation timestamp

      • updatedAt string(date-time) | null

        Record update timestamp

      • username string | null

        Generated username/email (only set during create/import)

      • password string | null

        Temporary password (only set during create/import)

      • firstName string | null

        First name from user profile

      • lastName string | null

        Last name from user profile

      • avatarUrl string(uri) | null

        Avatar URL from user profile

      • phoneNumber string | null

        Phone number from user profile

  • 400 application/json

    Bad Request - Invalid input data

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 404 application/json

    Class or student not found

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
  • 500 application/json

    Internal Server Error

    Hide response attributes Show response attributes object
    • success boolean
    • code integer
    • errorCode string
    • message string
    • timestamp string(date-time)
POST /classes/{classId}/students
curl \
 --request POST 'http://localhost:8080/api/classes/{classId}/students' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"email":"nguyen.van.a@example.com","lastName":"Van A","firstName":"Nguyen","phoneNumber":"+84987654321"}'
Request example
{
  "email": "nguyen.van.a@example.com",
  "lastName": "Van A",
  "firstName": "Nguyen",
  "phoneNumber": "+84987654321"
}
Response examples (200)
{
  "code": 200,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440003",
    "status": "active",
    "userId": "user_002",
    "address": "456 Elm St",
    "lastName": "Thi B",
    "password": "XyZ987!@#",
    "username": "tran.thi.b@example.com",
    "avatarUrl": "https://example.com/avatar2.jpg",
    "createdAt": "2024-01-15T10:30:00Z",
    "firstName": "Tran",
    "updatedAt": "2024-09-20T14:45:00Z",
    "phoneNumber": "+84981234567",
    "enrollmentDate": "2024-01-15",
    "parentContactEmail": "parent2@example.com"
  },
  "message": "Student created and enrolled successfully",
  "success": true
}
Response examples (400)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (404)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}
Response examples (500)
{
  "success": false,
  "code": 42,
  "errorCode": "string",
  "message": "string",
  "timestamp": "2026-05-04T09:42:00Z"
}