Skip to content

Create Post

The createPost mutation allows you to create a new post in your Teachify school with the specified properties.

Input Parameters

FieldTypeDescription
inputAdminPostInput!Input object containing post creation details

AdminPostInput Fields

FieldTypeRequiredDescription
titleString!YesPost title
subtitleStringNoPost subtitle
bodyString!YesPost body content
excerptStringNoPost excerpt
slugString!YesURL slug for the post. Must contain only lowercase letters, numbers, and hyphens
accessTypeString!YesAccess type for the post (login_required, paid, public_access)
publishedBooleanNoWhether the post is published
publishedAtIntNoUnix timestamp when the post should be published
categoryIdStringNoID of category to associate with this post
tagList[String!]NoTags to associate with this post
userIdStringNoID of the user (author) for this post

Return Type

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

Example

mutation CreatePost {
createPost(input: {
title: "Getting Started with GraphQL"
subtitle: "A comprehensive guide for beginners"
body: "GraphQL is a query language for APIs..."
excerpt: "Learn the basics of GraphQL"
slug: "getting-started-with-graphql"
accessType: "public_access"
published: true
tagList: ["graphql", "tutorial", "api"]
}) {
post {
id
title
subtitle
slug
accessType
published
tags
}
errors
}
}

Sample Response

{
"data": {
"createPost": {
"post": {
"id": "post_12345",
"title": "Getting Started with GraphQL",
"subtitle": "A comprehensive guide for beginners",
"slug": "getting-started-with-graphql",
"accessType": "public_access",
"published": true,
"tags": ["graphql", "tutorial", "api"]
},
"errors": []
}
}
}

Common Errors

ErrorDescription
Title cannot be emptyThe post title is required
Body cannot be emptyThe post body content is required
Slug already existsThe provided slug is already in use
Invalid access typeThe accessType must be one of: login_required, paid, public_access
Category not foundThe specified category ID does not exist
User not foundThe specified user ID does not exist

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