Skip to content

Expire Student Course Access

The expireStudentCourseAccess mutation allows you to mark a student’s course access as expired while retaining their course data. This is useful when you want to temporarily revoke a student’s access without removing their progress and enrollment records.

Input Parameters

FieldTypeRequiredDescription
userIdString!YesID of the student (User) whose access should be expired
courseIdString!YesID of the course to expire access for
customEndedAtIntNoCustom expiration date as Unix Timestamp (seconds since epoch). Must be a positive integer after January 1, 2020. Defaults to current time
reasonStringNoOptional reason for expiring the access

Return Type

type AdminExpireStudentCourseAccessPayload {
# The updated enrollment with expired access
enrollment: StudentCourseShip
}

StudentCourseShip Object

FieldTypeDescription
idString!ID of the enrollment
completionRateFloatThe completion rate of the enrolled course which student achieved
courseAdminCourse!Information of the enrolled course
userAdminUser!User information of the enrolled course
createdAtInt!Created date of the enrollment (Unix Timestamp)
updatedAtInt!Last updated date of the enrollment (Unix Timestamp)
endedAtIntExpiration date for the enrollment (Unix Timestamp)

Example

mutation ExpireStudentAccess {
expireStudentCourseAccess(
userId: "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv"
courseId: "ab6ee332-614d-475d-93b5-abc5ebb1fc84"
) {
enrollment {
id
completionRate
createdAt
updatedAt
endedAt
course {
id
name
slug
}
user {
id
name
email
}
}
}
}

Example with Custom Expiration Date

mutation ExpireStudentAccessWithCustomDate {
expireStudentCourseAccess(
userId: "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv"
courseId: "ab6ee332-614d-475d-93b5-abc5ebb1fc84"
customEndedAt: 1735689600
reason: "Course access expired due to non-payment"
) {
enrollment {
id
endedAt
course {
id
name
}
user {
id
name
}
}
}
}

Sample Response

{
"data": {
"expireStudentCourseAccess": {
"enrollment": {
"id": "619ad939-8591-40ad-9364-cf3825a9bf70",
"completionRate": 0.25,
"createdAt": 1672531200,
"updatedAt": 1747297936,
"endedAt": 1747297936,
"course": {
"id": "9a1216f7-36de-4c50-8094-2ebfb7d3c383",
"name": "Introduction to GraphQL",
"slug": "intro-graphql"
},
"user": {
"id": "387b0c87-0f85-44cc-833e-7306c1b5d3e6",
"name": "Student",
"email": "[email protected]"
}
}
}
}
}

Common Errors

ErrorDescription
Student is not enrolled in this courseThe student is not enrolled in the specified course
Course not foundThe specified course ID does not exist
User not foundThe specified user ID does not exist
The new end date is too far in the past. Please provide a timestamp after 2020.The provided customEndedAt date is invalid

For more information about the Teachify Admin API, please refer to the API Overview.