Skip to main content

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

FieldTypeRequiredDescription
titleStringYesTitle of the blog post.
slugStringYesSlug for the blog post (required and should be unique).
excerptStringYesShort summary or excerpt of the blog post.
bodyStringYesFull content of the blog post.
authorIntegerNoID of the author of the blog post.
featured_imageIntegerNoID of the featured image for the blog post.

Example Requests

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

Status Codes

CodeDescription
201Product created successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the blog post
titleStringTitle of the blog post
slugStringSlug for the blog post
viewsIntegerNumber of views the blog post has received
human_readable_viewsStringHuman-readable format of the views (e.g., 1.2K)
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`
bodyStringFull content of the blog post
truncated_bodyStringTruncated version of the body (e.g., first 200 characters)
created_atString (ISO 8601)Timestamp when the blog post was created
updated_atString (ISO 8601)Timestamp when the blog post was last updated

Author Data Structure

FieldTypeDescription
idIntegerUnique ID of the author
usernameStringUsername of the author
full_nameStringFull name of the author (first and last name combined)

Featured Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the featured image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor 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).