Skip to content

Create Course

The createCourse mutation allows you to create a new course in your school with the specified properties.

Input Parameters

FieldTypeDescription
inputAdminCourseInput!Input object containing course creation details

AdminCourseInput Fields

FieldTypeRequiredDescription
nameString!YesCourse name
slugString!YesURL slug for the course. Must contain only lowercase letters, numbers, and hyphens
courseTypeString!YesType of the course (paid, public_access, free_redeem, pre_order)
descriptionStringNoCourse description
categoryIds[String!]NoIDs of categories to associate with this course
tagList[String!]NoTags to associate with this course

Return Type

type AdminCourseCreatePayload {
# The created course object, null if operation failed
course: AdminCourse
# Array of error messages, if any occurred during the operation
errors: [String!]
}

Example

mutation CreateCourse {
createCourse(input: {
name: "GraphQL Fundamentals"
slug: "graphql-fundamentals"
courseType: "paid"
description: "Learn the basics of GraphQL API development"
categoryIds: ["cat_123"]
tagList: ["graphql", "api", "development"]
}) {
course {
id
name
slug
courseType
description
}
errors
}
}

Sample Response

{
"data": {
"createCourse": {
"course": {
"id": "course_12345",
"name": "GraphQL Fundamentals",
"slug": "graphql-fundamentals",
"courseType": "paid",
"description": "Learn the basics of GraphQL API development"
},
"errors": []
}
}
}

Common Errors

ErrorDescription
Name cannot be emptyThe course name is required
Slug already existsThe provided slug is already in use
Invalid course typeThe courseType must be one of: paid, public_access, free_redeem, pre_order
Category not foundOne or more category IDs do not exist

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