Skip to main content

Update Blog Post

Update an existing blog post.

HTTP Request

PATCH/api/blog/posts/:id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the blog post to update

Request Body

FieldTypeRequiredDescription
titleStringNoUpdated title of the blog post.
slugStringNoUpdated slug for the blog post (should be unique).
excerptStringNoUpdated short summary or excerpt of the blog post.
bodyStringNoUpdated full 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.patch('http://www.example.com/api/blog/posts/1', json={
3  'title': 'Updated Blog Post Title',
4  'excerpt': 'This is an updated excerpt for the blog post.',
5  'body': 'This is the updated full content of the blog post.'
6}, headers={
7  'Authorization': 'Token <your_api_key>'
8})
9
10print(response.json())

Status Codes

CodeDescription
200Blog post updated successfully
400Bad request — invalid input
404Blog post not found
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).