Managing Guardians

A guardian is a user, such as a parent, who receives information about a student's courses and work. The guardian, who typically isn't a member of the student's Classroom domain, is represented in the Classroom API by the Guardian resource.

In order to become a student's guardian, a user must first be invited, using their email address.This creates a GuardianInvitation resource with a state of PENDING. The user will then receive an email prompting them to accept the invitation. If the email address is not associated with a Google account, the user will be prompted to create one before accepting the invitation.

While the invitation has a state of PENDING, the user may accept the invitation, which creates a Guardian resource and marks the GuardianInvitation with a state of COMPLETED. An invitation may also become COMPLETED if it expires, or if an authorized user cancels the invitation (for example, using the PatchGuardianInvitation method). A Guardian relationship may also be broken by a guardian, a Classroom teacher, or an administrator, using either the Classroom user interface or the DeleteGuardian method.

Who can manage guardians

The following table describes the actions that can be performed with respect to guardians, according to the type of user currently authenticated:

Table of guardian-related ACLs by user type


There are three scopes that allow you to manage guardians:

Common actions

This section describes some of the common guardian actions that you may want to perform using the Google Classroom API.

Create a guardian invitation

The following example shows how you can create a guardian invitation:

guardianInvitation = {
  'invitedEmailAddress': '',
guardianInvitation = service.userProfiles().guardianInvitations().create(
  studentId='', # You can use a user ID or an email address.
print("Invitation created with id: {0}".format(guardianInvitation.get('invitationId')))

The result includes a server-assigned identifier that can be used to refer to the GuardianInvitation.

Cancel a guardian invitation

The following example shows how to cancel an invitation if your user created one by mistake:

guardianInvitation = { 'state': 'COMPLETE'}
guardianInvitation = service.userProfiles().guardianInvitations().patch(
  invitationId=1234, # Replace with the invitation ID of the invitation you want to cancel

List invitations for a specific student

You can get a list of all invitations that have been sent for a specific student:

invitations = service.userProfiles().guardianInvitations().list(studentId='').execute()

By default, only PENDING invitations will be returned. As a domain administrator, you can also retrieve invitations in the COMPLETED state by providing a states parameter.

List active guardians

If you wish to determine which users are active guardians for a specific student, you can use the ListGuardians method:

guardians = service.userProfiles().guardians().list(studentId='').execute()

Remove guardians

You can also remove a Guardian from a student, using the DeleteGuardian method:

service.userProfiles().guardians().delete(studentId='', guardianId='').execute()

Enviar comentarios sobre…