Skip to main content

Create Post Categories

Create a new blog post categories

HTTP Request

POST/api/blog/categories

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with required PostCategoryPermission or Admin
  • Permission Code: 3201
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
imageIntegerNoRelated image of the post category
orderIntegerNoRow order of the post category
parentIntegerNoThe parent category id of the post category
nameStringYesName of the post category
slugStringYesThe slug of the post category(uniqeu)
descriptionStringNoThe description of the post category

Example Requests

1import requests
2response = requests.post('http://www.example.com/api/blog/categories', json={
3  "image": 7,
4  "order": 1,
5  "parent": null,
6  "name": "cpu",
7  "slug": "cpu",
8  "description": "central processing unit"
9},
10headers={'Authorization': 'Token <your_api_key>'})
11print(response.json())

Response Fields

FieldTypeDescription
idIntegerId of the post category(unique)
image_dataObjectRelated image of the post category(nullable)
orderIntegerRow order of the category(nullable)
parentIntegerParent id of the category(nullable)
nameStringname of the category
slugStringslug of the category (unique, nullable)
descriptionStringdescription of the post category(nullable)
posts_countIntegerthe number of blog posts under this category
children_countIntegerthe number of child categories
created_atdatetimethe creation time of the post category
updated_atdatetimelast updated time of the post category

Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the featured image (unique)
typeStringFile type (e.g., image/jpeg) (nullable)
nameStringOriginal file name (nullable)
sizeIntegerFile size in bytes (nullable)
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB) (nullable)
fStringURL to access the image file
widthIntegerImage width in pixels (nullable)
heightIntegerImage height in pixels (nullable)
modeStringColor mode (e.g., RGB, CMYK) (nullable)
thumbnailsList of thumbnail objectsthumbnails of the image

Thumbnail Data Structure

FieldTypeDescription
idIntegerUnique ID of the thumbnail (unique)
fStringURL to access the thumbnail file
sizeIntegerFile size in bytes (nullable)

Example Response

{
"id": 3,
"image_data": {
"id": 7,
"type": "image",
"name": "computers",
"size": 3284,
"human_readable_size": "3.21 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/12/02/computer.png",
"width": 235,
"height": 215,
"mode": "P",,
"thumbnails": [
{
"id": 313,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 314,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 315,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 316,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
},
"order": 1,
"parent": null,
"name": "cpu",
"slug": "cpu",
"description": "central processing unit",
"posts_count": 0,
"children_count": 0,
"created_at": "2025-12-02T14:33:37.856753Z",
"updated_at": "2025-12-02T14:33:37.856762Z"
}