Skip to main content

Create Post

Create a new post.

HTTP Request​

POST/api/blog/posts

Authorization​

Authorization

  • Required: Yes
  • Permission: Staff with required PostPermission or Admin
  • 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.
authorIntegerNoBlog post author ID. Defaults to the current user if not provided or null.
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
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
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
metaArray[Object]List of meta data on the blog post

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) (nullable)
mime_typeStringMime type of the File (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)
thumbnailsArray[Object]thumbnails 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_fileObjectThe file value of the meta data

Meta value_file data structure

FieldTypeDescription
idIntegerUnique ID of the file
typeStringThe type of the file
mime_typeStringMime type of the File (e.g., image/jpeg) (nullable)
nameStringThe name of the file
sizeIntegerThe size of the file in bytes
human_readable_sizeStringThe human-readable size of the file
fStringThe url to the file

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",
"mime_type": "image/jpeg",
"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.jpg",
"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": []
}

Note​

  • 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