Create Course
The createCourse mutation allows you to create a new course in your school with the specified properties.
Input Parameters
Section titled “Input Parameters”| Field | Type | Description |
|---|---|---|
input | AdminCourseInput! | Input object containing course creation details |
AdminCourseInput Fields
Section titled “AdminCourseInput Fields”| Field | Type | Required | Description |
|---|---|---|---|
name | String! | Yes | Course name |
slug | String! | Yes | URL slug for the course. Must contain only lowercase letters, numbers, and hyphens |
courseType | String! | Yes | Type of the course (paid, public_access, free_redeem, pre_order) |
description | String | No | Course description |
categoryIds | [String!] | No | IDs of categories to associate with this course |
tagList | [String!] | No | Tags to associate with this course |
Return Type
Section titled “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
Section titled “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
Section titled “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
Section titled “Common Errors”| Error | Description |
|---|---|
Name cannot be empty | The course name is required |
Slug already exists | The provided slug is already in use |
Invalid course type | The courseType must be one of: paid, public_access, free_redeem, pre_order |
Category not found | One or more category IDs do not exist |
Related Resources
Section titled “Related Resources”- Update Course - Update an existing course
- Delete Course - Delete a course
- Course Management - Overview of course operations
For more information about the Teachify Admin API, please refer to the API Overview.