Skip to main content

Create Blog Post

Create a new blog post.

HTTP Request

POST/api/blog/posts

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
titleStringYesTitle of the blog post.
slugStringYesSlug for the blog post (unique).
is_publishedBooleanNoWhether the post has published status (default=False)
excerptStringYesShort summary or excerpt of the blog post.
authorIntegerNoID of the author of the blog post (nullable)
featured_imageIntegerNoID of the featured image for the blog post(nullable)
categoriesIntegerNoList of ids of the blog categories
bodyStringYesFull content of the blog post.

Example Requests

1import requests
2
3# Create a new blog post
4response = requests.post('http://www.example.com/api/blog/posts', json={
5  'title': 'My First Blog Post',
6  'slug': 'my-first-blog-post',
7  'is_published': true,
8  'excerpt': 'This is a short summary of my first blog post.',
9  'author': 1,
10  'featured_image': 123,
11  'categories': [1, 2],
12  'body': 'This is the full content of my first blog post.'
13},
14headers={'Authorization': 'Token <your_api_key>'}
15)
16print(response.json())

Response Fields

FieldTypeDescription
idIntegerUnique ID of the blog post(unique)
titleStringTitle of the blog post
slugStringSlug for the blog post(unique)
viewsIntegerNumber of views the blog post has received(default=0)
human_readable_viewsStringHuman-readable format of the views (e.g., 1.2K)
is_publishedBooleanWhether the post is published(true) or draft(false)
excerptStringShort summary or excerpt of the blog post
truncated_excerptStringTruncated version of the excerpt (e.g., first 100 characters)
author_dataObjectAuthor details including `id`, `username`, and `full_name`
featured_image_dataObjectFeatured image data including `id`, `type`, `name`, `size`, `human_readable_size`, `f`, `width`, `height`, and `mode`
categories_dataobjectPost categories data
created_atString (ISO 8601)Timestamp when the blog post was created
updated_atString (ISO 8601)Timestamp when the blog post was last updated
truncated_bodyStringTruncated version of the post body
bodyStringBody of the post
metaobject

Author Data Structure

FieldTypeDescription
idIntegerUnique ID of the author (unique)
usernameStringUsername of the author (unique)
full_nameStringFull name of the author (nullable)

Featured 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)

Post Category Data Structure

FieldTypeDescription
idIntegerPost category id (unique)
nameStringPost category name

Meta Data Structure

FieldTypeDescription
idIntegerId of the meta data
keyStringThe key name of the meta data
value_textStringThe text value of the meta data
value_fileFileThe file value of the meta data

Example Response

{
"id": 44,
"title": "blog-name1",
"slug": "blog-name100000002",
"views": 0,
"human_readable_views": "0",
"is_published": true,
"excerpt": "test",
"truncated_excerpt": "test",
"author_data": {
"id": 1,
"username": "BehroozGhorbani",
"full_name": "بهروز قربانی"
},
"featured_image_data": {
"id": 1,
"type": "image",
"name": "logitech-logo",
"size": 2763,
"human_readable_size": "2.70 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/11/22/logitech.png",
"width": 287,
"height": 176,
"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
}
]
},
"categories_data": [
{
"id": 2,
"name": "Technology"
},
{
"id": 1,
"name": "Computer"
}
],
"created_at": "2025-12-01T10:56:07.096692Z",
"updated_at": "2025-12-01T10:56:07.096699Z",
"truncated_body": "test",
"body": "test",
"meta": []
}
    • Set True value to is_published field to publish the blog post immediately after creation. By default, it is set to False, meaning the blog post will be created as a draft (for showing in shop).
    • Metadata are only editable from the core page endpints