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
Field | Type | Required | Description |
---|---|---|---|
userId | String! | Yes | ID of the student (User) whose access should be expired |
courseId | String! | Yes | ID of the course to expire access for |
customEndedAt | Int | No | Custom expiration date as Unix Timestamp (seconds since epoch). Must be a positive integer after January 1, 2020. Defaults to current time |
reason | String | No | Optional reason for expiring the access |
Return Type
type AdminExpireStudentCourseAccessPayload { # The updated enrollment with expired access enrollment: StudentCourseShip}
StudentCourseShip Object
Field | Type | Description |
---|---|---|
id | String! | ID of the enrollment |
completionRate | Float | The completion rate of the enrolled course which student achieved |
course | AdminCourse! | Information of the enrolled course |
user | AdminUser! | User information of the enrolled course |
createdAt | Int! | Created date of the enrollment (Unix Timestamp) |
updatedAt | Int! | Last updated date of the enrollment (Unix Timestamp) |
endedAt | Int | Expiration 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", } } } }}
Common Errors
Error | Description |
---|---|
Student is not enrolled in this course | The student is not enrolled in the specified course |
Course not found | The specified course ID does not exist |
User not found | The 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 |
Related Resources
- Enroll Student to Course - Enroll a student to a course
- Remove Student from Course - Remove a student’s enrollment
- Extend Student Course Access - Extend access duration
- Course Management - Overview of course operations
For more information about the Teachify Admin API, please refer to the API Overview.