Skip to content

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

FieldTypeRequiredDescription
userIdString!YesID of the student (User) whose access should be extended
courseIdString!YesID of the course to extend access for
extensionDaysIntNo*Number of days to extend the access from the current ended_at date
newEndedAtIntNo*New expiration date as Unix Timestamp (seconds since epoch). Takes precedence over extensionDays if both are provided
indefiniteBooleanNoIf 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

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). 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",
"email": "[email protected]"
}
}
}
}
}

Common Errors

ErrorDescription
Student is not enrolled in this courseThe student is not enrolled in the specified course
Current enrollment has no end dateCannot 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

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