Hiện tại, các nhà phát triển đã có thể sử dụng rộng rãi tiện ích bổ sung của Google Lớp học! Vui lòng xem tài liệu về tiện ích bổ sung để biết thêm thông tin.
Quản trị viên miền được phép thêm trực tiếp người dùng trong miền của họ làm học viên vào các khoá học trong miền của họ. Học viên được phép tự thêm mình vào một khoá học bằng mã đăng ký.
Phương thức này trả về các mã lỗi sau:
PERMISSION_DENIED nếu người dùng yêu cầu không được phép tạo học viên trong khoá học này hoặc do lỗi truy cập.
NOT_FOUND nếu mã khoá học được yêu cầu không tồn tại.
FAILED_PRECONDITION nếu tài khoản của người dùng được yêu cầu bị vô hiệu hoá, đối với các lỗi yêu cầu sau:
CourseMemberLimitReached
CourseNotModifiable
UserGroupsMembershipLimitReached
InactiveCourseOwner
ALREADY_EXISTS nếu người dùng đã là học viên hoặc giáo viên trong khoá học.
Yêu cầu HTTP
POST https://classroom.googleapis.com/v1/courses/{courseId}/students
Giá trị nhận dạng của khoá học để tạo học viên. Giá trị nhận dạng này có thể là giá trị nhận dạng do Lớp học chỉ định hoặc alias.
Tham số truy vấn
Thông số
enrollmentCode
string
Mã đăng ký của khoá học để tạo học viên. Bạn bắt buộc phải có mã này nếu userId tương ứng với người dùng yêu cầu; bạn có thể bỏ qua mã này nếu người dùng yêu cầu có quyền quản trị để tạo học viên cho bất kỳ người dùng nào.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# Method: courses.students.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nAdds a user as a student of a course.\n\nDomain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as students to courses within their domain. Students are permitted to add themselves to a course using an enrollment code.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for [access errors](/workspace/classroom/reference/Access.Errors).\n- `NOT_FOUND` if the requested course ID does not exist.\n- `FAILED_PRECONDITION` if the requested user's account is disabled, for the following [request errors](/workspace/classroom/reference/Request.Errors):\n - CourseMemberLimitReached\n - CourseNotModifiable\n - UserGroupsMembershipLimitReached\n - InactiveCourseOwner\n- `ALREADY_EXISTS` if the user is already a student or teacher in the course.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/courses/{courseId}/students`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `courseId` | `string` Identifier of the course to create the student in. This identifier can be either the Classroom-assigned identifier or an [alias](/workspace/classroom/reference/rest/v1/courses.aliases#CourseAlias). |\n\n### Query parameters\n\n| Parameters ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `enrollmentCode` | `string` Enrollment code of the course to create the student in. This code is required if [userId](/workspace/classroom/reference/rest/v1/courses.students#Student.FIELDS.user_id) corresponds to the requesting user; it may be omitted if the requesting user has administrative permissions to create students for any user. |\n\n### Request body\n\nThe request body contains an instance of [Student](/workspace/classroom/reference/rest/v1/courses.students#Student).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Student](/workspace/classroom/reference/rest/v1/courses.students#Student).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/classroom.rosters`\n- `\n https://www.googleapis.com/auth/classroom.profile.emails`\n- `\n https://www.googleapis.com/auth/classroom.profile.photos`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]