ここでは、2つの方法でクラスを作成する手順を書いていきます
- ClassroomのWeb上からクラスを作成する方法
- Apps Scriptでクラスを作成する方法
ClassroomのWeb上で作る場合
ホーム > クラスを作成
または
ホーム > 右上の + > クラスを作成
学校で利用する場合は、学校に Google Workspace for Education アカウントを登録してもらう必要があるようです
今回この記事では、個人アカウントでの利用で学校では利用しないため、チェックを入れて続行をクリックします
クラス名は必須で、セクション、科目、部屋も必要に応じて入力して、作成をクリックします
指導科目にクラスが作成されました
Apps Scriptで作る場合
Classroomのクラスはコードで作成することもできるようなので、試してみました
コードを実行する前に、Google Classroom API を追加します
サービス > Google Classroom API > 追加
Code.gs
function createClassroomCourse() {
var course = {
name: "English Class - Spring 2025",
section: "Section A",
descriptionHeading: "English Introduction Course",
description: "A course designed to help students learn basic English communication skills.",
room: "Room 101",
ownerId: "me", // 現在のユーザーを教師として設定
courseState: "PROVISIONED" // クラスをすぐに有効にする
};
try {
var newCourse = Classroom.Courses.create(course);
Logger.log("Course created: %s (%s)", newCourse.name, newCourse.id);
} catch (e) {
Logger.log("Error creating course: %s", e.message);
}
}
createClassroomCourse() を実行してアクセス許可をすると
クラスが作成されます

承諾すると指導科目にクラスが追加されます
Tips
コードはChatGPTに書いてもらいました
ClassroomのWeb上では科目を入力できますが、コードからは入力できないようですsubjectのフィールドが Classroom API v1 には存在しないため
Reference
REST Resource: courses
承諾すると指導科目にクラスが追加されます
Tips
コードはChatGPTに書いてもらいました
ClassroomのWeb上では科目を入力できますが、コードからは入力できないようです
試したらこんなエラーが出ました↓
Error creating course: API call to classroom.courses.create failed with error: Invalid JSON payload received. Unknown name "subject" at 'course': Cannot find field.
Reference
コースを作成する
Google Apps Script のクイックスタート
Classroom サービス
Google Classroom API