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
| Field | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | Title of the blog post. |
| slug | String | Yes | Slug for the blog post (unique). |
| is_published | Boolean | No | Whether the post has published status (default=False) |
| excerpt | String | Yes | Short summary or excerpt of the blog post. |
| author | Integer | No | ID of the author of the blog post (nullable) |
| featured_image | Integer | No | ID of the featured image for the blog post(nullable) |
| categories | Integer | No | List of ids of the blog categories |
| body | String | Yes | Full content of the blog post. |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# Create a new blog post
2curl -X POST "http://www.example.com/api/blog/posts"
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json"
5-d '{
6 'title': 'My First Blog Post',
7 'slug': 'my-first-blog-post',
8 'is_published': true,
9 'excerpt': 'This is a short summary of my first blog post.',
10 'author': 1,
11 'featured_image': 123,
12 'categories': [1, 2],
13 'body': 'This is the full content of my first blog post.'
14}Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the blog post(unique) |
| title | String | Title of the blog post |
| slug | String | Slug for the blog post(unique) |
| views | Integer | Number of views the blog post has received(default=0) |
| human_readable_views | String | Human-readable format of the views (e.g., 1.2K) |
| is_published | Boolean | Whether the post is published(true) or draft(false) |
| excerpt | String | Short summary or excerpt of the blog post |
| truncated_excerpt | String | Truncated version of the excerpt (e.g., first 100 characters) |
| author_data | Object | Author details including `id`, `username`, and `full_name` |
| featured_image_data | Object | Featured image data including `id`, `type`, `name`, `size`, `human_readable_size`, `f`, `width`, `height`, and `mode` |
| categories_data | object | Post categories data |
| created_at | String (ISO 8601) | Timestamp when the blog post was created |
| updated_at | String (ISO 8601) | Timestamp when the blog post was last updated |
| truncated_body | String | Truncated version of the post body |
| body | String | Body of the post |
| meta | object |
Author Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the author (unique) |
| username | String | Username of the author (unique) |
| full_name | String | Full name of the author (nullable) |
Featured Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the featured image (unique) |
| type | String | File type (e.g., image/jpeg) (nullable) |
| name | String | Original file name (nullable) |
| size | Integer | File size in bytes (nullable) |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) (nullable) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels (nullable) |
| height | Integer | Image height in pixels (nullable) |
| mode | String | Color mode (e.g., RGB, CMYK) (nullable) |
| thumbnails | List of thumbnail objects | thumbnails of the image |
Thumbnail Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the thumbnail (unique) |
| f | String | URL to access the thumbnail file |
| size | Integer | File size in bytes (nullable) |
Post Category Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Post category id (unique) |
| name | String | Post category name |
Meta Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Id of the meta data |
| key | String | The key name of the meta data |
| value_text | String | The text value of the meta data |
| value_file | File | The 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