Extend Student Course Access
The extendStudentCourseAccess
mutation allows you to extend a student’s access to a course by updating the ended_at date. This is useful when you want to grant additional time for course completion.
Input Parameters
Field | Type | Required | Description |
---|---|---|---|
userId | String! | Yes | ID of the student (User) whose access should be extended |
courseId | String! | Yes | ID of the course to extend access for |
extensionDays | Int | No* | Number of days to extend the access from the current ended_at date |
newEndedAt | Int | No* | New expiration date as Unix Timestamp (seconds since epoch). Takes precedence over extensionDays if both are provided |
indefinite | Boolean | No | If true, removes the access end date, granting unlimited access. Takes precedence over all other time parameters |
*At least one of extensionDays
, newEndedAt
, or indefinite
must be provided.
Return Type
type AdminExtendStudentCourseAccessPayload { # The updated enrollment with extended 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). Null if indefinite access is granted |
Example - Extend by Days
mutation ExtendStudentAccess { extendStudentCourseAccess( userId: "387b0c87-0f85-44cc-833e-7306c1b5d3e6" courseId: "9a1216f7-36de-4c50-8094-2ebfb7d3c383" extensionDays: 30 ) { enrollment { id completionRate createdAt updatedAt endedAt course { id name slug } user { id name email } } }}
Example - Set Specific End Date
mutation ExtendStudentAccessWithDate { extendStudentCourseAccess( userId: "387b0c87-0f85-44cc-833e-7306c1b5d3e6" courseId: "9a1216f7-36de-4c50-8094-2ebfb7d3c383" newEndedAt: 1735689600 ) { enrollment { id endedAt course { id name } user { id name } } }}
Example - Grant Indefinite Access
mutation GrantIndefiniteAccess { extendStudentCourseAccess( userId: "387b0c87-0f85-44cc-833e-7306c1b5d3e6" courseId: "9a1216f7-36de-4c50-8094-2ebfb7d3c383" indefinite: true ) { enrollment { id endedAt course { id name } user { id name } } }}
Sample Response
{ "data": { "extendStudentCourseAccess": { "enrollment": { "id": "619ad939-8591-40ad-9364-cf3825a9bf70", "completionRate": 0.5, "createdAt": 1672531200, "updatedAt": 1750076336, "endedAt": 1750076336, "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 |
Current enrollment has no end date | Cannot extend an enrollment that already has indefinite access |
The new end date is too far in the past. Please provide a timestamp after 2020. | The provided newEndedAt date is invalid |
Related Resources
- Enroll Student to Course - Enroll a student to a course
- Remove Student from Course - Remove a student’s enrollment
- Expire Student Course Access - Mark access as expired
- Course Management - Overview of course operations
For more information about the Teachify Admin API, please refer to the API Overview.