Create Blog Post
Create a new blog post.
HTTP Request
POST/api/blog/posts
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- 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 (required and should be unique). |
| excerpt | String | Yes | Short summary or excerpt of the blog post. |
| body | String | Yes | Full content of the blog post. |
| author | Integer | No | ID of the author of the blog post. |
| featured_image | Integer | No | ID of the featured image for the blog post. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2response = requests.post('http://www.example.com/api/blog/posts', json={
3 'title': 'My First Blog Post',
4 'slug': 'my-first-blog-post',
5 'excerpt': 'This is a short summary of my first blog post.',
6 'body': 'This is the full content of my first blog post.',
7 'author': 1,
8 'featured_image': 123
9})
10print(response.json())1curl -X POST "http://www.example.com/api/blog/posts" -H "Content-Type: application/json" -d '{
2 "title": "My First Blog Post",
3 "slug": "my-first-blog-post",
4 "excerpt": "This is a short summary of my first blog post.",
5 "body": "This is the full content of my first blog post.",
6 "author": 1,
7 "featured_image": 123
8}Status Codes
| Code | Description |
|---|---|
| 201 | Product created successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the blog post |
| title | String | Title of the blog post |
| slug | String | Slug for the blog post |
| views | Integer | Number of views the blog post has received |
| human_readable_views | String | Human-readable format of the views (e.g., 1.2K) |
| 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` |
| body | String | Full content of the blog post |
| truncated_body | String | Truncated version of the body (e.g., first 200 characters) |
| 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 |
Author Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the author |
| username | String | Username of the author |
| full_name | String | Full name of the author (first and last name combined) |
Featured Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the featured image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
- 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).